Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/__test-action-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ jobs:
fs.writeFileSync('lint-fixture/lint.cjs', `
require('node:fs').writeFileSync('command-ran.txt', 'lint ran');
if (process.env.WRITE_REPORT === 'true') {
require('node:fs').writeFileSync('eslint-report.json', '[]');
require('node:fs').writeFileSync('eslint-report.json', JSON.stringify([
{ filePath: 'src/index.js', messages: [], errorCount: 0, warningCount: 0 },
]));
}
process.exit(process.env.EXPECT_FAILURE === 'true' ? 1 : 0);
`);
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/__test-action-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
reports: true
report-file: ".reports/junit.xml,.reports/missing.xml"
expected: failure
artifact: false
artifact: true
artifact-files: '["junit.xml"]'
- scenario: no automatic reports
failure: false
reports: false
Expand Down Expand Up @@ -101,6 +102,7 @@ jobs:
EXPECT_REPORTS: ${{ matrix.reports }}
EXPECT_FAILURE: ${{ matrix.failure }}
ARTIFACT_ID: ${{ steps.test.outputs.report-artifact-id }}
ARTIFACT_FILES: ${{ matrix.artifact-files || '["junit.xml","lcov.info"]' }}
with:
script: |
const assert = require('node:assert/strict');
Expand All @@ -116,7 +118,10 @@ jobs:
assert.match(process.env.ARTIFACT_ID, /^\d+$/);
const globber = await glob.create('downloaded-reports/**/*', { matchDirectories: false });
const files = await globber.glob();
assert.equal(files.length, 2);
const expectedFiles = JSON.parse(process.env.ARTIFACT_FILES);
assert.deepEqual(files.map(file => require('node:path').basename(file)).sort(), expectedFiles.sort());
const junit = fs.readFileSync(files.find(file => file.endsWith('junit.xml')), 'utf8');
assert.equal(junit.includes('<failure'), process.env.EXPECT_FAILURE === 'true');
assert.match(fs.readFileSync(files.find(file => file.endsWith('lcov.info')), 'utf8'), /SF:/);
if (expectedFiles.includes('lcov.info')) {
assert.match(fs.readFileSync(files.find(file => file.endsWith('lcov.info')), 'utf8'), /SF:/);
}
15 changes: 14 additions & 1 deletion .github/workflows/__test-workflow-continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ jobs:
"artifact": "dist"
}
test: |
{"coverage": "github"}
{"comment": false, "report-group": "act-without-container-and-github-reports"}
# jscpd:ignore-end

assert-package-disabled:
Expand All @@ -302,6 +302,19 @@ jobs:
- env:
PACKAGE_ARTIFACT_ID: ${{ needs.act-without-container-and-github-reports.outputs.package-tarball-artifact-id }}
run: test -z "$PACKAGE_ARTIFACT_ID"
- name: Retrieve coverage by the outer calling job ID
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: ci-reports-${{ github.run_attempt }}-act-without-container-and-github-reports-*
path: native-reports
- name: Check that consolidated reporting can find the native coverage
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const assert = require('node:assert/strict');
const files = await (await glob.create('native-reports/**/lcov.info')).glob();
assert.equal(files.length, 1);
assert.match(require('node:fs').readFileSync(files[0], 'utf8'), /SF:/);

arrange-with-container:
name: Arrange - Build container image for CI workflow
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/continuous-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# GitHub Reusable Workflow: Node.js Continuous Integration

<div align="center">
<img src="https://opengraph.githubassets.com/798861777139bae96adc7ee652339a4713d1b50ce3b11cfb3ce6c363f2339b53/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Node.js Continuous Integration" />
<img src="https://opengraph.githubassets.com/7e9813f9e19bd5adf686a5ff854c41da9068e2fb45a0d01f3d74b94a77ffe027/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Node.js Continuous Integration" />
</div>

