CI #97
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: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| types: [opened, synchronize, reopened, labeled, unlabeled] | |
| schedule: | |
| # Nightly integration run at 02:00 UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| # Use repo vars/secrets when available; fallback to public project settings. | |
| NEXT_PUBLIC_SANITY_PROJECT_ID: ${{ vars.NEXT_PUBLIC_SANITY_PROJECT_ID || vars.SANITY_PROJECT_ID || secrets.SANITY_PROJECT_ID || '6r5yojda' }} | |
| NEXT_PUBLIC_SANITY_DATASET: ${{ vars.NEXT_PUBLIC_SANITY_DATASET || vars.SANITY_DATASET || secrets.SANITY_DATASET || 'production' }} | |
| NEXT_PUBLIC_SANITY_API_VERSION: ${{ vars.NEXT_PUBLIC_SANITY_API_VERSION || '2023-12-19' }} | |
| SANITY_API_VIEWER_TOKEN: ${{ secrets.SANITY_API_VIEWER_TOKEN || secrets.SANITY_API_EDITOR_TOKEN || secrets.SANITY_API_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Run type checking | |
| run: npm run type-check | |
| - name: Run unit tests (fast) | |
| run: npm run test:fast | |
| - name: Build application | |
| run: npm run build | |
| # Integration tests run on main, manual trigger, nightly schedule, | |
| # or PRs explicitly labeled "run-integration" (non-fork PRs only). | |
| integration-test: | |
| runs-on: ubuntu-latest | |
| if: >- | |
| ${{ | |
| github.event_name == 'workflow_dispatch' || | |
| github.event_name == 'schedule' || | |
| github.ref == 'refs/heads/main' || | |
| ( | |
| github.event_name == 'pull_request' && | |
| github.event.pull_request.head.repo.fork == false && | |
| contains(github.event.pull_request.labels.*.name, 'run-integration') | |
| ) | |
| }} | |
| env: | |
| # Use repo vars/secrets when available; fallback to public project settings. | |
| NEXT_PUBLIC_SANITY_PROJECT_ID: ${{ vars.NEXT_PUBLIC_SANITY_PROJECT_ID || vars.SANITY_PROJECT_ID || secrets.SANITY_PROJECT_ID || '6r5yojda' }} | |
| NEXT_PUBLIC_SANITY_DATASET: ${{ vars.NEXT_PUBLIC_SANITY_DATASET || vars.SANITY_DATASET || secrets.SANITY_DATASET || 'production' }} | |
| NEXT_PUBLIC_SANITY_API_VERSION: ${{ vars.NEXT_PUBLIC_SANITY_API_VERSION || '2023-12-19' }} | |
| SANITY_API_VIEWER_TOKEN: ${{ secrets.SANITY_API_VIEWER_TOKEN || secrets.SANITY_API_EDITOR_TOKEN || secrets.SANITY_API_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run integration tests | |
| run: npm run test:full-integration |