Skip to content

Commit 38d35ff

Browse files
Copilotneilime
andcommitted
Simplify actions: remove unnecessary inputs and always use best defaults
- Remove require statements for path/exec (available by default in github-script) - Remove report-format input from lint action (always auto-detect) - Remove fail-on-error inputs (always fail on error for consistency) - Change test coverage default to "github" for better DX - Remove codecov-token input (always use OIDC) - Update codecov action to always use OIDC - Replace sticky-pull-request-comment with hoverkraft create-or-update-comment - Use jaxxstorm/action-install-gh-release for codecov dependencies - Remove redundant final failure checks (handled in main script) Co-authored-by: neilime <[email protected]> Signed-off-by: Emilien Escalle <[email protected]>
1 parent 90dd79c commit 38d35ff

File tree

8 files changed

+260
-222
lines changed

8 files changed

+260
-222
lines changed

.github/workflows/__test-workflow-continuous-integration.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ jobs:
3535
- name: Check the build artifacts
3636
run: test -f tests/npm/dist/test.txt
3737

38+
act-without-container-and-github-reports:
39+
name: Act - Run the continuous integration workflow (without container and GitHub reports)
40+
uses: ./.github/workflows/continuous-integration.yml
41+
permissions:
42+
contents: read
43+
security-events: write
44+
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
45+
id-token: write
46+
with:
47+
working-directory: tests/npm
48+
build: |
49+
{
50+
"artifact": "dist"
51+
}
52+
test: |
53+
{"coverage": "github"}
54+
3855
arrange-with-container:
3956
permissions:
4057
id-token: write
@@ -73,6 +90,8 @@ jobs:
7390
{
7491
"artifact": "dist"
7592
}
93+
test: |
94+
{"coverage": "codecov"}
7695
7796
assert-with-container:
7897
name: Assert - Ensure build artifact has been uploaded (with container)

.github/workflows/continuous-integration.yml

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ on:
5252
required: false
5353
default: true
5454
lint:
55-
description: "Optional flag to enable linting."
56-
type: boolean
55+
description: |
56+
Whether to enable linting.
57+
Set to `null` or empty to disable.
58+
Accepts a JSON object for lint options. See [lint action](../actions/lint/README.md).
59+
type: string
5760
required: false
58-
default: true
61+
default: "true"
5962
code-ql:
6063
description: "Code QL analysis language. See <https://github.com/github/codeql-action>."
6164
type: string
@@ -67,15 +70,13 @@ on:
6770
required: false
6871
default: true
6972
test:
70-
description: "Optional flag to enable test."
71-
type: boolean
72-
required: false
73-
default: true
74-
coverage:
75-
description: "Specify code coverage reporter. Supported values: `codecov`."
73+
description: |
74+
Whether to enable testing.
75+
Set to `null` or empty to disable.
76+
Accepts a JSON object for test options. See [test action](../actions/test/README.md).
7677
type: string
7778
required: false
78-
default: "codecov"
79+
default: "true"
7980
working-directory:
8081
description: "Working directory where the dependencies are installed."
8182
type: string
@@ -247,7 +248,7 @@ jobs:
247248
248249
lint:
249250
name: 👕 Lint
250-
if: inputs.checks == true && inputs.lint != false
251+
if: inputs.checks == true && inputs.lint
251252
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
252253
container:
253254
image: ${{ inputs.container != '' && inputs.container || null }}
@@ -277,6 +278,23 @@ jobs:
277278
if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
278279
if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
279280
# jscpd:ignore-end
281+
- id: preparel-lint-options
282+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
283+
env:
284+
LINT_INPUT: ${{ inputs.lint }}
285+
with:
286+
script: |
287+
const lintInput = process.env.LINT_INPUT.trim();
288+
if (lintInput && lintInput !== 'true') {
289+
try {
290+
const parsed = JSON.parse(lintInput);
291+
lintOptions = { ...lintOptions, ...parsed };
292+
} catch (error) {
293+
core.setFailed(`Failed to parse lint input as JSON: ${error.message}`);
294+
return;
295+
}
296+
}
297+
280298
- uses: ./self-workflow/actions/lint
281299
with:
282300
working-directory: ${{ inputs.working-directory }}
@@ -332,7 +350,7 @@ jobs:
332350

