build(deps): bump github.com/BurntSushi/toml from 1.5.0 to 1.6.0 #396
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: CI | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| GO_VERSION: '^1.25' | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| check-latest: true | |
| cache: true | |
| - name: Get dependencies | |
| run: | | |
| go mod download | |
| go mod verify | |
| - name: Run tests with coverage (race) and always produce JSON | |
| id: unit_tests | |
| run: | | |
| set -euo pipefail | |
| export CGO_ENABLED=1 | |
| export GORACE=halt_on_error=1 | |
| # First pass: standard race run (no coverage) just to surface issues quickly; don't stop pipeline on failure yet | |
| set +e | |
| go test -race ./... -v | |
| RACE_STATUS=$? | |
| set -e | |
| # Second pass: coverage + JSON (allow failures but still emit report.json) | |
| set +e | |
| go test -coverprofile=coverage.txt -covermode=atomic -json ./... > report.json | |
| COV_STATUS=$? | |
| set -e | |
| # If coverage run failed AND coverage.txt missing or empty, attempt per-package collection as best-effort | |
| if [ "$COV_STATUS" -ne 0 ]; then | |
| if [ ! -s coverage.txt ]; then | |
| echo "Attempting fallback per-package coverage collection" >&2 | |
| rm -f coverage.txt || true | |
| echo 'mode: atomic' > coverage.txt | |
| # Iterate packages; skip ones that previously crashed (still produce partial coverage) | |
| for pkg in $(go list ./...); do | |
| echo "Collecting coverage for $pkg" >&2 | |
| go test -race -covermode=atomic -coverprofile=tmp.cov -json $pkg >> report.json 2>/dev/null || true | |
| if [ -f tmp.cov ]; then | |
| # Append without repeating mode line | |
| tail -n +2 tmp.cov >> coverage.txt || true | |
| rm -f tmp.cov | |
| fi | |
| done | |
| # If only mode line present (no real data), remove file to avoid uploading empty coverage | |
| if [ "$(wc -l < coverage.txt)" -le 1 ]; then | |
| echo "No substantive coverage collected; removing coverage.txt" >&2 | |
| rm -f coverage.txt | |
| fi | |
| fi | |
| fi | |
| echo "race_status=$RACE_STATUS" >> $GITHUB_OUTPUT | |
| echo "cov_status=$COV_STATUS" >> $GITHUB_OUTPUT | |
| continue-on-error: true | |
| - name: Fail unit tests if any step failed | |
| if: ${{ steps.unit_tests.outputs.race_status != '0' || steps.unit_tests.outputs.cov_status != '0' }} | |
| run: | | |
| echo "Race test status: ${{ steps.unit_tests.outputs.race_status }}" >&2 | |
| echo "Coverage test status: ${{ steps.unit_tests.outputs.cov_status }}" >&2 | |
| exit 1 | |
| - name: Upload coverage reports to Codecov (unit) | |
| if: ${{ hashFiles('coverage.txt') != '' }} | |
| uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.0 pinned | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| slug: GoCodeAlone/modular | |
| files: coverage.txt | |
| flags: unit | |
| - name: Upload unit coverage artifact | |
| if: ${{ hashFiles('coverage.txt') != '' }} | |
| # Make the raw Go coverage profile available for the merge job | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: unit-coverage | |
| path: coverage.txt | |
| if-no-files-found: error | |
| retention-days: 1 | |
| - name: CTRF Test Output | |
| run: | | |
| go install github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest | |
| # Guard if report.json somehow missing | |
| if [ ! -f report.json ]; then echo '{}' > report.json; fi | |
| cat report.json | go-ctrf-json-reporter -o report.ctrf.json || echo 'CTRF conversion failed' | |
| if: always() | |
| # https://github.com/ctrf-io/github-test-reporter | |
| - name: Publish CTRF Test Summary Results | |
| run: npx github-actions-ctrf report.ctrf.json | |
| if: always() | |
| test-cli: | |
| name: Test CLI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| check-latest: true | |
| cache: true | |
| - name: Get dependencies | |
| run: | | |
| cd cmd/modcli | |
| go mod download | |
| go mod verify | |
| - name: Run CLI tests with coverage | |
| run: | | |
| cd cmd/modcli | |
| go test ./... -v -coverprofile=cli-coverage.txt -covermode=atomic -json >> cli-report.json | |
| - name: Upload CLI coverage reports to Codecov | |
| uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.0 pinned | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| slug: GoCodeAlone/modular | |
| directory: cmd/modcli/ | |
| files: cli-coverage.txt | |
| flags: cli | |
| - name: Upload CLI coverage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cli-coverage | |
| path: cmd/modcli/cli-coverage.txt | |
| if-no-files-found: error | |
| retention-days: 1 | |
| - name: CTRF Test Output for CLI | |
| run: | | |
| go install github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest | |
| cd cmd/modcli | |
| cat cli-report.json | go-ctrf-json-reporter -o cli-report.ctrf.json | |
| if: always() | |
| - name: Publish CLI CTRF Test Summary Results | |
| run: | | |
| cd cmd/modcli | |
| npx github-actions-ctrf cli-report.ctrf.json | |
| if: always() | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache-dependency-path: go.sum | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v8 | |
| # See: https://github.com/marketplace/actions/golangci-lint for configuration options | |
| with: | |
| # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | |
| version: latest | |
| only-new-issues: true | |
| args: -c .golangci.yml | |
| merge-coverage: | |
| name: Merge Unit/CLI/BDD Coverage | |
| runs-on: ubuntu-latest | |
| needs: [test, test-cli] | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Download unit coverage artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: unit-coverage | |
| path: cov-artifacts | |
| continue-on-error: true | |
| - name: Download cli coverage artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: cli-coverage | |
| path: cov-artifacts | |
| continue-on-error: true | |
| - name: Download merged BDD coverage artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: merged-bdd-coverage | |
| path: cov-artifacts | |
| continue-on-error: true | |
| - name: Merge coverage profiles | |
| run: | | |
| set -e | |
| ls -R cov-artifacts || true | |
| FILES=() | |
| [ -f cov-artifacts/coverage.txt ] && FILES+=(cov-artifacts/coverage.txt) # unit | |
| [ -f cov-artifacts/cli-coverage.txt ] && FILES+=(cov-artifacts/cli-coverage.txt) # cli | |
| [ -f cov-artifacts/merged-bdd-coverage.txt ] && FILES+=(cov-artifacts/merged-bdd-coverage.txt) | |
| if [ ${#FILES[@]} -eq 0 ]; then | |
| echo "No coverage files found to merge"; exit 0; fi | |
| chmod +x scripts/merge-coverprofiles.sh | |
| ./scripts/merge-coverprofiles.sh total-coverage.txt "${FILES[@]}" | |
| echo "Merged: ${FILES[*]}" | |
| - name: Upload merged total coverage artifact | |
| if: success() && hashFiles('total-coverage.txt') != '' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: total-coverage | |
| path: total-coverage.txt | |
| if-no-files-found: error | |
| retention-days: 1 | |
| - name: Upload merged total coverage | |
| # Fail the job if Codecov can't find or upload the merged coverage | |
| if: always() | |
| uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.0 pinned | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| slug: GoCodeAlone/modular | |
| files: total-coverage.txt | |
| flags: total | |
| fail_ci_if_error: true |