|
| 1 | +name: Testplane E2E |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + testplane-e2e: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | + env: |
| 18 | + DOCKER_IMAGE_NAME: html-reporter-browsers |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Use Node.js 20 |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: 20 |
| 27 | + cache: 'npm' |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: npm ci |
| 31 | + |
| 32 | + - name: Build the package |
| 33 | + run: npm run build |
| 34 | + |
| 35 | + - name: 'Prepare e2e tests: Install pwt-chromium' |
| 36 | + run: npx playwright install chromium |
| 37 | + |
| 38 | + - name: 'Prepare e2e tests: Build-packages' |
| 39 | + run: npm run e2e:build-packages |
| 40 | + |
| 41 | + - name: 'Prepare e2e tests: Cache browser docker image' |
| 42 | + uses: actions/cache@v3 |
| 43 | + with: |
| 44 | + path: ~/.docker/cache |
| 45 | + key: docker-browser-image-${{ hashFiles('test/func/docker/Dockerfile') }} |
| 46 | + |
| 47 | + - name: 'Prepare e2e tests: Pull browser docker image' |
| 48 | + run: | |
| 49 | + mkdir -p ~/.docker/cache |
| 50 | + if [ -f ~/.docker/cache/image.tar ]; then |
| 51 | + docker load -i ~/.docker/cache/image.tar |
| 52 | + else |
| 53 | + docker pull yinfra/html-reporter-browsers |
| 54 | + docker save yinfra/html-reporter-browsers -o ~/.docker/cache/image.tar |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: 'Prepare e2e tests: Run browser docker image' |
| 58 | + run: docker run -d --name ${{ env.DOCKER_IMAGE_NAME }} -it --rm --network=host $(which colima >/dev/null || echo --add-host=host.docker.internal:0.0.0.0) yinfra/html-reporter-browsers |
| 59 | + |
| 60 | + - name: 'Prepare e2e tests: Generate fixtures' |
| 61 | + run: npm run e2e:generate-fixtures || true |
| 62 | + |
| 63 | + - name: 'Prepare e2e tests: Setup env' |
| 64 | + run: | |
| 65 | + REPORT_PREFIX=testplane-reports |
| 66 | + REPORT_DATE=$(date '+%y-%m-%d') |
| 67 | + echo "DEST_REPORTS_DIR=$REPORT_PREFIX/$REPORT_DATE/${{ github.run_id }}/${{ github.run_attempt }}" >> $GITHUB_ENV |
| 68 | +
|
| 69 | + - name: Upload fixtures reports |
| 70 | + uses: actions/upload-artifact@v4 |
| 71 | + with: |
| 72 | + name: testplane-fixtures |
| 73 | + path: test/func/fixtures/*/report |
| 74 | + |
| 75 | + - name: 'e2e: Run Testplane' |
| 76 | + id: 'testplane' |
| 77 | + continue-on-error: true |
| 78 | + working-directory: 'test/func/tests' |
| 79 | + run: npm run test |
| 80 | + |
| 81 | + - name: 'e2e: Stop browser docker image' |
| 82 | + run: | |
| 83 | + docker kill ${{ env.DOCKER_IMAGE_NAME }} || true |
| 84 | + docker rm ${{ env.DOCKER_IMAGE_NAME }} || true |
| 85 | +
|
| 86 | + - name: Merge Testplane html-reporter reports |
| 87 | + working-directory: 'test/func/tests' |
| 88 | + run: | |
| 89 | + mkdir -p ../../../${{ env.DEST_REPORTS_DIR }} |
| 90 | + npx testplane merge-reports reports/*/sqlite.db -d ../../../${{ env.DEST_REPORTS_DIR }} |
| 91 | +
|
| 92 | + - name: Deploy Testplane html-reporter reports |
| 93 | + uses: peaceiris/actions-gh-pages@v4 |
| 94 | + with: |
| 95 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + publish_dir: ${{ env.DEST_REPORTS_DIR }} |
| 97 | + destination_dir: ${{ env.DEST_REPORTS_DIR }} |
| 98 | + keep_files: true |
| 99 | + |
| 100 | + - name: Construct PR comment |
| 101 | + run: | |
| 102 | + link="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.DEST_REPORTS_DIR }}" |
| 103 | + if [ "${{ steps.testplane.outcome }}" != "success" ]; then |
| 104 | + comment="### ❌ Testplane run failed<br><br>[Report](${link})" |
| 105 | + echo "PR_COMMENT=${comment}" >> $GITHUB_ENV |
| 106 | + else |
| 107 | + comment="### ✅ Testplane run succeed<br><br>[Report](${link})" |
| 108 | + echo "PR_COMMENT=${comment}" >> $GITHUB_ENV |
| 109 | + fi |
| 110 | +
|
| 111 | + - name: Leave comment to PR with link to Testplane HTML reports |
| 112 | + uses: thollander/actions-comment-pull-request@v3 |
| 113 | + with: |
| 114 | + message: ${{ env.PR_COMMENT }} |
| 115 | + comment-tag: testplane_results |
| 116 | + |
| 117 | + - name: Fail the job if any Testplane job is failed |
| 118 | + if: ${{ steps.testplane.outcome != 'success' }} |
| 119 | + run: exit 1 |
0 commit comments