diff --git a/.github/workflows/.e2e.yml b/.github/workflows/.e2e.yml new file mode 100644 index 00000000..e1364c27 --- /dev/null +++ b/.github/workflows/.e2e.yml @@ -0,0 +1,63 @@ +name: .E2E +on: + workflow_call: + inputs: + FRONTEND_URL: + description: 'The URL of the frontend to test' + required: true + type: string + tag: + description: 'The tag of the containers to test' + default: 'latest' + type: string + required: false +jobs: + e2e-tests: + name: E2E Tests + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run Docker compose + if: ${{ inputs.FRONTEND_URL == 'http://localhost:3000' }} + env: + BACKEND_IMAGE: ghcr.io/${{ github.repository }}/backend:${{ inputs.tag }} + FLYWAY_IMAGE: ghcr.io/${{ github.repository }}/migrations:${{ inputs.tag }} + FRONTEND_IMAGE: ghcr.io/${{ github.repository }}/frontend:${{ inputs.tag }} + run: docker compose up -d --wait + continue-on-error: true + - name: Docker Compose Logs + if: ${{ runner.debug == '1' && inputs.FRONTEND_URL == 'http://localhost:3000' }} + run: docker compose logs + - name: Cache Playwright Browsers + uses: actions/cache@v4 + id: playwright-cache + with: + path: | + ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} + - uses: actions/setup-node@v4 + name: Setup Node + with: + node-version: 22 + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + - name: Fix permissions + run: sudo chown -R $USER:$USER frontend + - name: Install dependencies + working-directory: frontend + run: | + npm ci + - run: npx @playwright/test install --with-deps + if: steps.playwright-cache.outputs.cache-hit != 'true' + working-directory: ./frontend + - run: npx @playwright/test install-deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + working-directory: ./frontend + - name: Run Tests + working-directory: frontend + env: + E2E_BASE_URL: http://localhost:3000 + CI: 'true' + run: | + npx playwright test --project="chromium" --reporter=blob \ No newline at end of file diff --git a/.github/workflows/.tests.yml b/.github/workflows/.tests.yml index f242df08..4cab9397 100644 --- a/.github/workflows/.tests.yml +++ b/.github/workflows/.tests.yml @@ -76,49 +76,7 @@ jobs: sarif_file: "trivy-results.sarif" e2e: name: E2E Tests - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Run Docker compose - env: - BACKEND_IMAGE: ghcr.io/${{ github.repository }}/backend:${{ inputs.tag }} - FLYWAY_IMAGE: ghcr.io/${{ github.repository }}/migrations:${{ inputs.tag }} - FRONTEND_IMAGE: ghcr.io/${{ github.repository }}/frontend:${{ inputs.tag }} - run: docker compose up -d --wait - continue-on-error: true - - name: Docker Compose Logs - if: ${{ runner.debug == '1' }} - run: docker compose logs - - name: Cache Playwright Browsers - uses: actions/cache@v4 - id: playwright-cache - with: - path: | - ~/.cache/ms-playwright - key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} - - uses: actions/setup-node@v4 - name: Setup Node - with: - node-version: 22 - cache: 'npm' - cache-dependency-path: frontend/package-lock.json - - name: Fix permissions - run: sudo chown -R $USER:$USER frontend - - name: Install dependencies - working-directory: frontend - run: | - npm ci - - run: npx @playwright/test install --with-deps - if: steps.playwright-cache.outputs.cache-hit != 'true' - working-directory: ./frontend - - run: npx @playwright/test install-deps - if: steps.playwright-cache.outputs.cache-hit == 'true' - working-directory: ./frontend - - name: Run Tests - working-directory: frontend - env: - E2E_BASE_URL: http://localhost:3000 - CI: 'true' - run: | - npx playwright test --project="chromium" --reporter=blob \ No newline at end of file + uses: ./.github/workflows/.e2e.yml + with: + FRONTEND_URL: http://localhost:3000 + tag: ${{ inputs.tag }} \ No newline at end of file diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 0f64daac..40aa7c0f 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -39,7 +39,12 @@ jobs: tag: ${{ needs.vars.outputs.pr }} app_env: dev secrets: inherit - + e2e: + name: E2E Tests + needs: [deploy_stack_dev] + uses: ./.github/workflows/.e2e.yml + with: + frontend_url: https://${{ needs.deploy_stack_dev.outputs.CF_DOMAIN }} deploy_stack_test: name: Deploy Stack Test needs: [vars]