|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - reopened |
| 8 | + - synchronize |
| 9 | + |
| 10 | +# Cancel in-progress runs for the same PR when new commits are pushed |
| 11 | +concurrency: |
| 12 | + group: e2e-${{ github.event.pull_request.number }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + e2e: |
| 17 | + name: Run E2E Tests |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + pull-requests: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up Go |
| 28 | + uses: actions/setup-go@v5 |
| 29 | + with: |
| 30 | + go-version-file: go.mod |
| 31 | + |
| 32 | + - name: Setup proto files |
| 33 | + run: make proto-setup |
| 34 | + |
| 35 | + - name: Generate proto descriptors |
| 36 | + run: make proto-generate |
| 37 | + |
| 38 | + - name: Download WireMock |
| 39 | + run: make mock-download |
| 40 | + |
| 41 | + - name: Run E2E tests |
| 42 | + env: |
| 43 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 44 | + MODEL_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 45 | + run: make e2e-test |
| 46 | + |
| 47 | + - name: Parse test results |
| 48 | + if: always() |
| 49 | + id: parse_results |
| 50 | + run: | |
| 51 | + RESULTS_FILE="e2e-tests/mcpchecker/mcpchecker-stackrox-mcp-e2e-out.json" |
| 52 | + if [ -f "$RESULTS_FILE" ]; then |
| 53 | + cd e2e-tests/mcpchecker |
| 54 | +
|
| 55 | + # Get stats in GitHub Actions format |
| 56 | + ../../e2e-tests/bin/mcpchecker summary mcpchecker-stackrox-mcp-e2e-out.json --github-output >> $GITHUB_OUTPUT |
| 57 | +
|
| 58 | + # Get human-readable summary for PR comment |
| 59 | + SUMMARY=$(../../e2e-tests/bin/mcpchecker summary mcpchecker-stackrox-mcp-e2e-out.json) |
| 60 | + echo "summary<<EOF" >> $GITHUB_OUTPUT |
| 61 | + echo "$SUMMARY" >> $GITHUB_OUTPUT |
| 62 | + echo "EOF" >> $GITHUB_OUTPUT |
| 63 | +
|
| 64 | + # Add to GitHub Actions step summary |
| 65 | + echo "## E2E Test Results" >> $GITHUB_STEP_SUMMARY |
| 66 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 67 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 68 | + echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY |
| 69 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 70 | + else |
| 71 | + echo "total=0" >> $GITHUB_OUTPUT |
| 72 | + echo "passed=0" >> $GITHUB_OUTPUT |
| 73 | + echo "failed=0" >> $GITHUB_OUTPUT |
| 74 | + echo "summary=No results file found" >> $GITHUB_OUTPUT |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Find existing comment |
| 78 | + if: always() |
| 79 | + uses: peter-evans/find-comment@v3 |
| 80 | + id: find_comment |
| 81 | + with: |
| 82 | + issue-number: ${{ github.event.pull_request.number }} |
| 83 | + comment-author: 'github-actions[bot]' |
| 84 | + body-includes: '<!-- e2e-test-results -->' |
| 85 | + |
| 86 | + - name: Create or update comment - Success |
| 87 | + if: success() |
| 88 | + uses: peter-evans/create-or-update-comment@v4 |
| 89 | + with: |
| 90 | + comment-id: ${{ steps.find_comment.outputs.comment-id }} |
| 91 | + issue-number: ${{ github.event.pull_request.number }} |
| 92 | + edit-mode: replace |
| 93 | + body: | |
| 94 | + <!-- e2e-test-results --> |
| 95 | + ## E2E Test Results |
| 96 | +
|
| 97 | + **Commit:** ${{ github.event.pull_request.head.sha }} |
| 98 | + **Workflow Run:** [View Details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 99 | +
|
| 100 | + ``` |
| 101 | + ${{ steps.parse_results.outputs.summary }} |
| 102 | + ``` |
| 103 | +
|
| 104 | + - name: Create or update comment - Failure |
| 105 | + if: failure() |
| 106 | + uses: peter-evans/create-or-update-comment@v4 |
| 107 | + with: |
| 108 | + comment-id: ${{ steps.find_comment.outputs.comment-id }} |
| 109 | + issue-number: ${{ github.event.pull_request.number }} |
| 110 | + edit-mode: replace |
| 111 | + body: | |
| 112 | + <!-- e2e-test-results --> |
| 113 | + ## E2E Test Results - ❌ Job Failed |
| 114 | +
|
| 115 | + **Commit:** ${{ github.event.pull_request.head.sha }} |
| 116 | + **Workflow Run:** [View Details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
0 commit comments