|
| 1 | +name: Local E2E tests |
| 2 | + |
| 3 | +on: [workflow_call] |
| 4 | + |
| 5 | +jobs: |
| 6 | + end-to-end-tests: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + services: |
| 9 | + postgres: |
| 10 | + image: postgres:17.2 |
| 11 | + env: |
| 12 | + POSTGRES_PASSWORD: postgres |
| 13 | + options: >- |
| 14 | + --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 15 | + ports: |
| 16 | + - 5432:5432 |
| 17 | + env: |
| 18 | + MAVIS_TEST_REPO: testing-repository |
| 19 | + DATABASE_URL: postgresql://postgres:postgres@localhost:5432 |
| 20 | + DATABASE_USER: postgres |
| 21 | + DATABASE_PASSWORD: postgres |
| 22 | + RAILS_ENV: end_to_end |
| 23 | + steps: |
| 24 | + - name: Checkout base branch |
| 25 | + uses: actions/checkout@v6 |
| 26 | + with: |
| 27 | + ref: ${{ github.base_ref }} |
| 28 | + - name: Setup Node.js on base branch |
| 29 | + uses: actions/setup-node@v6 |
| 30 | + with: |
| 31 | + node-version-file: .tool-versions |
| 32 | + cache: yarn |
| 33 | + - name: Setup Ruby on base branch |
| 34 | + uses: ruby/setup-ruby@v1 |
| 35 | + with: |
| 36 | + bundler-cache: true |
| 37 | + - name: Install JS dependencies on base branch |
| 38 | + run: yarn install --frozen-lockfile |
| 39 | + - name: Setup database |
| 40 | + run: bin/rails db:setup |
| 41 | + - name: Checkout head branch |
| 42 | + uses: actions/checkout@v6 |
| 43 | + with: |
| 44 | + ref: ${{ github.head_ref }} |
| 45 | + - name: Setup Node.js on head branch |
| 46 | + uses: actions/setup-node@v6 |
| 47 | + with: |
| 48 | + node-version-file: .tool-versions |
| 49 | + cache: yarn |
| 50 | + - name: Setup Ruby on head branch |
| 51 | + uses: ruby/setup-ruby@v1 |
| 52 | + with: |
| 53 | + bundler-cache: true |
| 54 | + - name: Install JS dependencies on head branch |
| 55 | + run: yarn install --frozen-lockfile |
| 56 | + - name: Migrate database |
| 57 | + run: bin/rails db:migrate |
| 58 | + - name: Install Redis |
| 59 | + run: | |
| 60 | + sudo apt-get update |
| 61 | + sudo apt-get install -y redis-server |
| 62 | + - name: Enable feature flags |
| 63 | + run: bin/rails feature_flags:enable_for_development |
| 64 | + - name: Import from GIAS |
| 65 | + run: bin/mavis gias import --input-file=spec/fixtures/dfe-schools.zip |
| 66 | + - name: Check if head branch or base branch exists |
| 67 | + id: check-branch |
| 68 | + run: | |
| 69 | + if git ls-remote --exit-code \ |
| 70 | + --heads https://github.com/NHSDigital/manage-vaccinations-in-schools-testing.git \ |
| 71 | + "$HEAD_REF" > /dev/null 2>&1; then |
| 72 | + echo "test_branch=$HEAD_REF" >> "$GITHUB_OUTPUT" |
| 73 | + elif git ls-remote --exit-code \ |
| 74 | + --heads https://github.com/NHSDigital/manage-vaccinations-in-schools-testing.git \ |
| 75 | + "$BASE_REF" > /dev/null 2>&1; then |
| 76 | + echo "test_branch=$BASE_REF" >> "$GITHUB_OUTPUT" |
| 77 | + else |
| 78 | + echo "test_branch=main" >> "$GITHUB_OUTPUT" |
| 79 | + fi |
| 80 | + env: |
| 81 | + HEAD_REF: ${{ github.head_ref }} |
| 82 | + BASE_REF: ${{ github.base_ref }} |
| 83 | + - name: Clone testing repository |
| 84 | + uses: actions/checkout@v6 |
| 85 | + with: |
| 86 | + repository: NHSDigital/manage-vaccinations-in-schools-testing |
| 87 | + ref: ${{ steps.check-branch.outputs.test_branch }} |
| 88 | + path: ${{ env.MAVIS_TEST_REPO }} |
| 89 | + - name: Setup testing repository environment file |
| 90 | + run: mv ${{ env.MAVIS_TEST_REPO }}/.env.generic ${{ env.MAVIS_TEST_REPO }}/.env |
| 91 | + - name: Setup uv |
| 92 | + uses: astral-sh/setup-uv@v7 |
| 93 | + - name: Setup Playwright |
| 94 | + working-directory: ${{ env.MAVIS_TEST_REPO }} |
| 95 | + run: | |
| 96 | + uv run playwright install --with-deps chromium |
| 97 | + - name: Run tests |
| 98 | + run: bin/e2e -n 2 --reruns 2 |
0 commit comments