|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: [workflow_call] |
| 4 | + |
| 5 | +jobs: |
| 6 | + lint-test: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + - uses: actions/setup-node@v4 |
| 12 | + with: |
| 13 | + node-version: '20' |
| 14 | + cache: 'npm' |
| 15 | + - uses: docker/setup-buildx-action@v3 |
| 16 | + |
| 17 | + - name: Build image |
| 18 | + uses: docker/build-push-action@v5 |
| 19 | + with: |
| 20 | + context: . |
| 21 | + file: ./Containerfile |
| 22 | + build-args: | |
| 23 | + CI=true |
| 24 | + STAGING=true |
| 25 | + # BASE_PATH=/ |
| 26 | + push: false |
| 27 | + load: true |
| 28 | + tags: gptwrapper:ci |
| 29 | + cache-from: type=gha |
| 30 | + cache-to: type=gha,mode=max |
| 31 | + |
| 32 | + - name: Start the application |
| 33 | + run: docker compose -f compose.ci.yaml up -d |
| 34 | + |
| 35 | + # Copy dependencies from the container |
| 36 | + - name: Copy dependencies from the container |
| 37 | + run: docker cp gptwrapper:/opt/app-root/src/node_modules ./node_modules |
| 38 | + |
| 39 | + - run: npm run translations -- --lang fi,en |
| 40 | + - run: npm run lint |
| 41 | + - run: npm run tsc |
| 42 | + |
| 43 | + # https://playwrightsolutions.com/playwright-github-action-to-cache-the-browser-binaries/ |
| 44 | + - name: Get installed Playwright version |
| 45 | + id: playwright-version |
| 46 | + run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages[''].devDependencies['@playwright/test'])")" >> $GITHUB_ENV |
| 47 | + |
| 48 | + - name: Cache playwright binaries |
| 49 | + uses: actions/cache@v4 |
| 50 | + id: playwright-cache |
| 51 | + with: |
| 52 | + path: | |
| 53 | + ~/.cache/ms-playwright |
| 54 | + key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} |
| 55 | + |
| 56 | + - run: npx playwright install --with-deps chromium |
| 57 | + if: steps.playwright-cache.outputs.cache-hit != 'true' |
| 58 | + - run: npx playwright install-deps |
| 59 | + if: steps.playwright-cache.outputs.cache-hit != 'true' |
| 60 | + |
| 61 | + - name: Run tests |
| 62 | + env: |
| 63 | + CI: true |
| 64 | + run: npm run test:e2e |
| 65 | + |
| 66 | + - name: Upload Playwright Report |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + if: failure() |
| 69 | + with: |
| 70 | + name: playwright-report |
| 71 | + path: playwright-report/ |
| 72 | + retention-days: 7 |
| 73 | + |
| 74 | + - name: Print logs on failure |
| 75 | + shell: bash |
| 76 | + if: failure() |
| 77 | + run: docker compose -f compose.ci.yaml logs |
0 commit comments