Skip to content

Commit a939c2b

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 a939c2b

File tree

11 files changed

+269
-228
lines changed

11 files changed

+269
-228
lines changed

.github/workflows/__main-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
actions: read
2525
contents: read
2626
packages: write
27-
pull-requests: read
27+
pull-requests: write
2828
id-token: write
2929
issues: read
3030
security-events: write

.github/workflows/__pull-request-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
actions: read
1919
contents: read
2020
packages: write
21-
pull-requests: read
21+
pull-requests: write
2222
id-token: write
2323
issues: read
2424
security-events: write

.github/workflows/__shared-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
permissions:
5050
contents: read
5151
packages: write
52-
pull-requests: read
52+
pull-requests: write
5353
id-token: write
5454
issues: read
5555
security-events: write

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
uses: ./.github/workflows/continuous-integration.yml
1212
permissions:
1313
contents: read
14+
pull-requests: write
1415
security-events: write
1516
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
1617
id-token: write
@@ -35,6 +36,24 @@ jobs:
3536
- name: Check the build artifacts
3637
run: test -f tests/npm/dist/test.txt
3738

39+
act-without-container-and-github-reports:
40+
name: Act - Run the continuous integration workflow (without container and GitHub reports)
41+
uses: ./.github/workflows/continuous-integration.yml
42+
permissions:
43+
contents: read
44+
pull-requests: write
45+
security-events: write
46+
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
47+
id-token: write
48+
with:
49+
working-directory: tests/npm
50+
build: |
51+
{
52+
"artifact": "dist"
53+
}
54+
test: |
55+
{"coverage": "github"}
56+
3857
arrange-with-container:
3958
permissions:
4059
id-token: write
@@ -63,6 +82,7 @@ jobs:
6382
needs: arrange-with-container
6483
permissions:
6584
contents: read
85+
pull-requests: write
6686
security-events: write
6787
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
6888
id-token: write
@@ -73,6 +93,8 @@ jobs:
7393
{
7494
"artifact": "dist"
7595
}
96+
test: |
97+
{"coverage": "codecov"}
7698
7799
assert-with-container:
78100
name: Assert - Ensure build artifact has been uploaded (with container)

.github/workflows/continuous-integration.yml

Lines changed: 57 additions & 14 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 }}
@@ -343,9 +361,9 @@ jobs:
343361
- build
344362
permissions:
345363
contents: read
364+
pull-requests: write
346365
# FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
347366
id-token: write
348-
pull-requests: write
349367
steps:
350368
- uses: hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
351369
if: inputs.container == ''
@@ -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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIy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yA0YTIgMiAwIDAgMCAyIDBsNy00QTIgMiAwIDAgMCAyMSAxNnoiPjwvcGF0aD48cG9seWxpbmUgcG9pbnRzPSIzLjI3IDYuOTYgMTIgMTIuMDEgMjAuNzMgNi45NiI+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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ inputs:
2828
Multi-line string of secrets in env format (KEY=VALUE).
2929
Example:
3030
```
31-
SECRET_KEY=${{ secrets.SECRET_KEY }}
32-
API_TOKEN=${{ secrets.API_TOKEN }}
31+
SECRET_KEY=$\{{ secrets.SECRET_KEY }}
32+
API_TOKEN=$\{{ secrets.API_TOKEN }}
3333
```
3434
required: false
3535
default: ""
@@ -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

0 commit comments

Comments
 (0)