diff --git a/.github/workflows/new-issue-notify.yml b/.github/workflows/new-issue-notify.yml index ce09368..c4776fe 100644 --- a/.github/workflows/new-issue-notify.yml +++ b/.github/workflows/new-issue-notify.yml @@ -11,11 +11,24 @@ jobs: runs-on: ubuntu-latest steps: - name: Send Slack Notification for New Issue + env: + ISSUE_TITLE: ${{ github.event.issue.title }} + ISSUE_USER: ${{ github.event.issue.user.login }} + ISSUE_URL: ${{ github.event.issue.html_url }} + REPO_NAME: ${{ github.repository }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} run: | - MESSAGE_TEXT="*📢 New Issue Opened in ${{ github.repository }} 📢*\n\n*Issue Title:* ${{ github.event.issue.title }}\n*Opened By:* ${{ github.event.issue.user.login }}\n\n*View Issue:* ${{ github.event.issue.html_url }}" + # Build message text using jq to safely handle user input + MESSAGE_TEXT=$(jq -n \ + --arg repo "$REPO_NAME" \ + --arg title "$ISSUE_TITLE" \ + --arg user "$ISSUE_USER" \ + --arg url "$ISSUE_URL" \ + '*📢 New Issue Opened in \($repo) 📢*\n\n*Issue Title:* \($title)\n*Opened By:* \($user)\n\n*View Issue:* \($url)') + # Build Slack payload SLACK_PAYLOAD=$(jq -n \ - --arg text "${MESSAGE_TEXT}" \ + --arg text "$MESSAGE_TEXT" \ '{ "channel": "#docs-devdocs-notifications", "username": "Issue Notifier", @@ -23,7 +36,8 @@ jobs: "text": $text }') + # Send to Slack curl -X POST \ -H 'Content-type: application/json' \ --data "$SLACK_PAYLOAD" \ - ${{ secrets.SLACK_WEBHOOK }} + "$SLACK_WEBHOOK" diff --git a/.github/workflows/run-express-tests.yml b/.github/workflows/run-express-tests.yml index 36457cc..7f3e960 100644 --- a/.github/workflows/run-express-tests.yml +++ b/.github/workflows/run-express-tests.yml @@ -1,7 +1,7 @@ name: Run Express Tests on: - pull_request_target: + pull_request: branches: - development paths: @@ -16,18 +16,30 @@ jobs: test: name: Run Express Tests runs-on: ubuntu-latest - # Require manual approval for fork PRs - environment: testing - - defaults: - run: - working-directory: server/js-express steps: - name: Checkout code uses: actions/checkout@v5 - with: - ref: ${{ github.event.pull_request.head.sha }} + + - name: Install Atlas CLI + run: | + curl https://fastdl.mongodb.org/mongocli/mongodb-atlas-cli_1.47.0_linux_x86_64.deb --output atlas-cli.deb + sudo apt install ./atlas-cli.deb + + - name: Set up a local deployment using Atlas CLI + run: | + atlas deployments setup myLocalRs1 --type local --port 27017 --force + + - name: Install MongoDB Database Tools to load sample data + run: | + curl https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.13.0.deb --output mdb-db-tools.deb + sudo apt install ./mdb-db-tools.deb + + - name: Download sample data + run: curl https://atlas-education.s3.amazonaws.com/sampledata.archive -o sampledata.archive + + - name: Add sample data to database + run: mongorestore --archive=sampledata.archive --port=27017 - name: Set up Node.js uses: actions/setup-node@v4 @@ -35,19 +47,23 @@ jobs: node-version: '20' - name: Install dependencies + working-directory: server/js-express run: npm install - name: Run unit tests + working-directory: server/js-express run: npm run test:unit -- --json --outputFile=test-results-unit.json || true env: - MONGODB_URI: ${{ secrets.MFLIX_URI }} + MONGODB_URI: mongodb://localhost:27017/sample_mflix - name: Run integration tests + working-directory: server/js-express run: npm run test:integration -- --json --outputFile=test-results-integration.json || true env: - MONGODB_URI: ${{ secrets.MFLIX_URI }} + MONGODB_URI: mongodb://localhost:27017/sample_mflix ENABLE_SEARCH_TESTS: true - VOYAGE_API_KEY: ${{ secrets.VOYAGE_AI }} + # Note: Vector search tests will be skipped without VOYAGE_API_KEY + # Run these tests locally with a valid API key - name: Upload test results uses: actions/upload-artifact@v4 @@ -62,7 +78,6 @@ jobs: - name: Generate Test Summary if: always() - working-directory: . run: | chmod +x .github/scripts/generate-test-summary-jest.sh .github/scripts/generate-test-summary-jest.sh \ diff --git a/.github/workflows/run-java-spring-boot-tests.yml b/.github/workflows/run-java-spring-boot-tests.yml index 6c4ffa9..2709569 100644 --- a/.github/workflows/run-java-spring-boot-tests.yml +++ b/.github/workflows/run-java-spring-boot-tests.yml @@ -1,7 +1,7 @@ name: Run Java Spring Boot Tests on: - pull_request_target: + pull_request: branches: - development paths: @@ -16,22 +16,30 @@ jobs: test: name: Run Java Spring Boot Tests runs-on: ubuntu-latest - # Require manual approval for fork PRs - environment: testing - - defaults: - run: - working-directory: mflix/server/java-spring - - env: - MONGODB_URI: ${{ secrets.MFLIX_URI }} - ENABLE_SEARCH_TESTS: true steps: - name: Checkout code uses: actions/checkout@v5 - with: - ref: ${{ github.event.pull_request.head.sha }} + + - name: Install Atlas CLI + run: | + curl https://fastdl.mongodb.org/mongocli/mongodb-atlas-cli_1.47.0_linux_x86_64.deb --output atlas-cli.deb + sudo apt install ./atlas-cli.deb + + - name: Set up a local deployment using Atlas CLI + run: | + atlas deployments setup myLocalRs1 --type local --port 27017 --force + + - name: Install MongoDB Database Tools to load sample data + run: | + curl https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.13.0.deb --output mdb-db-tools.deb + sudo apt install ./mdb-db-tools.deb + + - name: Download sample data + run: curl https://atlas-education.s3.amazonaws.com/sampledata.archive -o sampledata.archive + + - name: Add sample data to database + run: mongorestore --archive=sampledata.archive --port=27017 - name: Set up JDK 21 uses: actions/setup-java@v5 @@ -41,14 +49,24 @@ jobs: cache: 'maven' - name: Make mvnw executable + working-directory: mflix/server/java-spring run: chmod +x mvnw - name: Run unit tests + working-directory: mflix/server/java-spring run: ./mvnw test + env: + MONGODB_URI: mongodb://localhost:27017/sample_mflix - name: Run integration tests + working-directory: mflix/server/java-spring run: ./mvnw test -Dtest=MongoDBSearchIntegrationTest continue-on-error: true + env: + MONGODB_URI: mongodb://localhost:27017/sample_mflix + ENABLE_SEARCH_TESTS: true + # Note: Vector search tests will be skipped without VOYAGE_API_KEY + # Run these tests locally with a valid API key - name: Upload test results uses: actions/upload-artifact@v4 @@ -60,7 +78,6 @@ jobs: - name: Generate Test Summary if: always() - working-directory: . run: | chmod +x .github/scripts/generate-test-summary-surefire.sh .github/scripts/generate-test-summary-surefire.sh mflix/server/java-spring/target/surefire-reports diff --git a/.github/workflows/run-python-tests.yml b/.github/workflows/run-python-tests.yml index 11b43cc..ecbd341 100644 --- a/.github/workflows/run-python-tests.yml +++ b/.github/workflows/run-python-tests.yml @@ -1,7 +1,7 @@ name: Run Python Tests on: - pull_request_target: + pull_request: branches: - development paths: @@ -16,40 +16,56 @@ jobs: test: name: Run Python Tests runs-on: ubuntu-latest - # Require manual approval for fork PRs - environment: testing - - defaults: - run: - working-directory: mflix/server/python-fastapi steps: - name: Checkout code uses: actions/checkout@v5 - with: - ref: ${{ github.event.pull_request.head.sha }} + + - name: Install Atlas CLI + run: | + curl https://fastdl.mongodb.org/mongocli/mongodb-atlas-cli_1.47.0_linux_x86_64.deb --output atlas-cli.deb + sudo apt install ./atlas-cli.deb + + - name: Set up a local deployment using Atlas CLI + run: | + atlas deployments setup myLocalRs1 --type local --port 27017 --force + + - name: Install MongoDB Database Tools to load sample data + run: | + curl https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.13.0.deb --output mdb-db-tools.deb + sudo apt install ./mdb-db-tools.deb + + - name: Download sample data + run: curl https://atlas-education.s3.amazonaws.com/sampledata.archive -o sampledata.archive + + - name: Add sample data to database + run: mongorestore --archive=sampledata.archive --port=27017 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.13' cache: 'pip' + cache-dependency-path: mflix/server/python-fastapi/requirements.txt - name: Install dependencies + working-directory: mflix/server/python-fastapi run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Run unit tests + working-directory: mflix/server/python-fastapi run: pytest -m unit --verbose --tb=short --junit-xml=test-results-unit.xml env: - MONGO_URI: ${{ secrets.MFLIX_URI }} + MONGO_URI: mongodb://localhost:27017 MONGO_DB: sample_mflix - name: Run integration tests + working-directory: mflix/server/python-fastapi run: pytest -m integration --verbose --tb=short --junit-xml=test-results-integration.xml || true env: - MONGO_URI: ${{ secrets.MFLIX_URI }} + MONGO_URI: mongodb://localhost:27017 MONGO_DB: sample_mflix - name: Upload test results @@ -65,7 +81,6 @@ jobs: - name: Generate Test Summary if: always() - working-directory: . run: | chmod +x .github/scripts/generate-test-summary-pytest.sh .github/scripts/generate-test-summary-pytest.sh \