chore(deps-dev): bump @commitlint/cli from 19.8.1 to 21.0.2 #273
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Terrain PR Analysis | |
| on: | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: terrain-pr-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| checks: write | |
| jobs: | |
| analyze: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Build Terrain | |
| run: go build -o terrain ./cmd/terrain | |
| - name: Run Terrain PR analysis (JSON) | |
| id: terrain-json | |
| run: | | |
| ./terrain pr --base "${{ github.event.pull_request.base.sha }}" --json > /tmp/terrain-pr.json | |
| - name: Extract selected tests | |
| id: tests | |
| run: | | |
| # Extract Go test packages (internal/foo/bar_test.go → ./internal/foo/...) | |
| GO_PKGS=$(jq -r '.testSelections[]?.path // empty' /tmp/terrain-pr.json \ | |
| | grep '_test\.go$' \ | |
| | sed 's|/[^/]*_test\.go$||' \ | |
| | sort -u \ | |
| | sed 's|^|./|' \ | |
| | tr '\n' ' ') | |
| echo "go_packages=$GO_PKGS" >> "$GITHUB_OUTPUT" | |
| # Count totals | |
| TOTAL=$(jq '.testSelections | length' /tmp/terrain-pr.json) | |
| echo "total_selected=$TOTAL" >> "$GITHUB_OUTPUT" | |
| # Posture band | |
| POSTURE=$(jq -r '.postureBand' /tmp/terrain-pr.json) | |
| echo "posture=$POSTURE" >> "$GITHUB_OUTPUT" | |
| - name: Run selected Go tests | |
| id: go-tests | |
| if: steps.tests.outputs.go_packages != '' | |
| continue-on-error: true | |
| run: | | |
| echo "::group::Terrain-selected Go tests" | |
| echo "Running: go test ${{ steps.tests.outputs.go_packages }} -count=1 -race" | |
| go test ${{ steps.tests.outputs.go_packages }} -count=1 -race -v 2>&1 | tee /tmp/go-test-output.txt | |
| echo "::endgroup::" | |
| - name: Generate PR comment | |
| id: terrain-comment | |
| run: | | |
| { | |
| echo 'body<<TERRAIN_EOF' | |
| ./terrain pr --base "${{ github.event.pull_request.base.sha }}" --format markdown | |
| echo '' | |
| echo '### Targeted Test Results' | |
| echo '' | |
| TOTAL="${{ steps.tests.outputs.total_selected }}" | |
| if [ "$TOTAL" = "0" ] || [ -z "$TOTAL" ]; then | |
| echo 'No tests selected — change affects only non-code files.' | |
| else | |
| echo "Terrain selected **${TOTAL} test(s)** instead of the full suite." | |
| echo '' | |
| # Go results | |
| if [ -n "${{ steps.tests.outputs.go_packages }}" ]; then | |
| if [ "${{ steps.go-tests.outcome }}" = "success" ]; then | |
| echo '- Go tests: **passed**' | |
| else | |
| echo '- Go tests: **failed** (see logs)' | |
| fi | |
| fi | |
| fi | |
| echo 'TERRAIN_EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Find existing Terrain comment | |
| uses: peter-evans/find-comment@v4 | |
| id: find-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: '<!-- terrain-pr-analysis -->' | |
| - name: Post or update PR comment | |
| uses: peter-evans/create-or-update-comment@v5 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| edit-mode: replace | |
| body: | | |
| <!-- terrain-pr-analysis --> | |
| ${{ steps.terrain-comment.outputs.body }} | |
| # ---------------------------------------------------------------- | |
| # Two GitHub check runs: terrain (gate) + terrain (observability) | |
| # ---------------------------------------------------------------- | |
| # Terrain emits a JSON bundle; this workflow POSTs each half through | |
| # `gh api`. The binary never makes outbound HTTP — auth + transport | |
| # live in the workflow, never in terrain itself. See | |
| # `docs/integrations/github-checks.md` for the full deploy story. | |
| - name: Build Terrain check-runs bundle | |
| id: check-runs-bundle | |
| run: | | |
| ./terrain report check-runs \ | |
| --head-sha "${{ github.event.pull_request.head.sha }}" \ | |
| --out /tmp/terrain-checks.json | |
| # Split into two files so each `gh api --input` call gets a | |
| # standalone CheckRun document. `jq` here is just a splitter — | |
| # the bundle's shape is documented in internal/checkruns. | |
| jq '.gate_check' /tmp/terrain-checks.json > /tmp/check-gate.json | |
| jq '.observability_check' /tmp/terrain-checks.json > /tmp/check-observability.json | |
| - name: Post terrain (gate) check run | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api \ | |
| --method POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "/repos/${{ github.repository }}/check-runs" \ | |
| --input /tmp/check-gate.json | |
| - name: Post terrain (observability) check run | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api \ | |
| --method POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "/repos/${{ github.repository }}/check-runs" \ | |
| --input /tmp/check-observability.json | |
| - name: Fail if selected tests failed | |
| if: steps.go-tests.outcome == 'failure' | |
| run: | | |
| echo "::error::Terrain-selected tests failed. See above for details." | |
| exit 1 |