Skip to content

Commit

Permalink
chore: move out e2e to workflow call
Browse files Browse the repository at this point in the history
  • Loading branch information
mishraomp committed Dec 29, 2024
1 parent b5a6c4c commit bc7859a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 47 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/.e2e.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 4 additions & 46 deletions .github/workflows/.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
uses: ./.github/workflows/.e2e.yml
with:
FRONTEND_URL: http://localhost:3000
tag: ${{ inputs.tag }}
7 changes: 6 additions & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit bc7859a

Please sign in to comment.