fix tests #342
This file contains 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/CD | |
on: | |
push: | |
branches: | |
- 'master' | |
paths-ignore: | |
- 'docs/**' | |
pull_request: | |
branches: | |
- 'master' | |
paths-ignore: | |
- 'docs/**' | |
workflow_dispatch: | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Node & NPM | |
uses: ./.github/actions/setup | |
- name: Lint | |
run: npx biome ci . | |
ts: | |
name: TS | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Node & NPM | |
uses: ./.github/actions/setup | |
- name: TS | |
run: npm run tsc | |
are-translations-sorted: | |
name: Are Translations Sorted | |
runs-on: ubuntu-latest | |
needs: | |
- ts | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Node & NPM | |
uses: ./.github/actions/setup | |
- name: Are Translations Sorted | |
run: npx tsx scripts/are-translations-sorted.ts | |
or-docs-or-non-docs: | |
name: Or Docs Or Non-Docs | |
runs-on: ubuntu-latest | |
needs: | |
- ts | |
# TODO should it be run on push to master as well? | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node & NPM | |
uses: ./.github/actions/setup | |
- name: Or Docs Or Non-Docs | |
run: npx tsx scripts/or-docs-or-non-docs.ts --target origin/${{ github.event.pull_request.base.ref }} | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: | |
- ts | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Node & NPM | |
uses: ./.github/actions/setup | |
- name: Run Unit Tests | |
run: npx vitest run --coverage | |
- name: Upload Unit Test Coverage Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-report | |
path: coverage/ | |
retention-days: 30 | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: | |
- ts | |
outputs: | |
bundle-cache-hit: ${{ steps.cache-bundle.outputs.cache-hit }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Node & NPM | |
id: setup | |
uses: ./.github/actions/setup | |
- name: Build App Bundle | |
run: npm run build | |
- name: Cache App Bundle | |
id: cache-bundle | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: ${{ runner.os }}-${{steps.setup.outputs.node-version}}-bundle-${{hashFiles('dist/**')}} | |
- name: Upload App Bundle | |
if: steps.cache-bundle.outputs.cache-hit != 'true' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bundle | |
path: dist/ | |
retention-days: 30 | |
e2e: | |
name: E2E (${{ matrix.shard }}/${{ strategy.job-total }}) | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
- build | |
strategy: | |
matrix: | |
shard: [1, 2, 3, 4] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Node & NPM | |
id: setup | |
uses: ./.github/actions/setup | |
- name: Run E2E Tests | |
uses: ./.github/actions/e2e | |
with: | |
env: 'development' | |
shard: ${{ matrix.shard }} | |
total_shards: ${{ strategy.job-total }} | |
deploy: | |
environment: | |
name: production | |
url: https://subs-savvy.pages.dev | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- ts | |
- are-translations-sorted | |
- e2e | |
if: | | |
github.event_name == 'push' && | |
github.ref == 'refs/heads/master' && | |
needs.build.outputs.bundle-cache-hit != 'true' | |
concurrency: | |
group: deploy | |
cancel-in-progress: false | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Node & NPM | |
id: setup | |
uses: ./.github/actions/setup | |
- name: Download App Bundle | |
uses: actions/download-artifact@v4 | |
with: | |
name: bundle | |
path: dist/ | |
- name: Deploy Bundle | |
run: npx wrangler pages deploy | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} |