Refactor CI workflows #776
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: Continuous Integration | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
# Lint & Format | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup environment | |
uses: ./.github/actions/setup-node-environment | |
- name: Run linter | |
run: npm run lint | |
- name: Check format | |
run: npm run format:check | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
# Test | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
test: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup environment | |
uses: ./.github/actions/setup-node-environment | |
- name: Run unit tests | |
run: npm run test | |
- name: Report coverage | |
if: success() | |
uses: davelosert/vitest-coverage-report-action@v2 | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
# Build the application | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
env: | |
DOTENV_PRIVATE_KEY_DEVELOPMENT: ${{ secrets.DOTENV_PRIVATE_KEY_DEVELOPMENT }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
token: ${{ secrets.CI_GITHUB_PAT }} | |
- name: Setup environment | |
uses: ./.github/actions/setup-node-environment | |
- name: Build application | |
run: npm run build | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: dist | |
retention-days: 2 | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
# End-to-end tests | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
e2e-tests: | |
name: End-to-end tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 90 | |
strategy: | |
fail-fast: false | |
matrix: | |
browser: [chrome, edge] | |
containers: [1, 2] | |
container: | |
image: cypress/browsers:node-20.18.0-chrome-129.0.6668.89-1-ff-131.0.2-edge-129.0.2792.65-1 | |
options: --user 1001 | |
env: | |
DOTENV_PRIVATE_KEY_DEVELOPMENT: ${{ secrets.DOTENV_PRIVATE_KEY_DEVELOPMENT }} | |
DOTENV_PRIVATE_KEY_TEST: ${{ secrets.DOTENV_PRIVATE_KEY_TEST }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
token: ${{ secrets.CI_GITHUB_PAT }} | |
- name: Execute Cypress tests | |
uses: cypress-io/github-action@v6 | |
env: | |
CYPRESS_BASE_URL: 'http://127.0.0.1:4173' | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
COMMIT_INFO_MESSAGE: '${{ github.event.pull_request.title }} (#${{ github.event.pull_request.number }})' | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
build: npm run build | |
start: npm run preview -- --host | |
tag: ${{ github.event_name }},e2e,${{ matrix.browser }} | |
wait-on: ${{ env.CYPRESS_BASE_URL }} | |
wait-on-timeout: 120 | |
record: true | |
parallel: true | |
browser: ${{ matrix.browser }} | |
ci-build-id: ${{ github.run_id }}-e2e-${{ matrix.browser }} | |
spec: | | |
cypress/e2e/participant/default-tests/**/*.cy.js | |
cypress/e2e/partner-admin/default-tests/**/*.cy.js | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
# Component Tests | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
component-tests: | |
name: Component tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 90 | |
strategy: | |
fail-fast: false | |
matrix: | |
browser: [chrome, edge] | |
container: | |
image: cypress/browsers:node-20.18.0-chrome-129.0.6668.89-1-ff-131.0.2-edge-129.0.2792.65-1 | |
options: --user 1001 | |
env: | |
DOTENV_PRIVATE_KEY_DEVELOPMENT: ${{ secrets.DOTENV_PRIVATE_KEY_DEVELOPMENT }} | |
DOTENV_PRIVATE_KEY_TEST: ${{ secrets.DOTENV_PRIVATE_KEY_TEST }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'true' | |
token: ${{ secrets.CI_GITHUB_PAT }} | |
- name: Execute Cypress tests | |
uses: cypress-io/github-action@v6 | |
env: | |
CYPRESS_BASE_URL: 'http://127.0.0.1:4173' | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
COMMIT_INFO_MESSAGE: '${{ github.event.pull_request.title }} (#${{ github.event.pull_request.number }})' | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
component: true | |
build: npm run build | |
start: npm run preview -- --host | |
tag: ${{ github.event_name }},component,${{ matrix.browser }} | |
wait-on: ${{ env.CYPRESS_BASE_URL }} | |
wait-on-timeout: 120 | |
record: true | |
parallel: true | |
browser: ${{ matrix.browser }} | |
ci-build-id: ${{ github.run_id }}-component-${{ matrix.browser }} | |
spec: | | |
cypress/component/**/*.cy.js | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
# Deploy to Preview Environment | |
# | |
# TODO: Remove the `if` condition once ready. | |
# ––––––––––––––––––––––––––––––––––––––––––––––– # | |
deploy-preview: | |
name: Deploy to Preview Environment | |
runs-on: ubuntu-latest | |
needs: [lint, test, build] | |
if: ${{ vars.CI_ENABLE_PR_ENVIRONMENT_DEPLOYMENTS == 'true' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
token: ${{ secrets.CI_GITHUB_PAT }} | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
- name: Deploy to Firebase Hosting Channel | |
id: firebase-deploy-preview | |
uses: FirebaseExtended/[email protected] | |
with: | |
repoToken: ${{ secrets.GITHUB_TOKEN }} | |
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_ADMIN_STAGING }} | |
projectId: ${{ secrets.FIREBASE_PROJECT_ID_ADMIN_STAGING }} | |
- name: Whitelist AppCheck admin environment | |
if: ${{ success() }} | |
uses: ./.github/actions/whitelist-appcheck-environment | |
with: | |
project-id: ${{ secrets.FIREBASE_PROJECT_ID_ADMIN_STAGING }} | |
service-account-key: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_ADMIN_STAGING }} | |
appcheck-site-key: ${{ secrets.FIREBASE_APPCHECK_SITE_KEY_ADMIN_STAGING }} | |
environment-url: ${{ fromJson(steps.firebase-deploy-preview.outputs.urls)[0] }} | |
- name: Whitelist AppCheck app environment | |
if: ${{ success() }} | |
uses: ./.github/actions/whitelist-appcheck-environment | |
with: | |
project-id: ${{ secrets.FIREBASE_PROJECT_ID_APP_STAGING }} | |
service-account-key: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_APP_STAGING }} | |
appcheck-site-key: ${{ secrets.FIREBASE_APPCHECK_SITE_KEY_APP_STAGING }} | |
environment-url: ${{ fromJson(steps.firebase-deploy-preview.outputs.urls)[0] }} |