Merge pull request #708 from webstackdev/bugfix/remove-require-calls-… #591
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
| # Runs unit tests to gate deployments | |
| name: Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: {} | |
| jobs: | |
| unit-test: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| environment: testing | |
| if: ${{ !startsWith(github.head_ref || github.ref_name, 'hotfix/') }} | |
| permissions: | |
| actions: write | |
| checks: write | |
| contents: read | |
| pull-requests: write | |
| env: | |
| ASTRO_DB_APP_TOKEN: ${{ secrets.ASTRO_DB_APP_TOKEN }} | |
| ASTRO_DB_REMOTE_URL: ${{ secrets.ASTRO_DB_REMOTE_URL }} | |
| COMPOSE_PROJECT_NAME: ${{ vars.COMPOSE_PROJECT_NAME }} | |
| CRON_SECRET: ${{ vars.CRON_SECRET }} | |
| DEV_SERVER_HOST: 127.0.0.1 | |
| DEV_SERVER_PORT: ${{ vars.DEV_SERVER_PORT }} | |
| DISABLE_TELEMETRY: true | |
| FORCE_COLOR: 3 | |
| PUBLIC_GOOGLE_MAPS_API_KEY: ${{ vars.PUBLIC_GOOGLE_MAPS_API_KEY }} | |
| PUBLIC_GOOGLE_MAP_ID: ${{ vars.PUBLIC_GOOGLE_MAP_ID }} | |
| PUBLIC_UPSTASH_SEARCH_READONLY_TOKEN: ${{ vars.PUBLIC_UPSTASH_SEARCH_READONLY_TOKEN }} | |
| PUBLIC_UPSTASH_SEARCH_REST_URL: ${{ vars.PUBLIC_UPSTASH_SEARCH_REST_URL }} | |
| RESEND_API_KEY: ${{ vars.RESEND_API_KEY }} | |
| RESEND_HTTP_PORT: ${{ vars.RESEND_HTTP_PORT }} | |
| SENTRY_AUTH_TOKEN: ${{ vars.SENTRY_AUTH_TOKEN }} | |
| PUBLIC_SENTRY_DSN: ${{ vars.PUBLIC_SENTRY_DSN }} | |
| WEBMENTION_IO_TOKEN: ${{ vars.WEBMENTION_IO_TOKEN }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: ">=24.16.0 <25" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| # Astro build runs sync, check, and integrations including verify links | |
| - name: Verify green build (local DB snapshot) | |
| run: npm run build:ci | |
| - name: Run unit tests (Vitest — coverage with GitHub Actions reporter) | |
| id: vitest | |
| run: npm run test:coverage | |
| - name: Report Coverage | |
| if: steps.vitest.outcome == 'success' && | |
| hashFiles('coverage/coverage-summary.json') != '' | |
| uses: davelosert/vitest-coverage-report-action@8b157684c6a6b259b97d45e72b44242865c0f6a5 # v2.12.2 | |
| with: | |
| json-summary-path: "./coverage/coverage-summary.json" | |
| json-final-path: "./coverage/coverage-final.json" | |
| - name: Upload test coverage | |
| if: always() && hashFiles('coverage/coverage-summary.json') != '' | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: test-coverage | |
| path: coverage/ | |
| retention-days: 30 | |
| hotfix-bypass: | |
| name: Hotfix Bypass | |
| runs-on: ubuntu-latest | |
| if: ${{ startsWith(github.head_ref || github.ref_name, 'hotfix/') }} | |
| permissions: {} | |
| steps: | |
| - name: Skip testing for hotfix branch | |
| run: | |
| echo "hotfix/* branch detected; skipping lint, unit, and e2e workflows but | |
| allowing deployments." |