|
| 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 | + SOURCE_REPORTS_DIR: test/func/tests/reports |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + |
| 24 | + - name: Use Node.js 20 |
| 25 | + uses: actions/setup-node@v2 |
| 26 | + with: |
| 27 | + node-version: 20 |
| 28 | + cache: 'npm' |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: npm ci |
| 32 | + |
| 33 | + - name: Build the package |
| 34 | + run: npm run build |
| 35 | + |
| 36 | + - name: 'Prepare e2e tests: Install pwt-chromium' |
| 37 | + run: npx playwright install chromium |
| 38 | + |
| 39 | + - name: 'Prepare e2e tests: Build-packages' |
| 40 | + run: npm run e2e:build-packages |
| 41 | + |
| 42 | + - name: 'Prepare e2e tests: Cache browser docker image' |
| 43 | + uses: actions/cache@v3 |
| 44 | + with: |
| 45 | + path: ~/.docker/cache |
| 46 | + key: docker-browser-image-${{ hashFiles('test/func/docker/Dockerfile') }} |
| 47 | + |
| 48 | + - name: 'Prepare e2e tests: Pull browser docker image' |
| 49 | + run: | |
| 50 | + mkdir -p ~/.docker/cache |
| 51 | + if [ -f ~/.docker/cache/image.tar ]; then |
| 52 | + docker load -i ~/.docker/cache/image.tar |
| 53 | + else |
| 54 | + docker pull yinfra/html-reporter-browsers |
| 55 | + docker save yinfra/html-reporter-browsers -o ~/.docker/cache/image.tar |
| 56 | + fi |
| 57 | +
|
| 58 | + - name: 'Prepare e2e tests: Run browser docker image' |
| 59 | + 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 |
| 60 | + |
| 61 | + - name: 'Prepare e2e tests: Generate fixtures' |
| 62 | + run: npm run e2e:generate-fixtures || true |
| 63 | + |
| 64 | + - name: 'Prepare e2e tests: Setup env' |
| 65 | + run: | |
| 66 | + REPORT_PREFIX=testplane-reports |
| 67 | + REPORT_DATE=$(date '+%y-%m-%d') |
| 68 | + echo "DEST_REPORTS_DIR=$REPORT_PREFIX/$REPORT_DATE/${{ github.run_id }}/${{ github.run_attempt }}" >> $GITHUB_ENV |
| 69 | +
|
| 70 | + - name: Upload fixtures reports |
| 71 | + uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: testplane-fixtures |
| 74 | + path: test/func/fixtures/*/report |
| 75 | + |
| 76 | + - name: 'e2e: Run Testplane testplane-common' |
| 77 | + id: 'testplane-testplane-common' |
| 78 | + continue-on-error: true |
| 79 | + working-directory: 'test/func/tests' |
| 80 | + run: npm run testplane:testplane-common |
| 81 | + |
| 82 | + - name: 'e2e: Run Testplane testplane-eye' |
| 83 | + id: 'testplane-testplane-eye' |
| 84 | + continue-on-error: true |
| 85 | + working-directory: 'test/func/tests' |
| 86 | + run: npm run testplane:testplane-eye |
| 87 | + |
| 88 | + - name: 'e2e: Run Testplane testplane-gui' |
| 89 | + id: 'testplane-testplane-gui' |
| 90 | + continue-on-error: true |
| 91 | + working-directory: 'test/func/tests' |
| 92 | + run: npm run testplane:testplane-gui |
| 93 | + |
| 94 | + - name: 'e2e: Run Testplane playwright' |
| 95 | + id: 'testplane-playwright' |
| 96 | + continue-on-error: true |
| 97 | + working-directory: 'test/func/tests' |
| 98 | + run: npm run testplane:playwright |
| 99 | + |
| 100 | + - name: 'e2e: Run Testplane plugins' |
| 101 | + id: 'testplane-plugins' |
| 102 | + continue-on-error: true |
| 103 | + working-directory: 'test/func/tests' |
| 104 | + run: npm run testplane:plugins |
| 105 | + |
| 106 | + - name: 'e2e: Run Testplane testplane-tinder' |
| 107 | + id: 'testplane-testplane-tinder' |
| 108 | + continue-on-error: true |
| 109 | + working-directory: 'test/func/tests' |
| 110 | + run: npm run testplane:testplane-tinder |
| 111 | + |
| 112 | + - name: 'e2e: Run Testplane analytics' |
| 113 | + id: 'testplane-analytics' |
| 114 | + continue-on-error: true |
| 115 | + working-directory: 'test/func/tests' |
| 116 | + run: npm run testplane:analytics |
| 117 | + |
| 118 | + - name: 'e2e: Stop browser docker image' |
| 119 | + run: | |
| 120 | + docker kill ${{ env.DOCKER_IMAGE_NAME }} || true |
| 121 | + docker rm ${{ env.DOCKER_IMAGE_NAME }} || true |
| 122 | +
|
| 123 | + - name: Set IS_FAILED if any step didn't succeed |
| 124 | + if: always() |
| 125 | + run: | |
| 126 | + if [ "${{ steps.testplane-testplane-common.outcome }}" != "success" ] || \ |
| 127 | + [ "${{ steps.testplane-testplane-gui.outcome }}" != "success" ] || \ |
| 128 | + [ "${{ steps.testplane-plugins.outcome }}" != "success" ] || \ |
| 129 | + [ "${{ steps.testplane-analytics.outcome }}" != "success" ] || \ |
| 130 | + [ "${{ steps.testplane-playwright.outcome }}" != "success" ] || \ |
| 131 | + [ "${{ steps.testplane-testplane-eye.outcome }}" != "success" ] || \ |
| 132 | + [ "${{ steps.testplane-testplane-tinder.outcome }}" != "success" ]; then |
| 133 | + echo "IS_FAILED=true" >> $GITHUB_ENV |
| 134 | + fi |
| 135 | +
|
| 136 | + - name: Deploy Testplane html-reporter reports |
| 137 | + if: ${{ env.IS_FAILED }} |
| 138 | + uses: peaceiris/actions-gh-pages@v4 |
| 139 | + with: |
| 140 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 141 | + publish_dir: ${{ env.SOURCE_REPORTS_DIR }} |
| 142 | + destination_dir: ${{ env.DEST_REPORTS_DIR }} |
| 143 | + keep_files: true |
| 144 | + |
| 145 | + - name: Construct failed PR comment |
| 146 | + if: ${{ env.IS_FAILED }} |
| 147 | + run: | |
| 148 | + comment="### ❌ Testplane run failed<br><br>" |
| 149 | + link_base="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.DEST_REPORTS_DIR }}" |
| 150 | +
|
| 151 | + if [[ ${{ steps.testplane-testplane-common.outcome }} == "success" ]]; then |
| 152 | + comment+="- ✅ testplane-common: success. " |
| 153 | + else |
| 154 | + comment+="- ❌ testplane-common: failure. " |
| 155 | + fi |
| 156 | + comment+="[Report](${link_base}/testplane) <br>" |
| 157 | +
|
| 158 | + if [[ ${{ steps.testplane-testplane-gui.outcome }} == "success" ]]; then |
| 159 | + comment+="- ✅ testplane-gui: success. " |
| 160 | + else |
| 161 | + comment+="- ❌ testplane-gui: failure. " |
| 162 | + fi |
| 163 | + comment+="[Report](${link_base}/testplane-gui) <br>" |
| 164 | +
|
| 165 | + if [[ ${{ steps.testplane-plugins.outcome }} == "success" ]]; then |
| 166 | + comment+="- ✅ plugins: success. " |
| 167 | + else |
| 168 | + comment+="- ❌ plugins: failure. " |
| 169 | + fi |
| 170 | + comment+="[Report](${link_base}/plugins) <br>" |
| 171 | +
|
| 172 | + if [[ ${{ steps.testplane-analytics.outcome }} == "success" ]]; then |
| 173 | + comment+="- ✅ analytics: success. " |
| 174 | + else |
| 175 | + comment+="- ❌ analytics: failure. " |
| 176 | + fi |
| 177 | + comment+="[Report](${link_base}/analytics) <br>" |
| 178 | +
|
| 179 | + if [[ ${{ steps.testplane-playwright.outcome }} == "success" ]]; then |
| 180 | + comment+="- ✅ playwright: success. " |
| 181 | + else |
| 182 | + comment+="- ❌ playwright: failure. " |
| 183 | + fi |
| 184 | + comment+="[Report](${link_base}/playwright) <br>" |
| 185 | +
|
| 186 | + if [[ ${{ steps.testplane-testplane-eye.outcome }} == "success" ]]; then |
| 187 | + comment+="- ✅ testplane-eye: success. " |
| 188 | + else |
| 189 | + comment+="- ❌ testplane-eye: failure. " |
| 190 | + fi |
| 191 | + comment+="[Report](${link_base}/testplane-eye) <br>" |
| 192 | +
|
| 193 | + if [[ ${{ steps.testplane-testplane-tinder.outcome }} == "success" ]]; then |
| 194 | + comment+="- ✅ testplane-tinder: success. " |
| 195 | + else |
| 196 | + comment+="- ❌ testplane-tinder: failure. " |
| 197 | + fi |
| 198 | + comment+="[Report](${link_base}/testplane-tinder) <br>" |
| 199 | +
|
| 200 | + echo "FAILED_PR_COMMENT=${comment}" >> $GITHUB_ENV |
| 201 | +
|
| 202 | + - name: Leave failed comment to PR with link to Testplane HTML reports |
| 203 | + if: env.IS_FAILED |
| 204 | + id: leave-failed-comment-step |
| 205 | + uses: thollander/actions-comment-pull-request@v3 |
| 206 | + with: |
| 207 | + message: ${{ env.FAILED_PR_COMMENT }} |
| 208 | + comment-tag: testplane_results |
| 209 | + |
| 210 | + - name: Leave success comment to PR |
| 211 | + if: steps.leave-failed-comment-step.outcome == 'skipped' |
| 212 | + uses: thollander/actions-comment-pull-request@v3 |
| 213 | + with: |
| 214 | + message: '### ✅ Testplane run succeed' |
| 215 | + comment-tag: testplane_results |
| 216 | + |
| 217 | + - name: Fail the job if any Testplane job is failed |
| 218 | + if: env.IS_FAILED |
| 219 | + run: exit 1 |
0 commit comments