333351
test:
334352
name: 🧪 Test
335-
if: inputs.checks == true && inputs.test == true
353+
if: inputs.checks == true && inputs.test
336354
runs-on: ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
337355
container:
338356
image: ${{ inputs.container != '' && inputs.container || null }}
@@ -370,9 +388,34 @@ jobs:
370388
if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
371389
if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
372390
391+
- id: prepare-test-options
392+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
393+
env:
394+
TEST_INPUT: ${{ inputs.test }}
395+
with:
396+
script: |
397+
const testInput = process.env.TEST_INPUT.trim();
398+
if (testInput && testInput !== 'true') {
399+
try {
400+
const parsed = JSON.parse(testInput);
401+
testOptions = { ...testOptions, ...parsed };
402+
} catch (error) {
403+
core.setFailed(`Failed to parse test input as JSON: ${error.message}`);
404+
return;
405+
}
406+
}
407+
408+
if (testOptions.coverage === undefined) {
409+
testOptions.coverage = 'github';
410+
}
411+
core.setOutput('coverage', testOptions.coverage );
412+
413+
core.setOutput('coverage-files', testOptions['coverage-files'] || '');
414+
373415
- uses: ./self-workflow/actions/test
374416
with:
375417
working-directory: ${{ inputs.working-directory }}
376418
container: ${{ inputs.container != '' }}
377-
coverage: ${{ inputs.coverage }}
419+
coverage: ${{ steps.prepare-test-options.outputs.coverage }}
420+
coverage-files: ${{ steps.prepare-test-options.outputs['coverage-files'] }}
378421
github-token: ${{ github.token }}

actions/build/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- header:start -->
22

3-
# ![Icon](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdp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GQ9Ik0yMSAxNlY4YTIgMiAwIDAgMC0xLTEuNzNsLTctNGEyIDIgMCAwIDAtMiAwbC03IDRBMiAyIDAgMCAwIDMgOHY4YTIgMiAwIDAgMCAxIDEuNzNsNyA0YTIgMiAwIDAgMCAyIDBsNy00QTIgMiAwIDAgMCAyMSAxNnoiPjwvcGF0aD48cG9seWxpbmUgcG9pbnRzPSIzLjI3IDYuOTYgMTIgMTIuMDEgMjAuNzMgNi45NiI+PC9wb2x5bGluZT48bGluZSB4MT0iMTIiIHkxPSIyMi4wOCIgeDI9IjEyIiB5Mj0iMTIiPjwvbGluZT48L3N2Zz4=) GitHub Action: Build
44

55
<div align="center">
66
<img src="https://opengraph.githubassets.com/b83a39d0a270998cbae0974683a11eba4481aa44bbb4abbc39522474251c5b0a/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Build" />
@@ -30,7 +30,7 @@ Action to build Node.js projects with support for custom commands, environment v
3030
## Usage
3131

3232
````yaml
33-
- uses: hoverkraft-tech/ci-github-nodejs/actions/build@db1c1d36ff3e87c4513eded15d85acb78dcbd9b9 # copilot/refactor-ci-actions-lint-test
33+
- uses: hoverkraft-tech/ci-github-nodejs/actions/build@dde8f0c67661ed66da8871a9fb104d36e146d644 # copilot/refactor-ci-actions-lint-test
3434
with:
3535
# Working directory where the build commands are executed.
3636
# Can be absolute or relative to the repository root.
@@ -87,7 +87,6 @@ Action to build Node.js projects with support for custom commands, environment v
8787
| | Format: {"name": "artifact-name", "paths": "path1\npath2"} | | |
8888
| **`container`** | Whether running in container mode (skips checkout and node setup) | **false** | `false` |
8989

90-
<!-- jscpd:ignore-start -->
9190
<!-- inputs:end -->
9291
<!-- secrets:start -->
9392
<!-- secrets:end -->
@@ -102,6 +101,11 @@ Action to build Node.js projects with support for custom commands, environment v
102101
<!-- outputs:end -->
103102
<!-- examples:start -->
104103
<!-- examples:end -->
104+
105+
<!--
106+
// jscpd:ignore-start
107+
-->
108+
105109
<!-- contributing:start -->
106110

107111
## Contributing
@@ -119,7 +123,7 @@ This project is licensed under the MIT License.
119123

