diff --git a/.github/actions/parse-ci-reports/README.md b/.github/actions/parse-ci-reports/README.md
deleted file mode 100644
index 0400d8f..0000000
--- a/.github/actions/parse-ci-reports/README.md
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-# GitHub Action: Parse CI reports
-
-
-

-
-
----
-
-
-
-
-
-
-
-
-[](https://github.com/marketplace/actions/parse-ci-reports)
-[](https://github.com/hoverkraft-tech/ci-github-go/releases)
-[](http://choosealicense.com/licenses/mit/)
-[](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-go?style=social)
-[](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md)
-
-
-
-
-
-
-
-## Overview
-
-Parse native reports and retain parsed files for consolidated reporting. Keep native Go coverage in a separate artifact because the common parser does not support its format. Internal helper for lint and test.
-
-
-
-
-
-
-
-
-## Usage
-
-```yaml
-- uses: hoverkraft-tech/ci-github-go/.github/actions/parse-ci-reports@eac34b0e29b78265265a2021a9099f73ab699e0c # fix/consolidated-go-coverage
- with:
- # Validated absolute project directory.
- # This input is required.
- directory: ""
-
- # Report paths or auto selectors passed to the common parser.
- # Default: `auto:test`
- report-paths: auto:test
-
- # Calling job ID used to group reports.
- # This input is required.
- group: ""
-
- # Retain the project's coverage.out in a separate artifact when present.
- # Default: `false`
- native-coverage: "false"
-
- # Title of the GitHub report summary.
- # Default: `CI reports`
- report-name: CI reports
-```
-
-
-
-
-
-## Inputs
-
-| **Input** | **Description** | **Required** | **Default** |
-| --------------------- | ---------------------------------------------------------------------- | ------------ | ------------ |
-| **`directory`** | Validated absolute project directory. | **true** | - |
-| **`report-paths`** | Report paths or auto selectors passed to the common parser. | **false** | `auto:test` |
-| **`group`** | Calling job ID used to group reports. | **true** | - |
-| **`native-coverage`** | Retain the project's coverage.out in a separate artifact when present. | **false** | `false` |
-| **`report-name`** | Title of the GitHub report summary. | **false** | `CI reports` |
-
-
-
-
-
-
-
-
-## Outputs
-
-| **Output** | **Description** |
-| -------------------------- | ----------------------------------------------------------------------- |
-| **`artifact-id`** | Uploaded artifact ID, or empty when no report files exist. |
-| **`coverage-artifact-id`** | Native Go coverage artifact ID, or empty when no coverage was retained. |
-
-
-
-
-
-
-
-
-
-
-
-
-
-## Contributing
-
-Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md) for more details.
-
-
-
-
-
-
-
-
-## License
-
-This project is licensed under the MIT License.
-
-SPDX-License-Identifier: MIT
-
-Copyright © 2026 hoverkraft-tech
-
-For more details, see the [license](http://choosealicense.com/licenses/mit/).
-
-
-
-
-
----
-
-This documentation was automatically generated by [CI Dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor).
-
-
-
-
diff --git a/.github/actions/parse-ci-reports/action.test.cjs b/.github/actions/parse-ci-reports/action.test.cjs
deleted file mode 100644
index 9efd740..0000000
--- a/.github/actions/parse-ci-reports/action.test.cjs
+++ /dev/null
@@ -1,68 +0,0 @@
-const assert = require("node:assert/strict");
-const fs = require("node:fs");
-const path = require("node:path");
-const test = require("node:test");
-const {
- createWorkspace,
- loadActionStep,
-} = require("../../../tests/action-test-helpers.cjs");
-
-const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
-
-test("report artifacts contain only parsed reports and use unique names", async (t) => {
- const directory = createWorkspace(t);
- const report = path.join(directory, "junit.xml");
- fs.writeFileSync(report, "");
- fs.writeFileSync(
- path.join(directory, "unrelated-secret.txt"),
- "not a report",
- );
- const prepare = new AsyncFunction(
- "core",
- "process",
- "require",
- loadActionStep(path.join(__dirname, "action.yml"), "prepare").with.script,
- );
- async function outputs(files, group = "outer-job", nativeCoverage = false) {
- const result = {};
- await prepare(
- {
- setOutput: (key, value) => {
- result[key] = value;
- },
- },
- {
- env: {
- DIRECTORY: directory,
- REPORT_FILES: JSON.stringify(files),
- REPORT_GROUP: group,
- NATIVE_COVERAGE: String(nativeCoverage),
- GITHUB_RUN_ATTEMPT: "2",
- },
- },
- require,
- );
- return result;
- }
- assert.deepEqual(await outputs([]), {});
- const first = await outputs([report]);
- assert.equal(first.files, report);
- assert.match(first.name, /^ci-reports-2-outer-job-/);
- assert.notEqual(first.name, (await outputs([report])).name);
- await assert.rejects(() => outputs([report], "../bad-group"), /report-group/);
- const coverage = path.join(directory, "coverage.out");
- fs.writeFileSync(coverage, "mode: atomic\n");
- const retained = await outputs([report], "outer-job", true);
- assert.equal(retained.files, report);
- assert.equal(retained["coverage-file"], coverage);
- assert.match(retained["coverage-name"], /^go-coverage-2-outer-job-/);
- assert.equal(
- retained.name.replace("ci-reports-", "go-coverage-"),
- retained["coverage-name"],
- );
- const coverageOnly = await outputs([], "outer-job", true);
- assert.equal(coverageOnly.files, undefined);
- assert.equal(coverageOnly["coverage-file"], coverage);
- await assert.rejects(() => outputs([], "../bad-group", true), /report-group/);
- assert.equal((await outputs([report])).files, report);
-});
diff --git a/.github/actions/parse-ci-reports/action.yml b/.github/actions/parse-ci-reports/action.yml
deleted file mode 100644
index afde3b3..0000000
--- a/.github/actions/parse-ci-reports/action.yml
+++ /dev/null
@@ -1,89 +0,0 @@
----
-name: Parse CI reports
-description:
- Parse native reports and retain parsed files for consolidated reporting.
- Keep native Go coverage in a separate artifact because the common parser does not support its format.
- Internal helper for lint and test.
-inputs:
- directory:
- description: Validated absolute project directory.
- required: true
- report-paths:
- description: Report paths or auto selectors passed to the common parser.
- default: auto:test
- group:
- description: Calling job ID used to group reports.
- required: true
- native-coverage:
- description: Retain the project's coverage.out in a separate artifact when present.
- default: "false"
- report-name:
- description: Title of the GitHub report summary.
- default: CI reports
-outputs:
- artifact-id:
- description: Uploaded artifact ID, or empty when no report files exist.
- value: ${{ steps.upload.outputs.artifact-id }}
- coverage-artifact-id:
- description: Native Go coverage artifact ID, or empty when no coverage was retained.
- value: ${{ steps.upload-coverage.outputs.artifact-id }}
-runs:
- using: composite
- steps:
- - id: parse
- if: ${{ !cancelled() }}
- uses: hoverkraft-tech/ci-github-common/actions/quality/parse-ci-reports@66882b24f9f13e45a6541896a5a7c638cb91c94c # 4.0.0
- with:
- working-directory: ${{ inputs.directory }}
- report-paths: |
- ${{ inputs.report-paths }}
- !**/.venv/**
- !**/.git/**
- !**/.cache/**
- !**/vendor/**
- report-name: ${{ inputs.report-name }}
- output-format: annotations,summary,markdown
- - id: prepare
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
- env:
- DIRECTORY: ${{ inputs.directory }}
- REPORT_FILES: ${{ steps.parse.outputs.parsed-files }}
- REPORT_GROUP: ${{ inputs.group }}
- NATIVE_COVERAGE: ${{ inputs.native-coverage }}
- with:
- script: |
- const fs = require('node:fs');
- const path = require('node:path');
- const files = JSON.parse(process.env.REPORT_FILES || '[]');
- const coverage = path.join(process.env.DIRECTORY, 'coverage.out');
- const retainCoverage = process.env.NATIVE_COVERAGE === 'true' && fs.existsSync(coverage);
- if (!files.length && !retainCoverage) return;
- const group = process.env.REPORT_GROUP;
- if (!/^[\w-]+$/.test(group)) throw new Error('report-group must be a job ID.');
- const suffix = `${process.env.GITHUB_RUN_ATTEMPT}-${group}-${require('node:crypto').randomUUID()}`;
- if (files.length) {
- core.setOutput('files', files.join('\n'));
- core.setOutput('name', `ci-reports-${suffix}`);
- }
- if (retainCoverage) {
- core.setOutput('coverage-file', coverage);
- core.setOutput('coverage-name', `go-coverage-${suffix}`);
- }
- if: ${{ !cancelled() }}
- - id: upload
- if: ${{ !cancelled() && steps.prepare.outputs.files != '' }}
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: ${{ steps.prepare.outputs.name }}
- path: ${{ steps.prepare.outputs.files }}
- include-hidden-files: true
- if-no-files-found: error
- retention-days: 7
- - id: upload-coverage
- if: ${{ !cancelled() && steps.prepare.outputs.coverage-file != '' }}
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: ${{ steps.prepare.outputs.coverage-name }}
- path: ${{ steps.prepare.outputs.coverage-file }}
- if-no-files-found: error
- retention-days: 7
diff --git a/.github/linters/actionlint.yml b/.github/linters/actionlint.yml
new file mode 100644
index 0000000..1bb6ca0
--- /dev/null
+++ b/.github/linters/actionlint.yml
@@ -0,0 +1,15 @@
+# FIXME: Remove only the code-quality exception when Actionlint supports it.
+# https://github.com/rhysd/actionlint/pull/674
+paths:
+ {
+ .github/workflows/__main-ci.yml:
+ { ignore: [^unknown permission scope "code-quality"\.] },
+ .github/workflows/__pull-request-ci.yml:
+ { ignore: [^unknown permission scope "code-quality"\.] },
+ .github/workflows/__release.yml:
+ { ignore: [^unknown permission scope "code-quality"\.] },
+ .github/workflows/__shared-ci.yml:
+ { ignore: [^unknown permission scope "code-quality"\.] },
+ .github/workflows/__test-workflow-continuous-integration.yml:
+ { ignore: [^unknown permission scope "code-quality"\.] },
+ }
diff --git a/.github/renovate.json b/.github/renovate.json
index fe4ec8a..fcff3ea 100644
--- a/.github/renovate.json
+++ b/.github/renovate.json
@@ -31,6 +31,13 @@
],
"datasourceTemplate": "github-releases",
"depNameTemplate": "golangci/golangci-lint"
+ },
+ {
+ "customType": "regex",
+ "managerFilePatterns": ["/^actions/test/action\\.yml$/"],
+ "matchStrings": ["GOCOVER_COBERTURA_VERSION: (?v[^\\s]+)"],
+ "datasourceTemplate": "go",
+ "depNameTemplate": "github.com/boumenot/gocover-cobertura"
}
]
}
diff --git a/.github/workflows/__main-ci.yml b/.github/workflows/__main-ci.yml
index 6ed761c..87a9232 100644
--- a/.github/workflows/__main-ci.yml
+++ b/.github/workflows/__main-ci.yml
@@ -16,6 +16,7 @@ jobs:
actions: read
security-events: write
id-token: write
+ code-quality: write
release:
needs: ci
if: github.event_name != 'schedule' && vars.CI_BOT_APP_CLIENT_ID != ''
diff --git a/.github/workflows/__pull-request-ci.yml b/.github/workflows/__pull-request-ci.yml
index 7232af2..8b907bc 100644
--- a/.github/workflows/__pull-request-ci.yml
+++ b/.github/workflows/__pull-request-ci.yml
@@ -16,6 +16,7 @@ jobs:
actions: read
security-events: write
id-token: write
+ code-quality: write
"on":
merge_group: null
pull_request:
diff --git a/.github/workflows/__release.yml b/.github/workflows/__release.yml
index c41a8b4..78cc269 100644
--- a/.github/workflows/__release.yml
+++ b/.github/workflows/__release.yml
@@ -17,6 +17,7 @@ jobs:
actions: read
security-events: write
id-token: write
+ code-quality: write
release:
name: Create and publish release
needs: ci
diff --git a/.github/workflows/__semantic-pull-request.yml b/.github/workflows/__semantic-pull-request.yml
index 36b014f..2122f61 100644
--- a/.github/workflows/__semantic-pull-request.yml
+++ b/.github/workflows/__semantic-pull-request.yml
@@ -14,4 +14,4 @@ jobs:
main:
permissions:
contents: read
- uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
diff --git a/.github/workflows/__shared-ci.yml b/.github/workflows/__shared-ci.yml
index e11f26f..83f898e 100644
--- a/.github/workflows/__shared-ci.yml
+++ b/.github/workflows/__shared-ci.yml
@@ -1,18 +1,17 @@
----
name: Internal - Common Continuous Integration tasks
"on":
workflow_call: null
permissions: {}
jobs:
linter:
- uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
permissions:
+ actions: read
contents: read
statuses: write
issues: write
packages: read
pull-requests: write
- actions: read
security-events: write
with:
linter-env: |
@@ -22,11 +21,13 @@ jobs:
test:
uses: $/.github/workflows/__test-workflow-continuous-integration.yml
permissions:
+ actions: read
contents: read
id-token: write
test-action-setup-go:
uses: $/.github/workflows/__test-action-setup-go.yml
permissions:
+ actions: read
contents: read
test-action-lint:
uses: $/.github/workflows/__test-action-lint.yml
@@ -41,12 +42,48 @@ jobs:
test-action-audit:
uses: $/.github/workflows/__test-action-audit.yml
permissions:
+ actions: read
contents: read
test-action-build:
uses: $/.github/workflows/__test-action-build.yml
permissions:
+ actions: read
contents: read
- test-action-parse-ci-reports:
- uses: $/.github/workflows/__test-action-parse-ci-reports.yml
+
+ reports:
+ if: always()
+ needs:
+ - linter
+ - test
+ - test-action-setup-go
+ - test-action-lint
+ - test-action-test
+ - test-action-audit
+ - test-action-build
+ uses: hoverkraft-tech/ci-github-common/.github/workflows/publish-ci-reports.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
permissions:
+ actions: read
contents: read
+ pull-requests: write
+ code-quality: write
+ id-token: write
+ security-events: write
+ with:
+ job-results: ${{ toJSON(needs) }}
+
+ complete:
+ name: CI complete
+ if: always()
+ needs:
+ - linter
+ - test
+ - test-action-setup-go
+ - test-action-lint
+ - test-action-test
+ - test-action-audit
+ - test-action-build
+ - reports
+ uses: hoverkraft-tech/ci-github-common/.github/workflows/check-jobs.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
+ permissions: {}
+ with:
+ job-results: ${{ toJSON(needs) }}
diff --git a/.github/workflows/__test-action-lint.yml b/.github/workflows/__test-action-lint.yml
index 486034c..bf6d064 100644
--- a/.github/workflows/__test-action-lint.yml
+++ b/.github/workflows/__test-action-lint.yml
@@ -1,4 +1,3 @@
----
name: Internal - Test lint action
"on":
workflow_call: null
@@ -8,21 +7,22 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
+ actions: read
contents: read
outputs:
- artifact-id: ${{ steps.failed-lint.outputs.report-artifact-id }}
+ artifact-id: ${{ steps.check.outputs.report-artifact-id }}
steps:
- name: Arrange - Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Assert - Action contract tests pass
- uses: hoverkraft-tech/ci-github-nodejs/actions/test@98d91b1cc347efc64cd5fb20bc0ebc076acad114 # 3.1.0
+ uses: hoverkraft-tech/ci-github-nodejs/actions/test@133df96fa31a002107174959beafa09808597051 # PR #624 (unreleased)
with:
- command: test:ci
+ engine: node:test
arguments: '["actions/lint/action.test.cjs"]'
- coverage: ""
- comment: "false"
+ coverage: "false"
- name: Arrange - Install the project runtime and dependencies
uses: $/actions/setup-go
with:
@@ -31,23 +31,7 @@ jobs:
uses: $/actions/lint
with:
working-directory: tests/go-project
- - name: Act - Retain diagnostics from a failing command
- uses: $/actions/lint
- with:
- working-directory: tests/go-project
- command: |
- printf '%s\n' '' > checkstyle.xml
- exit 23
- id: failed-lint
- continue-on-error: true
- - name: Assert - Failure propagates and reports survive
- shell: bash
- run: |
- test "$OUTCOME" = failure
- test -n "$ARTIFACT"
- env:
- OUTCOME: ${{ steps.failed-lint.outcome }}
- ARTIFACT: ${{ steps.failed-lint.outputs.report-artifact-id }}
+ id: check
verify:
needs: lint
runs-on: ubuntu-latest
@@ -61,11 +45,11 @@ jobs:
with:
github-token: ${{ github.token }}
artifact-ids: ${{ needs.lint.outputs.artifact-id }}
- path: ${{ runner.temp }}/lint-reports
- - name: Assert - Retained report contains the diagnostic
+ path: ${{ runner.temp }}/retained-reports
+ - name: Assert - Native reports and validation result are retained
shell: bash
run: |
- test -f "$REPORT_DIRECTORY/checkstyle.xml"
- grep -q 'message="expected lint failure"' "$REPORT_DIRECTORY/checkstyle.xml"
+ test -f "$REPORT_DIRECTORY/report.json"
+ test -s "$REPORT_DIRECTORY/native/1-golangci-lint.sarif"
env:
- REPORT_DIRECTORY: ${{ runner.temp }}/lint-reports
+ REPORT_DIRECTORY: ${{ runner.temp }}/retained-reports
diff --git a/.github/workflows/__test-action-parse-ci-reports.yml b/.github/workflows/__test-action-parse-ci-reports.yml
deleted file mode 100644
index 90ebe67..0000000
--- a/.github/workflows/__test-action-parse-ci-reports.yml
+++ /dev/null
@@ -1,65 +0,0 @@
----
-name: Internal - Test parse-ci-reports action
-"on":
- workflow_call: null
-permissions: {}
-jobs:
- reports:
- runs-on: ubuntu-latest
- timeout-minutes: 5
- permissions:
- contents: read
- outputs:
- artifact-id: ${{ steps.report.outputs.artifact-id }}
- steps:
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
- - name: Assert - Action contract tests pass
- uses: hoverkraft-tech/ci-github-nodejs/actions/test@98d91b1cc347efc64cd5fb20bc0ebc076acad114 # 3.1.0
- with:
- command: test:ci
- arguments: '[".github/actions/parse-ci-reports/action.test.cjs"]'
- coverage: ""
- comment: "false"
- - name: Arrange - Empty report directory
- run: mkdir -p "$RUNNER_TEMP/empty-reports"
- - name: Act - Retain no reports
- id: empty
- uses: $/.github/actions/parse-ci-reports
- with:
- directory: ${{ runner.temp }}/empty-reports
- group: reports
- - name: Assert - No empty artifact is created
- env:
- ARTIFACT: ${{ steps.empty.outputs.artifact-id }}
- run: test -z "$ARTIFACT"
- - name: Arrange - One report and an unrelated private file
- run: |
- mkdir -p "$RUNNER_TEMP/report-fixture"
- printf '%s\n' '' > "$RUNNER_TEMP/report-fixture/junit.xml"
- printf '%s\n' 'not a report' > "$RUNNER_TEMP/report-fixture/private.txt"
- - name: Act - Retain the selected report
- id: report
- uses: $/.github/actions/parse-ci-reports
- with:
- directory: ${{ runner.temp }}/report-fixture
- group: reports
- report-paths: junit.xml
- verify:
- needs: reports
- runs-on: ubuntu-latest
- timeout-minutes: 5
- permissions:
- contents: read
- steps:
- - name: Assert - Artifact can be downloaded
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
- with:
- artifact-ids: ${{ needs.reports.outputs.artifact-id }}
- path: ${{ runner.temp }}/downloaded-reports
- - name: Assert - Only the selected file was retained
- run: |
- test -f "$RUNNER_TEMP/downloaded-reports/junit.xml"
- test ! -e "$RUNNER_TEMP/downloaded-reports/private.txt"
- test "$(find "$RUNNER_TEMP/downloaded-reports" -type f | wc -l)" -eq 1
diff --git a/.github/workflows/__test-action-setup-go.yml b/.github/workflows/__test-action-setup-go.yml
index 79bd9f0..c8cce90 100644
--- a/.github/workflows/__test-action-setup-go.yml
+++ b/.github/workflows/__test-action-setup-go.yml
@@ -1,4 +1,3 @@
----
name: Internal - Test setup-go action
"on":
workflow_call: null
@@ -8,19 +7,20 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
+ actions: read
contents: read
steps:
- name: Arrange - Check out the repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Assert - Action contract tests pass
- uses: hoverkraft-tech/ci-github-nodejs/actions/test@98d91b1cc347efc64cd5fb20bc0ebc076acad114 # 3.1.0
+ uses: hoverkraft-tech/ci-github-nodejs/actions/test@133df96fa31a002107174959beafa09808597051 # PR #624 (unreleased)
with:
- command: test:ci
+ engine: node:test
arguments: '["actions/setup-go/action.test.cjs"]'
- coverage: ""
- comment: "false"
+ coverage: "false"
- name: Act - Detect the runtime and install dependencies
uses: $/actions/setup-go
with:
diff --git a/.github/workflows/__test-action-test.yml b/.github/workflows/__test-action-test.yml
index 86e3e34..d3cb0b1 100644
--- a/.github/workflows/__test-action-test.yml
+++ b/.github/workflows/__test-action-test.yml
@@ -1,4 +1,3 @@
----
name: Internal - Test test action
"on":
workflow_call: null
@@ -8,58 +7,32 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
+ actions: read
contents: read
outputs:
- artifact-id: ${{ steps.failed-test.outputs.report-artifact-id }}
- success-artifact-id: ${{ steps.test.outputs.report-artifact-id }}
- coverage-artifact-id: ${{ steps.test.outputs.coverage-artifact-id }}
+ artifact-id: ${{ steps.check.outputs.report-artifact-id }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
name: Arrange - Check out the repository
- name: Assert - Action contract tests pass
- uses: hoverkraft-tech/ci-github-nodejs/actions/test@98d91b1cc347efc64cd5fb20bc0ebc076acad114 # 3.1.0
+ uses: hoverkraft-tech/ci-github-nodejs/actions/test@133df96fa31a002107174959beafa09808597051 # PR #624 (unreleased)
with:
- command: test:ci
+ engine: node:test
arguments: '["actions/test/action.test.cjs"]'
- coverage: ""
- comment: "false"
+ coverage: "false"
- uses: $/actions/setup-go
with:
working-directory: tests/go-project
name: Arrange - Install dependencies
- - id: test
+ - id: check
uses: $/actions/test
with:
working-directory: tests/go-project
+ coverage: "false"
name: Act - Run default tests
- - id: failed-test
- continue-on-error: true
- uses: $/actions/test
- with:
- working-directory: tests/go-project
- command: |-
- printf '%s' 'failure' > junit.xml
- exit 17
- coverage: ""
- name: Act - Run a failing test command
- - name: Assert failures and reports
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
- env:
- SUCCESS_ARTIFACT: ${{ steps.test.outputs.report-artifact-id }}
- FAILURE_ARTIFACT: ${{ steps.failed-test.outputs.report-artifact-id }}
- COVERAGE_ARTIFACT: ${{ steps.test.outputs.coverage-artifact-id }}
- TEST_OUTCOME: ${{ steps.failed-test.outcome }}
- with:
- script: |
- const assert = require('node:assert/strict');
- assert.equal(process.env.TEST_OUTCOME, 'failure');
- assert.ok(process.env.SUCCESS_ARTIFACT, 'Successful tests retain reports');
- assert.ok(process.env.FAILURE_ARTIFACT, 'Failed tests retain reports');
- assert.notEqual(process.env.SUCCESS_ARTIFACT, process.env.FAILURE_ARTIFACT);
- assert.ok(process.env.COVERAGE_ARTIFACT, 'Native coverage is retained separately');
- assert.notEqual(process.env.SUCCESS_ARTIFACT, process.env.COVERAGE_ARTIFACT);
verify:
needs: test
runs-on: ubuntu-latest
@@ -72,35 +45,11 @@ jobs:
with:
github-token: ${{ github.token }}
artifact-ids: ${{ needs.test.outputs.artifact-id }}
- path: ${{ runner.temp }}/failed-reports
- - name: Verify retained failure report
- shell: bash
- env:
- REPORT_DIRECTORY: ${{ runner.temp }}/failed-reports
- run: |
- test -f "$REPORT_DIRECTORY/junit.xml"
- grep -q 'message="expected"' "$REPORT_DIRECTORY/junit.xml"
- - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
- with:
- github-token: ${{ github.token }}
- artifact-ids: ${{ needs.test.outputs.success-artifact-id }}
- path: ${{ runner.temp }}/successful-reports
- - name: Verify consolidated reports parse every retained file
- uses: hoverkraft-tech/ci-github-common/actions/quality/parse-ci-reports@33462c06bcbbd9144d7f661929e61953604b444d # 4.3.2
- with:
- working-directory: ${{ runner.temp }}/successful-reports
- report-paths: "**/*"
- output-format: summary
- - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
- with:
- github-token: ${{ github.token }}
- artifact-ids: ${{ needs.test.outputs.coverage-artifact-id }}
- path: ${{ runner.temp }}/native-coverage
- - name: Verify native coverage stays available outside consolidated artifacts
+ path: ${{ runner.temp }}/retained-reports
+ - name: Assert - Native reports and validation result are retained
shell: bash
env:
- REPORT_DIRECTORY: ${{ runner.temp }}/successful-reports
- COVERAGE_DIRECTORY: ${{ runner.temp }}/native-coverage
+ REPORT_DIRECTORY: ${{ runner.temp }}/retained-reports
run: |
- test ! -e "$REPORT_DIRECTORY/coverage.out"
- grep -q '^mode: atomic$' "$COVERAGE_DIRECTORY/coverage.out"
+ test -f "$REPORT_DIRECTORY/report.json"
+ test -s "$REPORT_DIRECTORY/native/1-junit.xml"
diff --git a/.github/workflows/__test-workflow-continuous-integration.yml b/.github/workflows/__test-workflow-continuous-integration.yml
index 7f94995..8c3d669 100644
--- a/.github/workflows/__test-workflow-continuous-integration.yml
+++ b/.github/workflows/__test-workflow-continuous-integration.yml
@@ -1,4 +1,3 @@
----
name: Internal - Test continuous integration workflow
"on":
workflow_call: null
@@ -7,30 +6,34 @@ jobs:
configuration:
runs-on: ubuntu-latest
permissions:
+ actions: read
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Assert - Workflow configuration tests pass
- uses: hoverkraft-tech/ci-github-nodejs/actions/test@98d91b1cc347efc64cd5fb20bc0ebc076acad114 # 3.1.0
+ uses: hoverkraft-tech/ci-github-nodejs/actions/test@133df96fa31a002107174959beafa09808597051 # PR #624 (unreleased)
with:
- command: test:ci
+ engine: node:test
arguments: '["tests/config.test.cjs"]'
- coverage: ""
- comment: "false"
+ coverage: "false"
fixture:
uses: $/.github/workflows/continuous-integration.yml
permissions:
+ actions: read
contents: read
id-token: write
with:
working-directory: tests/go-project
+ test: '{"coverage":true}'
go-versions: '["1.26", "1.27"]'
dependency-review: false
checks-disabled:
uses: $/.github/workflows/continuous-integration.yml
permissions:
+ actions: read
contents: read
id-token: write
with:
diff --git a/.github/workflows/continuous-integration.md b/.github/workflows/continuous-integration.md
index f2b93bd..5ba44f8 100644
--- a/.github/workflows/continuous-integration.md
+++ b/.github/workflows/continuous-integration.md
@@ -2,12 +2,6 @@
# GitHub Reusable Workflow: Go Continuous Integration
-
-

-
-
----
-
@@ -16,9 +10,7 @@
[](https://github.com/hoverkraft-tech/ci-github-go/releases)
-[](http://choosealicense.com/licenses/mit/)
[](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-go?style=social)
-[](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md)
@@ -41,15 +33,14 @@ jobs:
uses: hoverkraft-tech/ci-github-go/.github/workflows/continuous-integration.yml@main
permissions:
contents: read
- id-token: write
with:
working-directory: .
go-versions: '["1.26", "1.27"]'
```
-An empty versions input uses project detection once. The last matrix entry is
+An empty versions input uses project detection once. The highest configured version is
the primary version: lint, audit and build checks run there, and only
-that version publishes coverage. Tests run on every entry with fail-fast disabled.
+that version contributes coverage. Tests run on every entry with fail-fast disabled.
Duplicate, malformed and non-string versions are rejected. `runs-on` is a JSON
array of Linux labels and applies to every job, including configuration.
@@ -94,37 +85,23 @@ with:
inside the checkout. Each invocation uses a unique artifact name.
Build output is not published as a release.
-### Reports and permissions
-
-Tests retain JUnit and supported coverage files for seven days, including after
-command failures. Lint retains parsed SARIF/Checkstyle reports. Only report files
-are uploaded, with unique names for parallel calls; a job producing no reports
-returns an empty `report-artifact-id`. Summaries and annotations work without PR
-write permissions. Individual PR comments are not created.
-
-Use the common
-[ci-reports workflow](https://github.com/hoverkraft-tech/ci-github-common/blob/main/.github/workflows/ci-reports.yml)
-for consolidated comments after standalone producer jobs; set `report-group` to
-the outer calling job ID when required. Go coverage uses native `go tool cover` summaries and retains
-`coverage.out` in separate `go-coverage-*` artifacts; the common parser handles
-JUnit, not native Go coverage. Coverage details remain in each test job summary.
-
-`test: '{"coverage":"codecov"}'` enables OIDC upload. The expected coverage file is
-`coverage.out`. A custom command must produce
-the applicable file. `coverage` controls publication, not collection, and an
-empty value still retains JUnit results. The reusable workflow declares
-`id-token: write` for Codecov and callers must grant it, including for default
-GitHub reports. Standalone GitHub reporting requires only read permissions.
-No repository-specific bot secrets are required by the public actions or workflow.
-
-See [setup-go](../../actions/setup-go/README.md), [lint](../../actions/lint/README.md),
-[test](../../actions/test/README.md) and [audit](../../actions/audit/README.md)
-for standalone action usage. Pin the workflow to a reviewed commit SHA in production.
+### Report artifacts
+
+Every runtime retains validated JUnit test results. Lint and coverage run once
+on the highest configured version; the default command disables instrumentation
+on other versions. Custom commands receive CI_REPORTS_DIR and CI_TEST_COVERAGE.
+The test action converts its native profile to standard line coverage with gocover-cobertura.
+The lint and test actions validate their outputs and upload report artifacts,
+including after command failure. Missing or malformed required reports fail the action.
+Producer calls require actions: read and contents: read.
+
+The caller publishes those artifacts once with `publish-ci-reports.yml`.
+See the [common reporting guide](https://github.com/hoverkraft-tech/ci-github-common/blob/5.0.0/.github/workflows/publish-ci-reports.md#consumer-workflow).
### Permissions
+- **`actions`**: `read`
- **`contents`**: `read`
-- **`id-token`**: `write`
@@ -144,10 +121,10 @@ on:
permissions: {}
jobs:
continuous-integration:
- uses: hoverkraft-tech/ci-github-go/.github/workflows/continuous-integration.yml@3a72b809f7253a916ee2f4bcee59a66bbba131d3 # main
+ uses: hoverkraft-tech/ci-github-go/.github/workflows/continuous-integration.yml@8eea0eff4ef23bbb9789190957dcfa37beb86917 # feat/native-github-coverage
permissions:
+ actions: read
contents: read
- id-token: write
with:
# JSON array of Linux runner labels for all jobs.
# Default: `["ubuntu-latest"]`
@@ -161,14 +138,14 @@ jobs:
# Default: `.`
working-directory: .
- # JSON array of Go versions. The last entry runs lint, audit and build and publishes coverage. Empty runs project detection once. An empty entry uses the project version.
+ # JSON array of Go versions. Every version retains test results; the highest configured version runs lint, audit, build and coverage. Empty uses project detection once.
go-versions: ""
- # true for default checks, a trusted Bash command, or a JSON object with command. false, null or empty disables lint.
+ # true for defaults, a Bash command or JSON options (command). false, null or empty disables lint.
# Default: `true`
lint: "true"
- # true for default tests, a trusted Bash command, or a JSON object with command, coverage (`github`, `codecov` or empty), and race (boolean). false, null or empty disables tests. Coverage publication runs only on the last version; the command controls collection.
+ # true for defaults, a Bash command or JSON options (command, race, coverage). Supported report files are discovered automatically under CI_REPORTS_DIR. false, null or empty disables tests.
# Default: `true`
test: "true"
@@ -197,18 +174,18 @@ jobs:
### Workflow Call Inputs
-| **Input** | **Description** | **Required** | **Type** | **Default** |
-| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ----------- | ------------------- |
-| **`runs-on`** | JSON array of Linux runner labels for all jobs. | **false** | **string** | `["ubuntu-latest"]` |
-| **`checks`** | Enable all checks, including build. | **false** | **boolean** | `true` |
-| **`working-directory`** | One project directory inside the checkout. Use a caller matrix for multiple projects. | **false** | **string** | `.` |
-| **`go-versions`** | JSON array of Go versions. The last entry runs lint, audit and build and publishes coverage. Empty runs project detection once. An empty entry uses the project version. | **false** | **string** | - |
-| **`lint`** | true for default checks, a trusted Bash command, or a JSON object with command. false, null or empty disables lint. | **false** | **string** | `true` |
-| **`test`** | true for default tests, a trusted Bash command, or a JSON object with command, coverage (`github`, `codecov` or empty), and race (boolean). false, null or empty disables tests. Coverage publication runs only on the last version; the command controls collection. | **false** | **string** | `true` |
-| **`audit`** | Check production dependencies for known vulnerabilities. | **false** | **boolean** | `true` |
-| **`dependency-review`** | Review dependency changes on pull requests. Requires GitHub dependency review availability. | **false** | **boolean** | `true` |
-| **`build`** | true for go build, a trusted Bash command, or a JSON object with command and artifact (one project-relative directory). false, null or empty disables build. | **false** | **string** | `true` |
-| **`golangci-lint-version`** | Pinned golangci-lint v2 release used by the lint action. | **false** | **string** | `v2.15.0` |
+| **Input** | **Description** | **Required** | **Type** | **Default** |
+| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ----------- | ------------------- |
+| **`runs-on`** | JSON array of Linux runner labels for all jobs. | **false** | **string** | `["ubuntu-latest"]` |
+| **`checks`** | Enable all checks, including build. | **false** | **boolean** | `true` |
+| **`working-directory`** | One project directory inside the checkout. Use a caller matrix for multiple projects. | **false** | **string** | `.` |
+| **`go-versions`** | JSON array of Go versions. Every version retains test results; the highest configured version runs lint, audit, build and coverage. Empty uses project detection once. | **false** | **string** | - |
+| **`lint`** | true for defaults, a Bash command or JSON options (command). false, null or empty disables lint. | **false** | **string** | `true` |
+| **`test`** | true for defaults, a Bash command or JSON options (command, race, coverage). Supported report files are discovered automatically under CI_REPORTS_DIR. false, null or empty disables tests. | **false** | **string** | `true` |
+| **`audit`** | Check production dependencies for known vulnerabilities. | **false** | **boolean** | `true` |
+| **`dependency-review`** | Review dependency changes on pull requests. Requires GitHub dependency review availability. | **false** | **boolean** | `true` |
+| **`build`** | true for go build, a trusted Bash command, or a JSON object with command and artifact (one project-relative directory). false, null or empty disables build. | **false** | **string** | `true` |
+| **`golangci-lint-version`** | Pinned golangci-lint v2 release used by the lint action. | **false** | **string** | `v2.15.0` |
@@ -234,28 +211,12 @@ jobs:
-
-## Contributing
-
-Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md) for more details.
-
-
-## License
-
-This project is licensed under the MIT License.
-
-SPDX-License-Identifier: MIT
-
-Copyright © 2026 hoverkraft-tech
-
-For more details, see the [license](http://choosealicense.com/licenses/mit/).
-
diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index 9539d4f..da4c272 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -11,15 +11,14 @@
# uses: hoverkraft-tech/ci-github-go/.github/workflows/continuous-integration.yml@main
# permissions:
# contents: read
-# id-token: write
# with:
# working-directory: .
# go-versions: '["1.26", "1.27"]'
# ```
#
-# An empty versions input uses project detection once. The last matrix entry is
+# An empty versions input uses project detection once. The highest configured version is
# the primary version: lint, audit and build checks run there, and only
-# that version publishes coverage. Tests run on every entry with fail-fast disabled.
+# that version contributes coverage. Tests run on every entry with fail-fast disabled.
# Duplicate, malformed and non-string versions are rejected. `runs-on` is a JSON
# array of Linux labels and applies to every job, including configuration.
#
@@ -64,34 +63,19 @@
# inside the checkout. Each invocation uses a unique artifact name.
# Build output is not published as a release.
#
-# ### Reports and permissions
+# ### Report artifacts
#
-# Tests retain JUnit and supported coverage files for seven days, including after
-# command failures. Lint retains parsed SARIF/Checkstyle reports. Only report files
-# are uploaded, with unique names for parallel calls; a job producing no reports
-# returns an empty `report-artifact-id`. Summaries and annotations work without PR
-# write permissions. Individual PR comments are not created.
+# Every runtime retains validated JUnit test results. Lint and coverage run once
+# on the highest configured version; the default command disables instrumentation
+# on other versions. Custom commands receive CI_REPORTS_DIR and CI_TEST_COVERAGE.
+# The test action converts its native profile to standard line coverage with gocover-cobertura.
+# The lint and test actions validate their outputs and upload report artifacts,
+# including after command failure. Missing or malformed required reports fail the action.
+# Producer calls require actions: read and contents: read.
#
-# Use the common
-# [ci-reports workflow](https://github.com/hoverkraft-tech/ci-github-common/blob/main/.github/workflows/ci-reports.yml)
-# for consolidated comments after standalone producer jobs; set `report-group` to
-# the outer calling job ID when required. Go coverage uses native `go tool cover` summaries and retains
-# `coverage.out` in separate `go-coverage-*` artifacts; the common parser handles
-# JUnit, not native Go coverage. Coverage details remain in each test job summary.
+# The caller publishes those artifacts once with `publish-ci-reports.yml`.
+# See the [common reporting guide](https://github.com/hoverkraft-tech/ci-github-common/blob/5.0.0/.github/workflows/publish-ci-reports.md#consumer-workflow).
#
-# `test: '{"coverage":"codecov"}'` enables OIDC upload. The expected coverage file is
-# `coverage.out`. A custom command must produce
-# the applicable file. `coverage` controls publication, not collection, and an
-# empty value still retains JUnit results. The reusable workflow declares
-# `id-token: write` for Codecov and callers must grant it, including for default
-# GitHub reports. Standalone GitHub reporting requires only read permissions.
-# No repository-specific bot secrets are required by the public actions or workflow.
-#
-# See [setup-go](../../actions/setup-go/README.md), [lint](../../actions/lint/README.md),
-# [test](../../actions/test/README.md) and [audit](../../actions/audit/README.md)
-# for standalone action usage. Pin the workflow to a reviewed commit SHA in production.
-
----
name: Go Continuous Integration
"on":
workflow_call:
@@ -109,15 +93,15 @@ name: Go Continuous Integration
type: string
default: .
go-versions:
- description: JSON array of Go versions. The last entry runs lint, audit and build and publishes coverage. Empty runs project detection once. An empty entry uses the project version.
+ description: JSON array of Go versions. Every version retains test results; the highest configured version runs lint, audit, build and coverage. Empty uses project detection once.
type: string
default: ""
lint:
- description: true for default checks, a trusted Bash command, or a JSON object with command. false, null or empty disables lint.
+ description: true for defaults, a Bash command or JSON options (command). false, null or empty disables lint.
type: string
default: "true"
test:
- description: true for default tests, a trusted Bash command, or a JSON object with command, coverage (`github`, `codecov` or empty), and race (boolean). false, null or empty disables tests. Coverage publication runs only on the last version; the command controls collection.
+ description: "true for defaults, a Bash command or JSON options (command, race, coverage). Supported report files are discovered automatically under CI_REPORTS_DIR. false, null or empty disables tests."
type: string
default: "true"
audit:
@@ -159,6 +143,8 @@ jobs:
LINT: ${{ inputs.lint }}
TEST: ${{ inputs.test }}
BUILD: ${{ inputs.build }}
+ DIRECTORY: ${{ inputs.working-directory }}
+ CHECKS: ${{ inputs.checks }}
with:
script: |
const versions = process.env.VERSIONS.trim() ? JSON.parse(process.env.VERSIONS) : [''];
@@ -179,13 +165,12 @@ jobs:
if (unknown.length) throw new Error('Unknown ' + name + ' options: ' + unknown.join(', '));
config = {...defaults, ...config};
for (const [key, value] of Object.entries(config)) {
- if (typeof value !== typeof defaults[key]) throw new Error(name + '.' + key + ' has the wrong type.');
+ if (Array.isArray(defaults[key]) ? !Array.isArray(value) : typeof value !== typeof defaults[key]) throw new Error(name + '.' + key + ' has the wrong type.');
}
return config;
}
const lint = options('lint', process.env.LINT, {command: ''});
- const test = options('test', process.env.TEST, {"command": "", "coverage": "github", "race": true});
- if (test && !['', 'github', 'codecov'].includes(test.coverage)) throw new Error('test.coverage must be github, codecov or empty.');
+ const test = options('test', process.env.TEST, {command:'', coverage:true, race:true});
const build = options('build', process.env.BUILD, {command: 'go build -mod=readonly -trimpath ./...', artifact: ''});
const artifact = build?.artifact;
if (artifact && (artifact === '.' || artifact.startsWith('/') || artifact.includes('\\') || artifact.split('/').includes('..') || /[\r\n*?]/.test(artifact))) {
@@ -194,7 +179,16 @@ jobs:
if (build && !build.command.trim()) throw new Error('build.command must not be empty.');
core.setOutput('build', JSON.stringify(build));
core.setOutput('versions', versions);
- core.setOutput('primary-version', versions.at(-1));
+ if (versions.length > 1 && versions.includes('')) throw new Error('Project detection cannot be mixed with explicit versions.');
+ const primary = [...versions].sort((a, b) => {
+ const left = a.split('.').map(Number); const right = b.split('.').map(Number);
+ for (let index = 0; index < 3; index++) {
+ const difference = (left[index] || 0) - (right[index] || 0);
+ if (difference) return difference;
+ }
+ return 0;
+ }).at(-1);
+ core.setOutput('primary-version', primary);
core.setOutput('lint', JSON.stringify(lint));
core.setOutput('test', JSON.stringify(test));
dependency-review:
@@ -207,6 +201,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/dependency-review-action@bbc44d14a204704ccc493733616cd1e93a0321ec # v5.0.1
lint:
if: inputs.checks && needs.configuration.outputs.lint != 'null'
@@ -215,6 +210,7 @@ jobs:
timeout-minutes: 20
permissions:
contents: read
+ actions: read
steps:
- *checkout
- &setup-primary
@@ -234,9 +230,12 @@ jobs:
timeout-minutes: 20
permissions:
contents: read
- id-token: write
+ actions: read
steps:
- - *checkout
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
+ persist-credentials: false
- uses: $/actions/setup-go
with:
working-directory: ${{ inputs.working-directory }}
@@ -245,7 +244,7 @@ jobs:
with:
working-directory: ${{ inputs.working-directory }}
command: ${{ fromJSON(needs.configuration.outputs.test).command }}
- coverage: ${{ matrix.version == needs.configuration.outputs.primary-version && fromJSON(needs.configuration.outputs.test).coverage || '' }}
+ coverage: ${{ matrix.version == needs.configuration.outputs.primary-version && fromJSON(needs.configuration.outputs.test).coverage && 'true' || 'false' }}
race: ${{ fromJSON(needs.configuration.outputs.test).race }}
strategy:
fail-fast: false
@@ -280,7 +279,7 @@ jobs:
command: ${{ fromJSON(needs.configuration.outputs.build).command }}
- id: artifact
if: fromJSON(needs.configuration.outputs.build).artifact != ''
- uses: hoverkraft-tech/ci-github-common/actions/working-directory@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/actions/working-directory@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
working-directory: ${{ inputs.working-directory }}/${{ fromJSON(needs.configuration.outputs.build).artifact }}
- id: artifact-name
diff --git a/Makefile b/Makefile
index 92e4492..756f6dd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+GIT_COMMON_DIR := $(shell git rev-parse --path-format=absolute --git-common-dir)
+
.PHONY: help setup test test-fixture lint-fixture lint lint-fix docs ci
LINTER_IMAGE := ci-github-go-linter:local
@@ -27,9 +29,14 @@ lint-fix: ## Apply supported formatting fixes
docs: ## Generate action and workflow references with CI Dokumentor
docker run --rm --user $(shell id -u):$(shell id -g) -v "$(CURDIR):/workspace" -w /workspace -e GITHUB_TOKEN ghcr.io/hoverkraft-tech/ci-dokumentor/cli:0.6.0 generate --repository github --cicd github-actions --source 'actions/**/action.yml' '.github/actions/**/action.yml' '.github/workflows/[!_]*.yml'
-ci: setup test lint-fixture test-fixture lint ## Run checks without rewriting source
+ci: ## Run checks without rewriting source
+ $(MAKE) setup
+ $(MAKE) test
+ $(MAKE) lint-fixture
+ $(MAKE) test-fixture
+ $(MAKE) lint
define run_linter
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $(LINTER_IMAGE) .
- docker run --rm -v "$(CURDIR):$(CURDIR)" -e DEFAULT_WORKSPACE="$(CURDIR)" -e IGNORE_GITIGNORED_FILES=true $(1) $(LINTER_IMAGE)
+ docker run --rm -v "$(GIT_COMMON_DIR):$(GIT_COMMON_DIR):ro" -v "$(CURDIR):$(CURDIR)" -e DEFAULT_WORKSPACE="$(CURDIR)" -e DEFAULT_BRANCH="$$(git rev-parse --abbrev-ref HEAD)" -e RUN_LOCAL=true -e USE_FIND_ALGORITHM=false -e IGNORE_GITIGNORED_FILES=true $(1) $(LINTER_IMAGE)
endef
diff --git a/actions/audit/action.yml b/actions/audit/action.yml
index 399783a..c406a24 100644
--- a/actions/audit/action.yml
+++ b/actions/audit/action.yml
@@ -27,7 +27,7 @@ runs:
using: composite
steps:
- id: directory
- uses: hoverkraft-tech/ci-github-common/actions/working-directory@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/actions/working-directory@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
working-directory: ${{ inputs.working-directory }}
- id: audit
diff --git a/actions/build/action.yml b/actions/build/action.yml
index 0c38100..7aaa784 100644
--- a/actions/build/action.yml
+++ b/actions/build/action.yml
@@ -32,7 +32,7 @@ runs:
using: composite
steps:
- id: directory
- uses: hoverkraft-tech/ci-github-common/actions/working-directory@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/actions/working-directory@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
working-directory: ${{ inputs.working-directory }}
- id: run
diff --git a/actions/lint/README.md b/actions/lint/README.md
index d5398f5..9b577e6 100644
--- a/actions/lint/README.md
+++ b/actions/lint/README.md
@@ -2,12 +2,6 @@
#  GitHub Action: Lint Go
-
-

-
-
----
-
@@ -17,9 +11,7 @@
[](https://github.com/marketplace/actions/lint-go)
[](https://github.com/hoverkraft-tech/ci-github-go/releases)
-[](http://choosealicense.com/licenses/mit/)
[](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-go?style=social)
-[](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md)
@@ -31,20 +23,13 @@
Check gofmt, module tidiness and golangci-lint v2 diagnostics.
-Put project rules in `.golangci.yml`; the default is the standard linter set.
-The pinned golangci-lint release must support the selected Go version.
-Use `command` to replace defaults with a trusted Bash program.
-Custom commands should emit SARIF or Checkstyle for annotations.
-
-
-
-
-Run [setup-go](../setup-go/README.md) first with the same `working-directory`.
-
-Native reports survive command failures and are retained for seven days.
-See the [continuous integration workflow](../../.github/workflows/continuous-integration.md#reports-and-permissions) for consolidated reporting and permissions.
-
-
+Run setup-go first. Project rules belong in .golangci.yml. All default checks
+execute even after a failure; SARIF is written into a fresh CI_REPORTS_DIR.
+Supported report files are discovered automatically.
+Custom commands must write the supported native reports under CI_REPORTS_DIR.
+Reports are validated after execution, including after
+failure. Call common publish-ci-reports once after all jobs for annotations and summaries.
+Producer jobs require actions: read and contents: read.
@@ -56,7 +41,7 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
## Usage
```yaml
-- uses: hoverkraft-tech/ci-github-go/actions/lint@eac34b0e29b78265265a2021a9099f73ab699e0c # fix/consolidated-go-coverage
+- uses: hoverkraft-tech/ci-github-go/actions/lint@8eea0eff4ef23bbb9789190957dcfa37beb86917 # feat/native-github-coverage
with:
# Go module directory.
# Default: `.`
@@ -66,11 +51,8 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
# Default: `v2.15.0`
golangci-lint-version: v2.15.0
- # Trusted Bash command replacing the default formatting and lint checks. Project configuration remains authoritative.
+ # Trusted Bash replacement for the default checks. Write supported native reports under CI_REPORTS_DIR; test commands must honor CI_TEST_COVERAGE.
command: ""
-
- # Outer calling job ID for consolidated ci-reports. Defaults to the current job ID. No individual PR comments are posted.
- report-group: ""
```
@@ -79,12 +61,11 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
## Inputs
-| **Input** | **Description** | **Required** | **Default** |
-| --------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------ | ----------- |
-| **`working-directory`** | Go module directory. | **false** | `.` |
-| **`golangci-lint-version`** | Pinned golangci-lint v2 release. | **false** | `v2.15.0` |
-| **`command`** | Trusted Bash command replacing the default formatting and lint checks. Project configuration remains authoritative. | **false** | - |
-| **`report-group`** | Outer calling job ID for consolidated ci-reports. Defaults to the current job ID. No individual PR comments are posted. | **false** | - |
+| **Input** | **Description** | **Required** | **Default** |
+| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | ----------- |
+| **`working-directory`** | Go module directory. | **false** | `.` |
+| **`golangci-lint-version`** | Pinned golangci-lint v2 release. | **false** | `v2.15.0` |
+| **`command`** | Trusted Bash replacement for the default checks. Write supported native reports under CI_REPORTS_DIR; test commands must honor CI_TEST_COVERAGE. | **false** | - |
@@ -95,9 +76,9 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
## Outputs
-| **Output** | **Description** |
-| ------------------------ | --------------------------------------------------------------- |
-| **`report-artifact-id`** | Native report artifact ID. Empty when no reports were produced. |
+| **Output** | **Description** |
+| ------------------------ | -------------------------- |
+| **`report-artifact-id`** | Native lint report bundle. |
@@ -110,28 +91,12 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
-
-## Contributing
-
-Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md) for more details.
-
-
-## License
-
-This project is licensed under the MIT License.
-
-SPDX-License-Identifier: MIT
-
-Copyright © 2026 hoverkraft
-
-For more details, see the [license](http://choosealicense.com/licenses/mit/).
-
diff --git a/actions/lint/action.test.cjs b/actions/lint/action.test.cjs
index 2e6226f..c97af1f 100644
--- a/actions/lint/action.test.cjs
+++ b/actions/lint/action.test.cjs
@@ -1,26 +1,7 @@
-const assert = require("node:assert/strict");
-const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
-const {
- createWorkspace,
- runActionStep,
-} = require("../../tests/action-test-helpers.cjs");
+const { assertCustomCommand } = require("../../tests/action-test-helpers.cjs");
-const actionFile = path.join(__dirname, "action.yml");
-
-test("custom commands retain quoting and fail without continuing to default tools", (t) => {
- const directory = createWorkspace(t);
- const output = path.join(directory, "command output.txt");
- const result = runActionStep(actionFile, "run", directory, {
- COMMAND: 'printf "%s" "$VALUE" > "$OUTPUT"\nexit 17',
- OUTPUT: output,
- VALUE: 'quotes " and $(not-executed)',
- });
- assert.equal(result.status, 17, result.stderr);
- assert.notEqual(
- runActionStep(actionFile, "run", directory, { COMMAND: " " }).status,
- 0,
- );
- assert.equal(fs.readFileSync(output, "utf8"), 'quotes " and $(not-executed)');
+test("custom lint commands preserve quoting and propagate failure", (t) => {
+ assertCustomCommand(path.join(__dirname, "action.yml"), t);
});
diff --git a/actions/lint/action.yml b/actions/lint/action.yml
index ce8f934..1f1ecad 100644
--- a/actions/lint/action.yml
+++ b/actions/lint/action.yml
@@ -3,20 +3,13 @@ name: Lint Go
description: |
Check gofmt, module tidiness and golangci-lint v2 diagnostics.
- Put project rules in `.golangci.yml`; the default is the standard linter set.
- The pinned golangci-lint release must support the selected Go version.
- Use `command` to replace defaults with a trusted Bash program.
- Custom commands should emit SARIF or Checkstyle for annotations.
-
-
-
-
- Run [setup-go](../setup-go/README.md) first with the same `working-directory`.
-
- Native reports survive command failures and are retained for seven days.
- See the [continuous integration workflow](../../.github/workflows/continuous-integration.md#reports-and-permissions) for consolidated reporting and permissions.
-
-
+ Run setup-go first. Project rules belong in .golangci.yml. All default checks
+ execute even after a failure; SARIF is written into a fresh CI_REPORTS_DIR.
+ Supported report files are discovered automatically.
+ Custom commands must write the supported native reports under CI_REPORTS_DIR.
+ Reports are validated after execution, including after
+ failure. Call common publish-ci-reports once after all jobs for annotations and summaries.
+ Producer jobs require actions: read and contents: read.
author: hoverkraft
branding:
icon: package
@@ -29,20 +22,20 @@ inputs:
description: Pinned golangci-lint v2 release.
default: v2.15.0
command:
- description: Trusted Bash command replacing the default formatting and lint checks. Project configuration remains authoritative.
- default: ""
- report-group:
- description: Outer calling job ID for consolidated ci-reports. Defaults to the current job ID. No individual PR comments are posted.
+ description:
+ Trusted Bash replacement for the default checks. Write supported
+ native reports under CI_REPORTS_DIR; test commands must honor
+ CI_TEST_COVERAGE.
default: ""
outputs:
report-artifact-id:
- description: Native report artifact ID. Empty when no reports were produced.
- value: ${{ steps.report-artifact.outputs.artifact-id }}
+ description: Native lint report bundle.
+ value: ${{ steps.reports.outputs.artifact-id }}
runs:
using: composite
steps:
- id: directory
- uses: hoverkraft-tech/ci-github-common/actions/working-directory@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/actions/working-directory@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
working-directory: ${{ inputs.working-directory }}
- id: golangci
@@ -52,6 +45,30 @@ runs:
version: ${{ inputs.golangci-lint-version }}
install-only: true
working-directory: ${{ steps.directory.outputs.workspace-relative-path }}
+ - id: definition
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ env:
+ DIRECTORY: ${{ steps.directory.outputs.workspace-relative-path || '.' }}
+ WORKING_DIRECTORY: ${{ steps.directory.outputs.absolute-path }}
+ GOTOOLCHAIN: local
+ GOWORK: off
+ with:
+ script: |
+ const reports = [{kind: 'lint'}];
+ const options = {cwd:process.env.WORKING_DIRECTORY,silent:true};
+ const runtime = await exec.getExecOutput('go', ['env','GOVERSION'], options);
+ const modulePath = await exec.getExecOutput('go', ['list','-m','-f','{{.Path}}'], options);
+ core.setOutput('definition', {name:'Go lint',project:process.env.DIRECTORY,variant:{runtime:runtime.stdout.trim()},reports,'path-mapping':{[modulePath.stdout.trim()]:process.env.DIRECTORY}});
+ - id: prepare
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const fs = require('node:fs');
+ const path = require('node:path');
+ core.setOutput('report-directory', fs.mkdtempSync(path.join(process.env.RUNNER_TEMP, 'ci-reports-')));
+ core.setOutput('definition', process.env.REPORT_DEFINITION);
+ env:
+ REPORT_DEFINITION: ${{ steps.definition.outputs.definition }}
- id: run
shell: bash
working-directory: ${{ steps.directory.outputs.absolute-path }}
@@ -59,6 +76,7 @@ runs:
COMMAND: ${{ inputs.command }}
GOTOOLCHAIN: local
GOWORK: "off"
+ CI_REPORTS_DIR: ${{ steps.prepare.outputs.report-directory }}
run: |
if [ -n "$COMMAND" ] && ! [[ "$COMMAND" =~ [^[:space:]] ]]; then
echo "command must not contain only whitespace." >&2
@@ -77,14 +95,13 @@ runs:
fi
done < <(find . -type d \( -name vendor -o -name .git -o -name .cache \) -prune -o -type f -name '*.go' -print0)
go mod tidy -diff || status=1
- golangci-lint run --timeout=5m --output.sarif.path=golangci-lint.sarif || status=1
+ golangci-lint run --timeout=5m --output.sarif.path="$CI_REPORTS_DIR/golangci-lint.sarif" || status=1
exit "$status"
- - name: Report lint results
- id: report-artifact
- if: ${{ !cancelled() && steps.run.outcome != 'skipped' }}
- uses: $/.github/actions/parse-ci-reports
+ - id: reports
+ name: Prepare and retain reports
+ if: ${{ !cancelled() && steps.prepare.outcome == 'success' }}
+ uses: hoverkraft-tech/ci-github-common/actions/quality/prepare-ci-reports@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
- directory: ${{ steps.directory.outputs.absolute-path }}
- report-paths: auto:lint
- report-name: Go lint results
- group: ${{ inputs.report-group || github.job }}
+ definition: ${{ steps.prepare.outputs.definition }}
+ directory: ${{ steps.prepare.outputs.report-directory }}
+ outcome: ${{ steps.run.outcome }}
diff --git a/actions/setup-go/action.yml b/actions/setup-go/action.yml
index e1e2f61..b2ab950 100644
--- a/actions/setup-go/action.yml
+++ b/actions/setup-go/action.yml
@@ -60,7 +60,7 @@ runs:
using: composite
steps:
- id: directory
- uses: hoverkraft-tech/ci-github-common/actions/working-directory@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/actions/working-directory@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
working-directory: ${{ inputs.working-directory }}
- id: validate
diff --git a/actions/test/README.md b/actions/test/README.md
index 2a95a25..893aa27 100644
--- a/actions/test/README.md
+++ b/actions/test/README.md
@@ -2,12 +2,6 @@
#  GitHub Action: Test Go
-
-

-
-
----
-
@@ -17,9 +11,7 @@
[](https://github.com/marketplace/actions/test-go)
[](https://github.com/hoverkraft-tech/ci-github-go/releases)
-[](http://choosealicense.com/licenses/mit/)
[](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-go?style=social)
-[](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md)
@@ -29,36 +21,17 @@
## Overview
-Run Go tests with gotestsum, JUnit output and atomic coverage.
-
-Defaults enable `-race`, `-count=1` and a five-minute package timeout.
-The race detector requires CGO and a C compiler on a supported Linux runner;
-set `race: "false"` when unavailable. A trusted Bash `command` replaces defaults
-and must produce JUnit for test reporting and `coverage.out` for coverage.
-GitHub coverage uses native `go tool cover` summaries and retains `coverage.out`;
-the common report parser handles JUnit, not the native Go coverage format.
-Native coverage is retained in a separate `go-coverage-*` artifact, so consolidated
-CI reports receive only supported files. Coverage details remain in the test job summary.
-
-
-
-
-Run [setup-go](../setup-go/README.md) first with the same `working-directory`.
-
-
-
-`coverage: "github"` is the default. Set `coverage: "codecov"` and grant the
-job `id-token: write` for OIDC upload of `coverage.out`. An empty coverage
-value disables publication while retaining JUnit; collection is controlled by
-the command. Custom commands must produce the applicable report files.
-
-
-
+Run Go tests with detailed JUnit results on every runtime and optional native coverage.
-Native reports survive command failures and are retained for seven days.
-See the [continuous integration workflow](../../.github/workflows/continuous-integration.md#reports-and-permissions) for consolidated reporting and permissions.
+Run setup-go first. Defaults write junit.xml and coverage.xml into a fresh
+CI_REPORTS_DIR. Coverage instrumentation is disabled when coverage is false.
+Supported report files are discovered automatically; no filenames need declaring.
+Custom commands receive CI_REPORTS_DIR and CI_TEST_COVERAGE.
-
+Required outputs are validated after success or failure. The default command
+converts Go coverage to Cobertura with gocover-cobertura. Select publication once
+in common publish-ci-reports after all jobs; no report outputs need forwarding.
+Producer jobs require actions: read and contents: read.
@@ -70,25 +43,22 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
## Usage
```yaml
-- uses: hoverkraft-tech/ci-github-go/actions/test@3a72b809f7253a916ee2f4bcee59a66bbba131d3 # main
+- uses: hoverkraft-tech/ci-github-go/actions/test@8eea0eff4ef23bbb9789190957dcfa37beb86917 # feat/native-github-coverage
with:
# Go module directory.
# Default: `.`
working-directory: .
- # Trusted Bash command replacing the default test command. Generate junit.xml and coverage.out for reporting.
+ # Trusted Bash replacement for the default checks. Write supported native reports under CI_REPORTS_DIR; test commands must honor CI_TEST_COVERAGE.
command: ""
# Enable the race detector for the default command. Requires CGO and a C compiler.
# Default: `true`
race: "true"
- # Publication only: `github` (native go tool cover summary), `codecov`, or empty. Collection is controlled by the test command.
- # Default: `github`
- coverage: github
-
- # Outer calling job ID for consolidated ci-reports. Defaults to the current job ID. No individual PR comments are posted.
- report-group: ""
+ # Collect native Go coverage. The default command disables instrumentation when false.
+ # Default: `true`
+ coverage: "true"
```
@@ -97,13 +67,12 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
## Inputs
-| **Input** | **Description** | **Required** | **Default** |
-| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------ | ----------- |
-| **`working-directory`** | Go module directory. | **false** | `.` |
-| **`command`** | Trusted Bash command replacing the default test command. Generate junit.xml and coverage.out for reporting. | **false** | - |
-| **`race`** | Enable the race detector for the default command. Requires CGO and a C compiler. | **false** | `true` |
-| **`coverage`** | Publication only: `github` (native go tool cover summary), `codecov`, or empty. Collection is controlled by the test command. | **false** | `github` |
-| **`report-group`** | Outer calling job ID for consolidated ci-reports. Defaults to the current job ID. No individual PR comments are posted. | **false** | - |
+| **Input** | **Description** | **Required** | **Default** |
+| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | ----------- |
+| **`working-directory`** | Go module directory. | **false** | `.` |
+| **`command`** | Trusted Bash replacement for the default checks. Write supported native reports under CI_REPORTS_DIR; test commands must honor CI_TEST_COVERAGE. | **false** | - |
+| **`race`** | Enable the race detector for the default command. Requires CGO and a C compiler. | **false** | `true` |
+| **`coverage`** | Collect native Go coverage. The default command disables instrumentation when false. | **false** | `true` |
@@ -114,10 +83,9 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
## Outputs
-| **Output** | **Description** |
-| -------------------------- | ------------------------------------------------------------------------------- |
-| **`report-artifact-id`** | Native report artifact ID. Empty when no reports were produced. |
-| **`coverage-artifact-id`** | Native coverage.out artifact ID for GitHub coverage, or empty when unavailable. |
+| **Output** | **Description** |
+| ------------------------ | --------------------------------------------------------------------- |
+| **`report-artifact-id`** | Native report bundle, including available diagnostics after failures. |
@@ -130,28 +98,12 @@ See the [continuous integration workflow](../../.github/workflows/continuous-int
-
-## Contributing
-
-Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-go/blob/main/CONTRIBUTING.md) for more details.
-
-
-## License
-
-This project is licensed under the MIT License.
-
-SPDX-License-Identifier: MIT
-
-Copyright © 2026 hoverkraft
-
-For more details, see the [license](http://choosealicense.com/licenses/mit/).
-
diff --git a/actions/test/action.test.cjs b/actions/test/action.test.cjs
index 25ba88b..6d0b108 100644
--- a/actions/test/action.test.cjs
+++ b/actions/test/action.test.cjs
@@ -3,6 +3,7 @@ const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const {
+ assertCustomCommand,
createWorkspace,
runActionStep,
} = require("../../tests/action-test-helpers.cjs");
@@ -10,22 +11,10 @@ const {
const actionFile = path.join(__dirname, "action.yml");
test("custom commands retain quoting and fail without continuing to default tools", (t) => {
- const directory = createWorkspace(t);
- const output = path.join(directory, "command output.txt");
- const result = runActionStep(actionFile, "run", directory, {
- COMMAND: 'printf "%s" "$VALUE" > "$OUTPUT"\nexit 17',
- OUTPUT: output,
- VALUE: 'quotes " and $(not-executed)',
- });
- assert.equal(result.status, 17, result.stderr);
- assert.notEqual(
- runActionStep(actionFile, "run", directory, { COMMAND: " " }).status,
- 0,
- );
- assert.equal(fs.readFileSync(output, "utf8"), 'quotes " and $(not-executed)');
+ assertCustomCommand(actionFile, t);
});
-test("test configuration rejects unsupported coverage destinations", (t) => {
+test("test configuration rejects non-boolean coverage configuration", (t) => {
const directory = createWorkspace(t);
assert.notEqual(
runActionStep(actionFile, "validate", directory, {
@@ -36,9 +25,41 @@ test("test configuration rejects unsupported coverage destinations", (t) => {
);
assert.equal(
runActionStep(actionFile, "validate", directory, {
- COVERAGE: "",
+ COVERAGE: "true",
RACE: "true",
}).status,
0,
);
});
+
+test("the default command only instruments the primary runtime and writes fresh native outputs", (t) => {
+ const directory = createWorkspace(t);
+ const log = path.join(directory, "arguments.json");
+ fs.writeFileSync(
+ path.join(directory, "go"),
+ `#!/usr/bin/env node\nrequire("node:fs").writeFileSync(process.env.ARGUMENT_LOG,JSON.stringify(process.argv.slice(2)));\n`,
+ { mode: 0o700 },
+ );
+ for (const coverage of ["true", "false"]) {
+ const result = runActionStep(actionFile, "run", directory, {
+ COMMAND: "",
+ RACE: "true",
+ GOTESTSUM_VERSION: "v1.13.0",
+ CI_TEST_COVERAGE: coverage,
+ CI_REPORTS_DIR: path.join(directory, "fresh reports"),
+ PATH: `${directory}:${process.env.PATH}`,
+ ARGUMENT_LOG: log,
+ });
+ assert.equal(result.status, 0, result.stderr);
+ const args = JSON.parse(fs.readFileSync(log, "utf8"));
+ assert.ok(
+ args.includes(`--junitfile=${directory}/fresh reports/junit.xml`),
+ );
+ assert.equal(
+ args.includes(`-coverprofile=${directory}/fresh reports/coverage.out`),
+ coverage === "true",
+ );
+ assert.equal(args.includes("-covermode=atomic"), coverage === "true");
+ assert.ok(args.includes("-race"));
+ }
+});
diff --git a/actions/test/action.yml b/actions/test/action.yml
index 26de574..09483fc 100644
--- a/actions/test/action.yml
+++ b/actions/test/action.yml
@@ -1,36 +1,17 @@
---
name: Test Go
description: |
- Run Go tests with gotestsum, JUnit output and atomic coverage.
+ Run Go tests with detailed JUnit results on every runtime and optional native coverage.
- Defaults enable `-race`, `-count=1` and a five-minute package timeout.
- The race detector requires CGO and a C compiler on a supported Linux runner;
- set `race: "false"` when unavailable. A trusted Bash `command` replaces defaults
- and must produce JUnit for test reporting and `coverage.out` for coverage.
- GitHub coverage uses native `go tool cover` summaries and retains `coverage.out`;
- the common report parser handles JUnit, not the native Go coverage format.
- Native coverage is retained in a separate `go-coverage-*` artifact, so consolidated
- CI reports receive only supported files. Coverage details remain in the test job summary.
+ Run setup-go first. Defaults write junit.xml and coverage.xml into a fresh
+ CI_REPORTS_DIR. Coverage instrumentation is disabled when coverage is false.
+ Supported report files are discovered automatically; no filenames need declaring.
+ Custom commands receive CI_REPORTS_DIR and CI_TEST_COVERAGE.
-
-
-
- Run [setup-go](../setup-go/README.md) first with the same `working-directory`.
-
-
-
- `coverage: "github"` is the default. Set `coverage: "codecov"` and grant the
- job `id-token: write` for OIDC upload of `coverage.out`. An empty coverage
- value disables publication while retaining JUnit; collection is controlled by
- the command. Custom commands must produce the applicable report files.
-
-
-
-
- Native reports survive command failures and are retained for seven days.
- See the [continuous integration workflow](../../.github/workflows/continuous-integration.md#reports-and-permissions) for consolidated reporting and permissions.
-
-
+ Required outputs are validated after success or failure. The default command
+ converts Go coverage to Cobertura with gocover-cobertura. Select publication once
+ in common publish-ci-reports after all jobs; no report outputs need forwarding.
+ Producer jobs require actions: read and contents: read.
author: hoverkraft
branding:
icon: package
@@ -40,29 +21,29 @@ inputs:
description: Go module directory.
default: .
command:
- description: Trusted Bash command replacing the default test command. Generate junit.xml and coverage.out for reporting.
+ description:
+ Trusted Bash replacement for the default checks. Write supported
+ native reports under CI_REPORTS_DIR; test commands must honor
+ CI_TEST_COVERAGE.
default: ""
race:
- description: Enable the race detector for the default command. Requires CGO and a C compiler.
+ description:
+ Enable the race detector for the default command. Requires CGO and
+ a C compiler.
default: "true"
coverage:
- description: "Publication only: `github` (native go tool cover summary), `codecov`, or empty. Collection is controlled by the test command."
- default: github
- report-group:
- description: Outer calling job ID for consolidated ci-reports. Defaults to the current job ID. No individual PR comments are posted.
- default: ""
+ description: Collect native Go coverage. The default command disables
+ instrumentation when false.
+ default: "true"
outputs:
report-artifact-id:
- description: Native report artifact ID. Empty when no reports were produced.
- value: ${{ steps.report-artifact.outputs.artifact-id }}
- coverage-artifact-id:
- description: Native coverage.out artifact ID for GitHub coverage, or empty when unavailable.
- value: ${{ steps.report-artifact.outputs.coverage-artifact-id }}
+ description: Native report bundle, including available diagnostics after failures.
+ value: ${{ steps.reports.outputs.artifact-id }}
runs:
using: composite
steps:
- id: directory
- uses: hoverkraft-tech/ci-github-common/actions/working-directory@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ uses: hoverkraft-tech/ci-github-common/actions/working-directory@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
working-directory: ${{ inputs.working-directory }}
- id: validate
@@ -72,7 +53,33 @@ runs:
COVERAGE: ${{ inputs.coverage }}
run: |
case "$RACE" in true|false) ;; *) echo 'race must be true or false.' >&2; exit 1 ;; esac
- case "$COVERAGE" in github|codecov|'') ;; *) echo 'coverage must be github, codecov or empty.' >&2; exit 1 ;; esac
+ case "$COVERAGE" in true|false) ;; *) echo 'coverage must be true or false.' >&2; exit 1 ;; esac
+ - id: definition
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ env:
+ DIRECTORY: ${{ steps.directory.outputs.workspace-relative-path || '.' }}
+ WORKING_DIRECTORY: ${{ steps.directory.outputs.absolute-path }}
+ GOTOOLCHAIN: local
+ GOWORK: off
+ COVERAGE: ${{ inputs.coverage }}
+ with:
+ script: |
+ const reports = [{kind: 'test'}];
+ if (process.env.COVERAGE === 'true') reports.push({kind: 'coverage', language: 'Go'});
+ const options = {cwd:process.env.WORKING_DIRECTORY,silent:true};
+ const runtime = await exec.getExecOutput('go', ['env','GOVERSION'], options);
+ const modulePath = await exec.getExecOutput('go', ['list','-m','-f','{{.Path}}'], options);
+ core.setOutput('definition', {name:'Go tests',project:process.env.DIRECTORY,variant:{runtime:runtime.stdout.trim()},reports,'path-mapping':{[modulePath.stdout.trim()]:process.env.DIRECTORY}});
+ - id: prepare
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const fs = require('node:fs');
+ const path = require('node:path');
+ core.setOutput('report-directory', fs.mkdtempSync(path.join(process.env.RUNNER_TEMP, 'ci-reports-')));
+ core.setOutput('definition', process.env.REPORT_DEFINITION);
+ env:
+ REPORT_DEFINITION: ${{ steps.definition.outputs.definition }}
- id: run
shell: bash
working-directory: ${{ steps.directory.outputs.absolute-path }}
@@ -83,6 +90,8 @@ runs:
GOTOOLCHAIN: local
GOWORK: "off"
CI: "true"
+ CI_REPORTS_DIR: ${{ steps.prepare.outputs.report-directory }}
+ CI_TEST_COVERAGE: ${{ inputs.coverage }}
run: |
if [ -n "$COMMAND" ] && ! [[ "$COMMAND" =~ [^[:space:]] ]]; then
echo "command must not contain only whitespace." >&2
@@ -92,36 +101,28 @@ runs:
bash --noprofile --norc -e -u -o pipefail -c "$COMMAND"
exit
fi
- args=(-mod=readonly -count=1 -timeout=5m -covermode=atomic -coverprofile=coverage.out)
+ args=(-mod=readonly -count=1 -timeout=5m)
+ if [ "$CI_TEST_COVERAGE" = true ]; then args+=(-covermode=atomic "-coverprofile=$CI_REPORTS_DIR/coverage.out"); fi
if [ "$RACE" = true ]; then args+=(-race); fi
- go run "gotest.tools/gotestsum@$GOTESTSUM_VERSION" --junitfile=junit.xml --format=testname -- "${args[@]}" ./...
- - name: Report test results
- id: report-artifact
- if: ${{ !cancelled() && steps.run.outcome != 'skipped' }}
- uses: $/.github/actions/parse-ci-reports
- with:
- directory: ${{ steps.directory.outputs.absolute-path }}
- report-paths: auto:test
- report-name: Go test results
- group: ${{ inputs.report-group || github.job }}
- native-coverage: ${{ inputs.coverage == 'github' }}
- - id: go-coverage
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
- if: ${{ !cancelled() && steps.run.outcome != 'skipped' && inputs.coverage == 'github' }}
+ go run "gotest.tools/gotestsum@$GOTESTSUM_VERSION" --junitfile="$CI_REPORTS_DIR/junit.xml" --format=testname -- "${args[@]}" ./...
+ - name: Convert Go coverage with gocover-cobertura
+ id: coverage-report
+ if:
+ ${{ !cancelled() && inputs.coverage == 'true' && inputs.command == '' &&
+ steps.prepare.outcome == 'success' }}
+ shell: bash
+ working-directory: ${{ steps.directory.outputs.absolute-path }}
env:
- DIRECTORY: ${{ steps.directory.outputs.absolute-path }}
- with:
- script: |
- const fs = require('node:fs');
- const path = require('node:path');
- const file = path.join(process.env.DIRECTORY, 'coverage.out');
- if (!fs.existsSync(file)) return;
- const result = await exec.getExecOutput('go', ['tool', 'cover', '-func=' + file], {cwd: process.env.DIRECTORY});
- await core.summary.addHeading('Go coverage').addCodeBlock(result.stdout, 'text').write();
- - name: Upload coverage to Codecov
- if: ${{ !cancelled() && steps.run.outcome != 'skipped' && inputs.coverage == 'codecov' }}
- uses: hoverkraft-tech/ci-github-common/actions/quality/codecov@d606f77fad305ef07dfde3db5270f5e324019c97 # 4.2.4
+ REPORT_DIRECTORY: ${{ steps.prepare.outputs.report-directory }}
+ GOTOOLCHAIN: local
+ GOWORK: "off"
+ run: go run github.com/boumenot/gocover-cobertura@v1.5.0 <
+ "$REPORT_DIRECTORY/coverage.out" > "$REPORT_DIRECTORY/coverage.xml"
+ - name: Prepare and retain reports
+ id: reports
+ if: ${{ !cancelled() && steps.prepare.outcome == 'success' }}
+ uses: hoverkraft-tech/ci-github-common/actions/quality/prepare-ci-reports@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0
with:
- working-directory: ${{ steps.directory.outputs.absolute-path }}
- files: coverage.out
- fail-ci-if-error: "true"
+ definition: ${{ steps.prepare.outputs.definition }}
+ directory: ${{ steps.prepare.outputs.report-directory }}
+ outcome: ${{ steps.run.outcome }}
diff --git a/docs/development/README.md b/docs/development/README.md
index c779a66..e9ad0ed 100644
--- a/docs/development/README.md
+++ b/docs/development/README.md
@@ -2,9 +2,8 @@
Install Node.js from `.node-version`, npm, Go, a C compiler and golangci-lint v2, and Docker.
Node.js and the development-only `yaml` dependency exercise the actual inline
-Actions configuration scripts. Lint and test actions share the internal
-[parse-ci-reports action](../../.github/actions/parse-ci-reports/README.md), which owns
-file selection, unique artifact naming and uploads.
+Actions configuration scripts. Lint and test actions use common `prepare-ci-reports` for fresh-file validation,
+execution identity and retention. Native parsers and publication live only in common.
```sh
make setup
@@ -42,8 +41,7 @@ The Node tests execute workflow configuration directly to check matrix selection
disable switches and invalid input.
Action contract tests live beside each action as `action.test.cjs`, including
[setup](../../actions/setup-go/action.test.cjs),
-[lint](../../actions/lint/action.test.cjs), [test](../../actions/test/action.test.cjs)
-and [report parsing](../../.github/actions/parse-ci-reports/action.test.cjs).
+[lint](../../actions/lint/action.test.cjs) and [test](../../actions/test/action.test.cjs).
They execute the actual Bash and JavaScript from adjacent action metadata to
check quoting, failure propagation, setup preconditions and artifact selection.
`make test` discovers these files and the workflow configuration tests.
@@ -56,7 +54,9 @@ Node tests and calls the public workflow with real fixture versions and checks
disabled behavior. `__shared-ci.yml` calls all these test workflows.
The [`ci-github-nodejs` test action](https://github.com/hoverkraft-tech/ci-github-nodejs/tree/main/actions/test)
handles Node setup and dependency caching, installs locked dependencies with
-lifecycle scripts disabled, and runs `test:ci` with the suite path from `arguments`.
+lifecycle scripts disabled, and uses the `node:test` preset with the suite path
+from `arguments`. The preset owns native reporters; packages keep only their
+ordinary test command. These repositories do not generate action distributions.
These GitHub runner/artifact boundaries cannot be covered by local unit tests.
The fixture is deliberately small; it validates action wiring rather than the
language's arithmetic implementation.
@@ -112,3 +112,15 @@ The shared linter uses its bundled Go compiler (`GOTOOLCHAIN=local`) with the
fixture configuration. This keeps its precompiled golangci-lint compatible with
the compiler export format. Dedicated action tests also lint with the project
toolchain and the action's pinned golangci-lint release.
+
+## Reporting boundary
+
+One outer `ci-reports` job publishes all evidence. A separate required `CI complete`
+job calls `check-jobs.yml` to check every producer and reporting. Failed native tests
+fail the producer, while valid reports can still be published successfully.
+Unexpected skips fail the gate. Configure explicitly allowed conditional skips
+in the caller; the reporting workflow owns no skip policy.
+
+The Node contract suites execute inline workflow scripts; they retain JUnit results
+without requesting an empty JavaScript coverage measurement. The language fixture
+collects application coverage on its primary runtime.
diff --git a/package.json b/package.json
index 123924f..6978909 100644
--- a/package.json
+++ b/package.json
@@ -3,8 +3,7 @@
"private": true,
"description": "Development-only tests for GitHub Actions configuration",
"scripts": {
- "test": "node --test tests/*.test.cjs actions/*/*.test.cjs .github/actions/*/*.test.cjs",
- "test:ci": "node --test"
+ "test": "node --test tests/*.test.cjs actions/*/*.test.cjs"
},
"devDependencies": {
"yaml": "2.9.1"
diff --git a/tests/action-test-helpers.cjs b/tests/action-test-helpers.cjs
index ae8c8ca..462d13b 100644
--- a/tests/action-test-helpers.cjs
+++ b/tests/action-test-helpers.cjs
@@ -1,3 +1,4 @@
+const assert = require("node:assert/strict");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
@@ -37,4 +38,25 @@ function runActionStep(actionFile, id, directory, env) {
);
}
-module.exports = { createWorkspace, loadActionStep, runActionStep };
+function assertCustomCommand(actionFile, t) {
+ const directory = createWorkspace(t);
+ const output = path.join(directory, "command output.txt");
+ const result = runActionStep(actionFile, "run", directory, {
+ COMMAND: 'printf "%s" "$VALUE" > "$OUTPUT"\nexit 17',
+ OUTPUT: output,
+ VALUE: 'quotes " and $(not-executed)',
+ });
+ assert.equal(result.status, 17, result.stderr);
+ assert.notEqual(
+ runActionStep(actionFile, "run", directory, { COMMAND: " " }).status,
+ 0,
+ );
+ assert.equal(fs.readFileSync(output, "utf8"), 'quotes " and $(not-executed)');
+}
+
+module.exports = {
+ assertCustomCommand,
+ createWorkspace,
+ loadActionStep,
+ runActionStep,
+};
diff --git a/tests/config.test.cjs b/tests/config.test.cjs
index aecdd55..49c262a 100644
--- a/tests/config.test.cjs
+++ b/tests/config.test.cjs
@@ -31,16 +31,17 @@ async function parse(env = {}) {
return outputs;
}
-test("uses project detection by default and the last explicit version as primary", async () => {
+test("uses project detection by default and the highest explicit version as primary", async () => {
const automatic = await parse();
assert.deepEqual(automatic.versions, [""]);
assert.equal(automatic["primary-version"], "");
- const explicit = await parse({ VERSIONS: '["1.26", "1.27"]' });
- assert.equal(explicit["primary-version"], explicit.versions.at(-1));
+ const explicit = await parse({ VERSIONS: '["1.27", "1.26"]' });
+ assert.equal(explicit["primary-version"], "1.27");
});
test("rejects ambiguous or unbounded version matrices", async () => {
for (const value of [
+ '["", "1.27"]',
"[]",
'["1.2", "1.2"]',
"[1.2]",
@@ -61,17 +62,17 @@ test("disables checks and preserves explicitly supplied command bytes", async ()
}
const command = 'printf "%s\n" "$VALUE"\nexit 17';
const result = await parse({
- TEST: JSON.stringify({ command, coverage: "" }),
+ TEST: JSON.stringify({ command, coverage: false }),
});
assert.equal(JSON.parse(result.test).command, command);
- assert.equal(JSON.parse(result.test).coverage, "");
+ assert.equal(JSON.parse(result.test).coverage, false);
assert.equal(
JSON.parse((await parse({ LINT: "make lint" })).lint).command,
"make lint",
);
});
-test("rejects misspelled options, invalid types and unknown coverage providers", async () => {
+test("rejects misspelled options, invalid types and non-boolean coverage options", async () => {
for (const key of ["LINT", "TEST"]) {
for (const value of [
"{",
@@ -87,7 +88,7 @@ test("rejects misspelled options, invalid types and unknown coverage providers",
);
}
}
- for (const coverage of ["unknown", false, null]) {
+ for (const coverage of ["unknown", "false", null]) {
await assert.rejects(() => parse({ TEST: JSON.stringify({ coverage }) }));
}
});