Fetch deployment baselines retained outside branch history #873
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.head.sha || github.sha }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| actions: read | |
| pull-requests: read | |
| jobs: | |
| dedupe: | |
| name: Avoid Duplicate Test Runs | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_run: ${{ steps.dedupe.outputs.should_run }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Decide whether this run owns the tests | |
| id: dedupe | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} | |
| PR_ACTION: ${{ github.event.action }} | |
| PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} | |
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| WORKFLOW_FILE: tests.yml | |
| run: bash .github/scripts/should-run-tests-workflow.sh | |
| detect-changes: | |
| name: Detect Changes | |
| needs: dedupe | |
| if: needs.dedupe.outputs.should_run == 'true' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| frontend: ${{ steps.filter.outputs.frontend }} | |
| backend: ${{ steps.filter.outputs.backend }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect changed components | |
| id: filter | |
| env: | |
| DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | |
| PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| PUSH_BEFORE_SHA: ${{ github.event.before }} | |
| run: bash .github/scripts/detect-component-changes.sh | |
| frontend: | |
| name: Frontend Tests | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.frontend == 'true' | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.12.0 | |
| cache: npm | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| run: npm ci | |
| - name: Run frontend tests | |
| run: npm run test | |
| backend: | |
| name: Backend Tests | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.backend == 'true' | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| env: | |
| MONGODB_URI: mongodb://localhost:27017/modtale-test | |
| MONGODB_DATABASE_NAME: modtale-test | |
| R2_BUCKET_NAME: modtale-test | |
| R2_ACCESS_KEY: test-access-key | |
| R2_SECRET_KEY: test-secret-key | |
| R2_ENDPOINT: https://example.com | |
| R2_PUBLIC_DOMAIN: https://cdn.example.com | |
| FRONTEND_URL: http://localhost:5173 | |
| BACKEND_URL: http://localhost:8080 | |
| WARDEN_ENABLED: "false" | |
| PRE_AUTH_SECRET: test-pre-auth-secret | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Ensure Gradle wrapper is executable | |
| run: chmod +x gradlew | |
| - name: Run backend tests | |
| run: ./gradlew test |