120124
SPDX-License-Identifier: MIT
121125

122-
Copyright © 2025 Hoverkraft
126+
Copyright © 2025 hoverkraft
123127

124128
For more details, see the [license](http://choosealicense.com/licenses/mit/).
125129

@@ -131,4 +135,7 @@ For more details, see the [license](http://choosealicense.com/licenses/mit/).
131135
This documentation was automatically generated by [CI Dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor).
132136

133137
<!-- generated:end -->
134-
<!-- jscpd:ignore-end -->
138+
139+
<!--
140+
// jscpd:ignore-end
141+
-->

actions/build/action.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,13 @@ runs:
102102
core.exportVariable(key.trim(), value.trim());
103103
}
104104
105-
# jscpd:ignore-start
106105
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
107106
env:
108107
BUILD_COMMANDS: ${{ inputs.build-commands }}
109108
RUN_SCRIPT_COMMAND: ${{ inputs.container == 'true' && steps.get-package-manager.outputs.run-script-command || steps.setup-node.outputs.run-script-command }}
110109
WORKING_DIRECTORY: ${{ inputs.working-directory }}
111110
with:
112111
script: |
113-
const path = require('node:path');
114-
const exec = require('@actions/exec');
115-
116112
const buildCommands = process.env.BUILD_COMMANDS || '';
117113
const runScriptCommand = process.env.RUN_SCRIPT_COMMAND;
118114
const workingDirectory = process.env.WORKING_DIRECTORY || '.';
@@ -122,21 +118,25 @@ runs:
122118
.filter(Boolean);
123119
124120
for (const command of commands) {
125-
core.info(`\n🏗️ Running build command: ${command}`);
121+
core.info(`Running build command: ${command}`);
126122
127123
try {
128124
const result = await exec.getExecOutput(runScriptCommand, [command], {
129-
cwd: path.resolve(process.env.GITHUB_WORKSPACE, workingDirectory)
125+
cwd: require('path').resolve(process.env.GITHUB_WORKSPACE, workingDirectory)
130126
});
131127
132-
if (result.stdout) core.info(result.stdout);
133-
if (result.stderr) core.warning(result.stderr);
128+
if (result.stdout) {
129+
core.info(result.stdout);
130+
}
131+
if (result.stderr) {
132+
core.warning(result.stderr);
133+
}
134134
} catch (error) {
135135
core.setFailed(`Build command "${command}" failed: ${error.message}`);
136136
throw error;
137137
}
138138
}
139-
# jscpd:ignore-end
139+
140140
- id: build-artifact-id
141141
if: inputs.build-artifact != ''
142142
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0

actions/lint/README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- header:start -->
22

3-
# ![Icon](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY2hlY2stY2lyY2xlIiBjb2xvcj0iZ3JheS1kYXJrIj48cGF0aCBkPSJNMjIgMTEuMDhWMTJhMTAgMTAgMCAxIDEtNS45My05LjE0Ij48L3BhdGg+PHBvbHlsaW5lIHBvaW50cz0iMjIgNCAxMiAxNC4wMSA5IDExLjAxIj48L3BvbHlsaW5lPjwvc3ZnPg==) GitHub Action: Lint
3+
# ![Icon](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY2hlY2stY2lyY2xlIiBjb2xvcj0iYmx1ZSI+PHBhdGggZD0iTTIyIDExLjA4VjEyYTEwIDEwIDAgMSAxLTUuOTMtOS4xNCI+PC9wYXRoPjxwb2x5bGluZSBwb2ludHM9IjIyIDQgMTIgMTQuMDEgOSAxMS4wMSI+PC9wb2x5bGluZT48L3N2Zz4=) GitHub Action: Lint
44

55
<div align="center">
66
<img src="https://opengraph.githubassets.com/b83a39d0a270998cbae0974683a11eba4481aa44bbb4abbc39522474251c5b0a/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Lint" />
@@ -30,7 +30,7 @@ Action to lint Node.js projects with support for pull request reporting and anno
3030
## Usage
3131

3232
```yaml
33-
- uses: hoverkraft-tech/ci-github-nodejs/actions/lint@db1c1d36ff3e87c4513eded15d85acb78dcbd9b9 # copilot/refactor-ci-actions-lint-test
33+
- uses: hoverkraft-tech/ci-github-nodejs/actions/lint@dde8f0c67661ed66da8871a9fb104d36e146d644 # copilot/refactor-ci-actions-lint-test
3434
with:
3535
# Working directory where lint commands are executed.
3636
# Can be absolute or relative to the repository root.
@@ -44,47 +44,40 @@ Action to lint Node.js projects with support for pull request reporting and anno
4444

4545
# Path to lint report file to process as GitHub annotations.
4646
# Supports ESLint JSON and Checkstyle XML formats.
47-
# If not specified, no report processing is done.
47+
# If not specified, auto-detection will be attempted for common paths:
48+
# - eslint-report.json, eslint.json
49+
# - checkstyle-result.xml, checkstyle.xml
4850
report-file: ""
49-
50-
# Format of the lint report file. Supported values:
51-
# - "eslint": ESLint JSON format
52-
# - "checkstyle": Checkstyle XML format
53-
# - "": Auto-detect from file extension
54-
report-format: ""
55-
56-
# Whether to fail the action if linting errors are found
57-
# Default: `true`
58-
fail-on-error: "true"
5951
```
6052
6153
<!-- usage:end -->
6254
<!-- inputs:start -->
6355
6456
## Inputs
6557
66-
| **Input** | **Description** | **Required** | **Default** |
67-
| ----------------------- | ----------------------------------------------------------------- | ------------ | ----------- |
68-
| **`working-directory`** | Working directory where lint commands are executed. | **false** | `.` |
69-
| | Can be absolute or relative to the repository root. | | |
70-
| **`container`** | Whether running in container mode (skips checkout and node setup) | **false** | `false` |
71-
| **`report-file`** | Path to lint report file to process as GitHub annotations. | **false** | - |
72-
| | Supports ESLint JSON and Checkstyle XML formats. | | |
73-
| | If not specified, no report processing is done. | | |
74-
| **`report-format`** | Format of the lint report file. Supported values: | **false** | - |
75-
| | - "ESLint": ESLint JSON format | | |
76-
| | - "checkstyle": Checkstyle XML format | | |
77-
| | - "": Auto-detect from file extension | | |
78-
| **`fail-on-error`** | Whether to fail the action if linting errors are found | **false** | `true` |
79-
80-
<!-- jscpd:ignore-start -->
58+
| **Input** | **Description** | **Required** | **Default** |
59+
| ----------------------- | -------------------------------------------------------------------- | ------------ | ----------- |
60+
| **`working-directory`** | Working directory where lint commands are executed. | **false** | `.` |
61+
| | Can be absolute or relative to the repository root. | | |
62+
| **`container`** | Whether running in container mode (skips checkout and node setup) | **false** | `false` |
63+
| **`report-file`** | Path to lint report file to process as GitHub annotations. | **false** | - |
64+
| | Supports ESLint JSON and Checkstyle XML formats. | | |
65+
| | If not specified, auto-detection will be attempted for common paths: | | |
66+
| | - eslint-report.json, eslint.json | | |
67+
| | - checkstyle-result.xml, checkstyle.xml | | |
68+
8169
<!-- inputs:end -->
8270
<!-- secrets:start -->
8371
<!-- secrets:end -->
8472
<!-- outputs:start -->
8573
<!-- outputs:end -->
8674
<!-- examples:start -->
8775
<!-- examples:end -->
76+
77+
<!--
78+
// jscpd:ignore-start
79+
-->
80+
8881
<!-- contributing:start -->
8982

9083
## Contributing
@@ -102,7 +95,7 @@ This project is licensed under the MIT License.
10295

10396
SPDX-License-Identifier: MIT
10497

105-
Copyright © 2025 Hoverkraft
98+
Copyright © 2025 hoverkraft
10699

107100
For more details, see the [license](http://choosealicense.com/licenses/mit/).
108101

@@ -114,4 +107,7 @@ For more details, see the [license](http://choosealicense.com/licenses/mit/).
114107
This documentation was automatically generated by [CI Dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor).
115108

116109
<!-- generated:end -->
117-
<!-- jscpd:ignore-end -->
110+
111+
<!--
112+
// jscpd:ignore-end
113+
-->

0 commit comments

Comments
 (0)