diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ff025fba..9f7cdec8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -53,6 +53,28 @@ jobs: - name: Check formatting run: npx prettier src --check + test: + name: Test + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Check out Git repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 25 + + - name: Install Node.js dependencies + run: npm ci + + - name: Run tests + run: npm test + build: name: Build runs-on: ubuntu-latest diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fa4fb237..d0e034cd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,33 +1,28 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages -# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages - name: Deploy on: - push: - branches: - - main + workflow_run: + workflows: ["Checks"] + types: [completed] + branches: [main] jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 25 - - run: npm ci - - run: npm test - deploy_server: - needs: validate + name: Deploy server runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' permissions: contents: read steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + + - uses: actions/setup-node@v4 + with: + node-version: 25 - run: npm ci - run: npm run build-server @@ -47,14 +42,21 @@ jobs: pm2 start migrate deploy_client: - needs: validate + name: Deploy client runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' permissions: contents: read steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + + - uses: actions/setup-node@v4 + with: + node-version: 25 - run: npm ci - run: npm run build diff --git a/.github/workflows/test.yml b/.github/workflows/e2e.yml similarity index 63% rename from .github/workflows/test.yml rename to .github/workflows/e2e.yml index 33a1bf2c..131ec61a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/e2e.yml @@ -1,18 +1,12 @@ -name: Test +name: E2E Tests on: - push: - branches: - - main - pull_request: - branches: - - main + workflow_dispatch: jobs: - run-tests: - name: Run tests + run-e2e: + name: Run E2E tests runs-on: ubuntu-latest - # container: node:20-bookworm-slim permissions: contents: read @@ -31,7 +25,6 @@ jobs: --health-timeout 5s --health-retries 5 ports: - # Maps tcp port 5432 on service container to the host - 5432:5432 steps: @@ -42,39 +35,31 @@ jobs: - run: sudo apt-get install unzip - name: Set up Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: 25 - # ESLint and Prettier must be in `package.json` - name: Install Node.js dependencies run: npm ci - - name: Running tests - run: npm test - - name: Set up Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: "21" distribution: "temurin" - # - uses: browser-actions/setup-chrome@v1 - # with: - # install-chromedriver: true - # install-dependencies: true - # chrome-version: 139 + - name: Build + run: npm run build - - run: npm run build - - run: npm run migrate-testdb-direct + - name: Run migrations + run: npm run migrate-testdb-direct env: POSTGRES_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres" NODE_ENV: "test" - - name: Run e2e tests + - name: Run E2E tests run: ./src/scripts/deflake.sh "npm run e2e-test" env: - # User, port, and db seem to be hardcoded POSTGRES_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres" NODE_ENV: "test" PORT: 3001