---
Expand All @@ -16,7 +16,6 @@
[![License](https://img.shields.io/github/license/hoverkraft-tech/ci-github-nodejs)](http://choosealicense.com/licenses/mit/)
[![Stars](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-nodejs?style=social)](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-nodejs?style=social)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/hoverkraft-tech/ci-github-nodejs/blob/main/CONTRIBUTING.md)
![GitHub Verified Creator](https://img.shields.io/badge/GitHub-Verified%20Creator-4493F8?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJyZ2IoNjgsIDE0NywgMjQ4KSI+CiAgPHBhdGggZD0ibTkuNTg1LjUyLjkyOS42OGMuMTUzLjExMi4zMzEuMTg2LjUxOC4yMTVsMS4xMzguMTc1YTIuNjc4IDIuNjc4IDAgMCAxIDIuMjQgMi4yNGwuMTc0IDEuMTM5Yy4wMjkuMTg3LjEwMy4zNjUuMjE1LjUxOGwuNjguOTI4YTIuNjc3IDIuNjc3IDAgMCAxIDAgMy4xN2wtLjY4LjkyOGExLjE3NCAxLjE3NCAwIDAgMC0uMjE1LjUxOGwtLjE3NSAxLjEzOGEyLjY3OCAyLjY3OCAwIDAgMS0yLjI0MSAyLjI0MWwtMS4xMzguMTc1YTEuMTcgMS4xNyAwIDAgMC0uNTE4LjIxNWwtLjkyOC42OGEyLjY3NyAyLjY3NyAwIDAgMS0zLjE3IDBsLS45MjgtLjY4YTEuMTc0IDEuMTc0IDAgMCAwLS41MTgtLjIxNUwzLjgzIDE0LjQxYTIuNjc4IDIuNjc4IDAgMCAxLTIuMjQtMi4yNGwtLjE3NS0xLjEzOGExLjE3IDEuMTcgMCAwIDAtLjIxNS0uNTE4bC0uNjgtLjkyOGEyLjY3NyAyLjY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c1IDAgMCAxLTEuMDYgMEw0LjcyIDguNzhhLjc1MS43NTEgMCAwIDEgLjAxOC0xLjA0Mi43NTEuNzUxIDAgMCAxIDEuMDQyLS4wMThMNyA4Ljk0bDMuMjItMy4yMmEuNzUxLjc1MSAwIDAgMSAxLjA0Mi4wMTguNzUxLjc1MSAwIDAgMSAuMDE4IDEuMDQyWiI+PC9wYXRoPgo8L3N2Zz4K)

<!-- badges:end -->

Expand Down Expand Up @@ -193,6 +192,8 @@ jobs:
# Set to `null` or empty to disable.
# Accepts a JSON object for test options. See [test action](../../actions/test/README.md).
# If coverage is enabled, it should generate test and coverage reports in standard formats.
# For consolidated reports, set `comment` to false and `report-group` to the calling job ID
# used in the common `ci-reports` workflow's `job-results`.
#
# Example:
#
Expand Down Expand Up @@ -326,6 +327,8 @@ jobs:
| | Set to `null` or empty to disable. | | | |
| | Accepts a JSON object for test options. See [test action](../../actions/test/README.md). | | | |
| | If coverage is enabled, it should generate test and coverage reports in standard formats. | | | |
| | For consolidated reports, set `comment` to false and `report-group` to the calling job ID | | | |
| | used in the common `ci-reports` workflow's `job-results`. | | | |
| | | | | |
| | Example: | | | |
| | | | | |
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ on:
Set to `null` or empty to disable.
Accepts a JSON object for test options. See [test action](../../actions/test/README.md).
If coverage is enabled, it should generate test and coverage reports in standard formats.
For consolidated reports, set `comment` to false and `report-group` to the calling job ID
used in the common `ci-reports` workflow's `job-results`.

Example:

Expand Down Expand Up @@ -680,7 +682,16 @@ jobs:
if (testOptions.coverage === undefined) {
testOptions.coverage = 'github';
}
if (testOptions.comment !== undefined && typeof testOptions.comment !== 'boolean') {
throw new Error('test.comment must be a boolean.');
}
if (testOptions['report-group'] !== undefined &&
(typeof testOptions['report-group'] !== 'string' || !/^[\w-]+$/.test(testOptions['report-group']))) {
throw new Error('test.report-group must be a job ID containing letters, numbers, underscores or hyphens.');
}
core.setOutput('coverage', testOptions.coverage );
core.setOutput('comment', testOptions.comment ?? true);
core.setOutput('report-group', testOptions['report-group'] || '');
core.setOutput('report-file', testOptions['report-file'] || '');
core.setOutput('command', testOptions.command || 'test:ci');

Expand All @@ -692,6 +703,8 @@ jobs:
container: ${{ inputs.container != '' && 'true' || 'false' }}
command: ${{ steps.prepare-test-options.outputs.command }}
coverage: ${{ steps.prepare-test-options.outputs.coverage }}
comment: ${{ steps.prepare-test-options.outputs.comment }}
report-group: ${{ steps.prepare-test-options.outputs.report-group }}
report-file: ${{ steps.prepare-test-options.outputs.report-file }}
path-mapping: ${{ needs.prepare.outputs.path-mapping || '' }}
github-token: ${{ secrets.github-token || github.token }}
Expand Down
13 changes: 10 additions & 3 deletions actions/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ![Icon](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY2hlY2stc3F1YXJlIiBjb2xvcj0iYmx1ZSI+PHBvbHlsaW5lIHBvaW50cz0iOSAxMSAxMiAxNCAyMiA0Ij48L3BvbHlsaW5lPjxwYXRoIGQ9Ik0yMSAxMnY3YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0yVjVhMiAyIDAgMCAxIDItMmgxMSI+PC9wYXRoPjwvc3ZnPg==) GitHub Action: Test

<div align="center">
<img src="https://opengraph.githubassets.com/798861777139bae96adc7ee652339a4713d1b50ce3b11cfb3ce6c363f2339b53/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Test" />
<img src="https://opengraph.githubassets.com/7e9813f9e19bd5adf686a5ff854c41da9068e2fb45a0d01f3d74b94a77ffe027/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Test" />
</div>

---
Expand All @@ -16,7 +16,6 @@
[![License](https://img.shields.io/github/license/hoverkraft-tech/ci-github-nodejs)](http://choosealicense.com/licenses/mit/)
[![Stars](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-nodejs?style=social)](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-nodejs?style=social)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/hoverkraft-tech/ci-github-nodejs/blob/main/CONTRIBUTING.md)
![GitHub Verified Creator](https://img.shields.io/badge/GitHub-Verified%20Creator-4493F8?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJyZ2IoNjgsIDE0NywgMjQ4KSI+CiAgPHBhdGggZD0ibTkuNTg1LjUyLjkyOS42OGMuMTUzLjExMi4zMzEuMTg2LjUxOC4yMTVsMS4xMzguMTc1YTIuNjc4IDIuNjc4IDAgMCAxIDIuMjQgMi4yNGwuMTc0IDEuMTM5Yy4wMjkuMTg3LjEwMy4zNjUuMjE1LjUxOGwuNjguOTI4YTIuNjc3IDIuNjc3IDAgMCAxIDAgMy4xN2wtLjY4LjkyOGExLjE3NCAxLjE3NCAwIDAgMC0uMjE1LjUxOGwtLjE3NSAxLjEzOGEyLjY3OCAyLjY3OCAwIDAgMS0yLjI0MSAyLjI0MWwtMS4xMzguMTc1YTEuMTcgMS4xNyAwIDAgMC0uNTE4LjIxNWwtLjkyOC42OGEyLjY3NyAyLjY3NyAwIDAgMS0zLjE3IDBsLS45MjgtLjY4YTEuMTc0IDEuMTc0IDAgMCAwLS41MTgtLjIxNUwzLj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NzRhMi42NzcgMi42NzcgMCAwIDEtMS4xOC0uNDg5bC0uOTI4LS42OGExLjE3NiAxLjE3NiAwIDAgMC0xLjM5NCAwWk0xMS4yOCA2Ljc4bC0zLjc1IDMuNzVhLjc1Ljc1IDAgMCAxLTEuMDYgMEw0LjcyIDguNzhhLjc1MS43NTEgMCAwIDEgLjAxOC0xLjA0Mi43NTEuNzUxIDAgMCAxIDEuMDQyLS4wMThMNyA4Ljk0bDMuMjItMy4yMmEuNzUxLjc1MSAwIDAgMSAxLjA0Mi4wMTguNzUxLjc1MSAwIDAgMSAuMDE4IDEuMDQyWiI+PC9wYXRoPgo8L3N2Zz4K)

<!-- badges:end -->

Expand Down Expand Up @@ -46,7 +45,7 @@ permissions:
## Usage

```yaml
- uses: hoverkraft-tech/ci-github-nodejs/actions/test@0340fba99303d160fd476ff1e7766125b632dcf9 # ci/adopt-common-3
- uses: hoverkraft-tech/ci-github-nodejs/actions/test@02a04ad25ceaacdf3b7200e45fb7fec07fadf4fa # 2.1.0
with:
# Disable project and dependency lifecycle scripts during installation.
# Set false to allow installation hooks, subject to the package manager's script approval settings.
Expand Down Expand Up @@ -100,6 +99,11 @@ permissions:
# Default: `true`
comment: "true"

# Job ID used to associate native reports with the common ci-reports workflow's job-results.
# Defaults to the current job ID. Set the outer calling job ID for nested reusable workflows.
# Matrix runs keep separate artifacts labeled with their working directory.
report-group: ""

# GitHub token for coverage PR comments.
# Required when coverage is `github` and individual comments are enabled.
# Requires permissions to create and update PR comments:
Expand Down Expand Up @@ -142,6 +146,9 @@ permissions:
| **`path-mapping`** | Optional path mapping to adjust file paths in test and coverage reports. | **false** | - |
| | See the [parse-ci-reports documentation](https://github.com/hoverkraft-tech/ci-github-common/tree/main/actions/quality/parse-ci-reports) for details. | | |
| **`comment`** | Publish an individual coverage PR comment. Set false when using the common ci-reports workflow; GitHub summaries and report artifacts remain enabled. | **false** | `true` |
| **`report-group`** | Job ID used to associate native reports with the common ci-reports workflow's job-results. | **false** | - |
| | Defaults to the current job ID. Set the outer calling job ID for nested reusable workflows. | | |
| | Matrix runs keep separate artifacts labeled with their working directory. | | |
| **`github-token`** | GitHub token for coverage PR comments. | **false** | - |
| | Required when coverage is `github` and individual comments are enabled. | | |
| | Requires permissions to create and update PR comments: | | |
Expand Down
Loading
Loading