docs: journey-first documentation refactor #435
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
| # Tests & Lint - runs go test -race + coverage and golangci-lint. | |
| # | |
| # Triggers: | |
| # push: branches main standalone run on every push to trunk - this is what | |
| # populates the ?branch=main status badge. | |
| # pull_request gate every PR before merge. | |
| # workflow_call invoked by orchestrate.yaml (keep - do not remove). | |
| # workflow_dispatch manual standalone run against any ref. | |
| # | |
| # The push/pull_request triggers give this workflow runs of its own so its | |
| # status badge renders; a workflow_call-only workflow has no standalone runs | |
| # to badge. | |
| name: Tests & Lint | |
| on: | |
| workflow_call: | |
| inputs: | |
| dry_run: | |
| description: 'Dry run mode' | |
| type: boolean | |
| required: false | |
| default: false | |
| outputs: | |
| result: | |
| description: 'Validation result (success/failure)' | |
| value: ${{ jobs.validate.outputs.result }} | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run tests | |
| run: go test -v -race -coverprofile=coverage.out ./... | |
| - name: Check coverage | |
| run: | | |
| go tool cover -func=coverage.out | |
| COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%') | |
| echo "Total coverage: ${COVERAGE}%" | |
| - name: Check coverage threshold | |
| run: | | |
| COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%') | |
| echo "Total coverage: ${COVERAGE}%" | |
| awk -v cov="$COVERAGE" 'BEGIN { | |
| if (cov + 0 < 80) { | |
| printf "Coverage %s%% is below the 80%% threshold\n", cov | |
| exit 1 | |
| } | |
| printf "Coverage %s%% meets the 80%% threshold\n", cov | |
| }' | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run golangci-lint | |
| uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 | |
| with: | |
| version: v2.10.1 | |
| vuln: | |
| name: Vulnerability Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Run govulncheck | |
| run: go run golang.org/x/vuln/cmd/govulncheck@0782b76014f15f24e22a438f30f308df42899ba1 ./... # v1.3.0 | |
| - name: Run govulncheck (e2e module) | |
| working-directory: e2e | |
| run: go run golang.org/x/vuln/cmd/govulncheck@0782b76014f15f24e22a438f30f308df42899ba1 ./... # v1.3.0 | |
| validate: | |
| name: Validation Gate | |
| needs: [test, lint, vuln] | |
| runs-on: ubuntu-latest | |
| outputs: | |
| result: ${{ steps.result.outputs.result }} | |
| steps: | |
| - name: Check results | |
| id: result | |
| run: | | |
| echo "result=success" >> "$GITHUB_OUTPUT" | |
| echo "Validation passed" |