|
| 1 | +name: Integration Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, main] |
| 6 | + pull_request: |
| 7 | + branches: [master, main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + test-action: |
| 16 | + name: Test Action End-to-End |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Make test changes |
| 24 | + run: | |
| 25 | + echo "Integration test run at $(date -u)" > integration-test-output.txt |
| 26 | +
|
| 27 | + - name: Run create-pull-request action |
| 28 | + id: cpr |
| 29 | + uses: ./ |
| 30 | + with: |
| 31 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + commit-message: "test: integration test commit" |
| 33 | + branch: integration-test/verify-action |
| 34 | + title: "test: Verify create-pull-request action works" |
| 35 | + body: | |
| 36 | + Automated integration test PR. |
| 37 | + This PR was created by the integration test workflow to verify the action works correctly. |
| 38 | + **This PR can be closed without merging.** |
| 39 | + labels: test, automated |
| 40 | + delete-branch: true |
| 41 | + |
| 42 | + - name: Verify outputs |
| 43 | + run: | |
| 44 | + echo "Pull Request Number: ${{ steps.cpr.outputs.pull-request-number }}" |
| 45 | + echo "Pull Request URL: ${{ steps.cpr.outputs.pull-request-url }}" |
| 46 | + echo "Operation: ${{ steps.cpr.outputs.pull-request-operation }}" |
| 47 | + echo "Head SHA: ${{ steps.cpr.outputs.pull-request-head-sha }}" |
| 48 | + echo "Branch: ${{ steps.cpr.outputs.pull-request-branch }}" |
| 49 | +
|
| 50 | + # Verify critical outputs are non-empty |
| 51 | + if [ -z "${{ steps.cpr.outputs.pull-request-number }}" ]; then |
| 52 | + echo "FAIL: pull-request-number is empty" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | +
|
| 56 | + if [ -z "${{ steps.cpr.outputs.pull-request-url }}" ]; then |
| 57 | + echo "FAIL: pull-request-url is empty" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + OPERATION="${{ steps.cpr.outputs.pull-request-operation }}" |
| 62 | + if [ "$OPERATION" != "created" ] && [ "$OPERATION" != "updated" ]; then |
| 63 | + echo "FAIL: unexpected operation '$OPERATION' (expected 'created' or 'updated')" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | +
|
| 67 | + echo "All output validations passed!" |
| 68 | +
|
| 69 | + - name: Close test PR |
| 70 | + if: steps.cpr.outputs.pull-request-number |
| 71 | + run: | |
| 72 | + gh pr close ${{ steps.cpr.outputs.pull-request-number }} --delete-branch || true |
| 73 | + env: |
| 74 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + test-no-changes: |
| 77 | + name: Test No Changes Scenario |
| 78 | + runs-on: ubuntu-latest |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout code |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Run action without changes |
| 85 | + id: cpr |
| 86 | + uses: ./ |
| 87 | + with: |
| 88 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + branch: integration-test/no-changes |
| 90 | + |
| 91 | + - name: Verify no PR was created |
| 92 | + run: | |
| 93 | + if [ -n "${{ steps.cpr.outputs.pull-request-number }}" ]; then |
| 94 | + echo "FAIL: PR was created when no changes exist" |
| 95 | + exit 1 |
| 96 | + fi |
| 97 | + echo "Correctly handled no-changes scenario" |
| 98 | +
|
| 99 | + test-docker-build: |
| 100 | + name: Test Docker Image Runs |
| 101 | + runs-on: ubuntu-latest |
| 102 | + |
| 103 | + steps: |
| 104 | + - name: Checkout code |
| 105 | + uses: actions/checkout@v4 |
| 106 | + |
| 107 | + - name: Build Docker image |
| 108 | + run: docker build -t cpr-test . |
| 109 | + |
| 110 | + - name: Verify Python module resolves |
| 111 | + run: | |
| 112 | + docker run --rm --entrypoint python cpr-test -c "from create_pull_request.main import run; print('Module import OK')" |
0 commit comments