|
| 1 | +name: E2E Tests with Allure Reports |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, develop] |
| 6 | + |
| 7 | +jobs: |
| 8 | + e2e-tests: |
| 9 | + name: E2E Tests |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + node-version: [22.16.0] |
| 15 | + browser: [chromium] |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 22 | + uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node-version }} |
| 25 | + cache: 'yarn' |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + cd apps/meteor |
| 30 | + yarn install --frozen-lockfile |
| 31 | +
|
| 32 | + - name: Install Playwright browsers |
| 33 | + run: | |
| 34 | + cd apps/meteor |
| 35 | + npx playwright install --with-deps ${{ matrix.browser }} |
| 36 | +
|
| 37 | + - name: Install Allure Commandline |
| 38 | + run: | |
| 39 | + wget https://github.com/allure-framework/allure2/releases/download/2.24.1/allure-2.24.1.tgz |
| 40 | + tar -zxf allure-2.24.1.tgz |
| 41 | + sudo mv allure-2.24.1 /opt/allure |
| 42 | + sudo ln -s /opt/allure/bin/allure /usr/local/bin/allure |
| 43 | + allure --version |
| 44 | +
|
| 45 | + - name: Run E2E tests with Allure |
| 46 | + run: | |
| 47 | + cd apps/meteor |
| 48 | + yarn test:e2e |
| 49 | + env: |
| 50 | + CI: true |
| 51 | + NODE_ENV: test |
| 52 | + |
| 53 | + - name: Generate Allure report |
| 54 | + if: always() |
| 55 | + run: | |
| 56 | + cd apps/meteor |
| 57 | + mkdir -p tests/e2e/reports/allure |
| 58 | + allure generate allure-results --clean --output tests/e2e/reports/allure |
| 59 | +
|
| 60 | + - name: Upload Allure results as artifacts |
| 61 | + if: always() |
| 62 | + uses: actions/upload-artifact@v4 |
| 63 | + with: |
| 64 | + name: allure-results-${{ matrix.browser }}-${{ github.run_number }} |
| 65 | + path: apps/meteor/allure-results/ |
| 66 | + retention-days: 30 |
| 67 | + |
| 68 | + - name: Upload Allure report as artifacts |
| 69 | + if: always() |
| 70 | + uses: actions/upload-artifact@v4 |
| 71 | + with: |
| 72 | + name: allure-report-${{ matrix.browser }}-${{ github.run_number }} |
| 73 | + path: apps/meteor/tests/e2e/reports/allure/ |
| 74 | + retention-days: 30 |
| 75 | + |
| 76 | + - name: Upload HTML report as artifacts |
| 77 | + if: always() |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: html-report-${{ matrix.browser }}-${{ github.run_number }} |
| 81 | + path: apps/meteor/tests/e2e/reports/html/ |
| 82 | + retention-days: 30 |
| 83 | + |
| 84 | + - name: Upload JUnit report as artifacts |
| 85 | + if: always() |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: junit-report-${{ matrix.browser }}-${{ github.run_number }} |
| 89 | + path: apps/meteor/tests/e2e/reports/junit.xml |
| 90 | + retention-days: 30 |
| 91 | + |
| 92 | + - name: Publish Allure Report to GitHub Pages |
| 93 | + if: github.ref == 'refs/heads/main' && always() |
| 94 | + uses: peaceiris/actions-gh-pages@v3 |
| 95 | + with: |
| 96 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + publish_dir: ./apps/meteor/tests/e2e/reports/allure |
| 98 | + destination_dir: ./e2e-reports |
| 99 | + |
| 100 | + - name: Comment PR with Allure Report Link |
| 101 | + if: github.event_name == 'pull_request' && always() |
| 102 | + uses: actions/github-script@v7 |
| 103 | + with: |
| 104 | + script: | |
| 105 | + const { data: comments } = await github.rest.issues.listComments({ |
| 106 | + owner: context.repo.owner, |
| 107 | + repo: context.repo.repo, |
| 108 | + issue_number: context.issue.number, |
| 109 | + }); |
| 110 | +
|
| 111 | + const botComment = comments.find(comment => |
| 112 | + comment.user.type === 'Bot' && |
| 113 | + comment.body.includes('Allure Report') |
| 114 | + ); |
| 115 | +
|
| 116 | + const reportUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/e2e-reports/`; |
| 117 | + const commentBody = `## 📊 E2E Test Results |
| 118 | +
|
| 119 | + **Allure Report**: [View Report](${reportUrl}) |
| 120 | +
|
| 121 | + **Test Run**: #${{ github.run_number }} |
| 122 | + **Browser**: ${{ matrix.browser }} |
| 123 | + **Node.js**: ${{ matrix.node-version }} |
| 124 | +
|
| 125 | + 📥 **Download Reports**: |
| 126 | + - [Allure Results](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts) |
| 127 | + - [HTML Report](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts) |
| 128 | +
|
| 129 | + --- |
| 130 | + *Reports are generated automatically for this PR*`; |
| 131 | +
|
| 132 | + if (botComment) { |
| 133 | + await github.rest.issues.updateComment({ |
| 134 | + owner: context.repo.owner, |
| 135 | + repo: context.repo.repo, |
| 136 | + comment_id: botComment.id, |
| 137 | + body: commentBody, |
| 138 | + }); |
| 139 | + } else { |
| 140 | + await github.rest.issues.createComment({ |
| 141 | + owner: context.repo.owner, |
| 142 | + repo: context.repo.repo, |
| 143 | + issue_number: context.issue.number, |
| 144 | + body: commentBody, |
| 145 | + }); |
| 146 | + } |
0 commit comments