|
| 1 | +name: Test Pull Request |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + unit: |
| 10 | + name: Unit Tests |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + |
| 14 | + - name: Setup Go |
| 15 | + uses: actions/setup-go@v5 |
| 16 | + with: |
| 17 | + go-version: stable |
| 18 | + |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Run Unit Tests |
| 25 | + run: ./scripts/unit.sh |
| 26 | + |
| 27 | + integration-matrix: |
| 28 | + name: Integration Matrix |
| 29 | + runs-on: ubuntu-latest |
| 30 | + outputs: |
| 31 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 32 | + needs: unit |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Set Matrix |
| 38 | + id: set-matrix |
| 39 | + run: | |
| 40 | + matrix="$(jq -r -c '.integration.matrix' ./config.json)" |
| 41 | + printf "Output: matrix=%s\n" "${matrix}" |
| 42 | + printf "matrix=%s\n" "${matrix}" >> "$GITHUB_OUTPUT" |
| 43 | +
|
| 44 | + integration: |
| 45 | + name: Integration Test |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: integration-matrix |
| 48 | + strategy: |
| 49 | + matrix: |
| 50 | + include: ${{ fromJSON(needs.integration-matrix.outputs.matrix) }} |
| 51 | + steps: |
| 52 | + |
| 53 | + - name: Setup Go |
| 54 | + uses: actions/setup-go@v5 |
| 55 | + with: |
| 56 | + go-version: stable |
| 57 | + |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + fetch-depth: 0 |
| 62 | + |
| 63 | + - name: Run Integration Tests |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + run: | |
| 67 | + ./scripts/integration.sh \ |
| 68 | + --platform docker \ |
| 69 | + --github-token "${GITHUB_TOKEN}" \ |
| 70 | + --cached ${{ matrix.cached }} \ |
| 71 | + --parallel ${{ matrix.parallel }} |
| 72 | +
|
| 73 | + roundup: |
| 74 | + name: Integration Tests |
| 75 | + if: ${{ always() }} |
| 76 | + runs-on: ubuntu-latest |
| 77 | + needs: integration |
| 78 | + steps: |
| 79 | + - run: | |
| 80 | + result="${{ needs.integration.result }}" |
| 81 | + if [[ "${result}" == "success" ]]; then |
| 82 | + echo "All integration tests passed" |
| 83 | + exit 0 |
| 84 | + else |
| 85 | + echo "One or more integration tests failed" |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | +
|
| 89 | + approve: |
| 90 | + name: Approve Bot PRs |
| 91 | + if: ${{ github.event.pull_request.user.login == 'cf-buildpacks-eng' || github.event.pull_request.user.login == 'dependabot[bot]' }} |
| 92 | + runs-on: ubuntu-latest |
| 93 | + needs: roundup |
| 94 | + steps: |
| 95 | + |
| 96 | + - name: Check Commit Verification |
| 97 | + id: unverified-commits |
| 98 | + uses: paketo-buildpacks/github-config/actions/pull-request/check-unverified-commits@main |
| 99 | + with: |
| 100 | + token: ${{ secrets.CF_BOT_GITHUB_TOKEN }} |
| 101 | + repo: ${{ github.repository }} |
| 102 | + number: ${{ github.event.number }} |
| 103 | + |
| 104 | + - name: Check for Human Commits |
| 105 | + id: human-commits |
| 106 | + uses: paketo-buildpacks/github-config/actions/pull-request/check-human-commits@main |
| 107 | + with: |
| 108 | + token: ${{ secrets.CF_BOT_GITHUB_TOKEN }} |
| 109 | + repo: ${{ github.repository }} |
| 110 | + number: ${{ github.event.number }} |
| 111 | + bots: 'dependabot[bot],web-flow,cf-buildpacks-eng' |
| 112 | + |
| 113 | + - name: Checkout |
| 114 | + if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false' |
| 115 | + uses: actions/checkout@v2 |
| 116 | + with: |
| 117 | + ref: ${{ github.event.pull_request.head.sha }} |
| 118 | + |
| 119 | + - name: Dispatch |
| 120 | + if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false' |
| 121 | + uses: paketo-buildpacks/github-config/actions/dispatch@main |
| 122 | + with: |
| 123 | + repos: ${{ github.repository }} |
| 124 | + token: ${{ secrets.CF_BOT_GITHUB_TOKEN }} |
| 125 | + event: approve-bot-pr |
| 126 | + payload: | |
| 127 | + { |
| 128 | + "number": "${{ github.event.pull_request.number }}", |
| 129 | + "login": "${{ github.event.pull_request.user.login }}", |
| 130 | + "tracker_story": "${{ steps.story-id.outputs.story_id }}" |
| 131 | + } |
0 commit comments