Skip to content

Commit d7666ec

Browse files
Copilotneilime
authored andcommitted
feat(actions): add package action
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
1 parent 7b1b881 commit d7666ec

File tree

18 files changed

+381
-152
lines changed

18 files changed

+381
-152
lines changed

.github/workflows/__greetings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions: {}
1010

1111
jobs:
1212
greetings:
13-
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
13+
uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
1414
permissions:
1515
contents: read
1616
issues: write

.github/workflows/__need-fix-to-issue.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ permissions: {}
1818

1919
jobs:
2020
main:
21-
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
21+
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
2222
permissions:
2323
contents: read
2424
issues: write

.github/workflows/__semantic-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions: {}
1212

1313
jobs:
1414
main:
15-
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
15+
uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
1616
permissions:
1717
contents: write
1818
pull-requests: write

.github/workflows/__shared-ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions: {}
77

88
jobs:
99
linter:
10-
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
10+
uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
1111
permissions:
1212
contents: read
1313
statuses: write
@@ -35,6 +35,13 @@ jobs:
3535
permissions:
3636
contents: read
3737

38+
test-action-package:
39+
name: Test action "package"
40+
needs: linter
41+
uses: ./.github/workflows/__test-action-package.yml
42+
permissions:
43+
contents: read
44+
3845
test-action-setup-node:
3946
name: Test action "setup-node"
4047
needs: linter

.github/workflows/__stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ permissions: {}
88

99
jobs:
1010
main:
11-
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
11+
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
1212
permissions:
1313
issues: write
1414
pull-requests: write
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Internal - Tests for "package" action
2+
3+
on:
4+
workflow_call:
5+
6+
permissions: {}
7+
8+
jobs:
9+
test:
10+
name: Test "package" (${{ matrix.working-directory }})
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
strategy:
15+
matrix:
16+
include:
17+
- working-directory: tests/npm
18+
artifact-suffix: npm
19+
- working-directory: tests/pnpm
20+
artifact-suffix: pnpm
21+
- working-directory: tests/pnpm-package-manager
22+
artifact-suffix: pnpm-package-manager
23+
- working-directory: tests/yarn
24+
artifact-suffix: yarn
25+
steps:
26+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
28+
- id: package
29+
uses: ./actions/package
30+
with:
31+
working-directory: ${{ matrix.working-directory }}
32+
artifact-name: package-tarball-${{ matrix.artifact-suffix }}
33+
34+
- name: Check "package" outputs
35+
run: |
36+
if [ -z "${{ steps.package.outputs.package-tarball-path }}" ]; then
37+
echo "package-tarball-path output is empty"
38+
exit 1
39+
fi
40+
41+
if [ ! -f "${{ steps.package.outputs.package-tarball-path }}" ]; then
42+
echo "Generated package tarball does not exist"
43+
exit 1
44+
fi
45+
46+
if [ -z "${{ steps.package.outputs.package-tarball-artifact-id }}" ]; then
47+
echo "package-tarball-artifact-id output is empty"
48+
exit 1
49+
fi

.github/workflows/continuous-integration.yml

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ jobs:
293293
security-events: write
294294
runs-on: *ci-runner
295295
steps:
296-
- uses: hoverkraft-tech/ci-github-common/actions/checkout@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
296+
- uses: hoverkraft-tech/ci-github-common/actions/checkout@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
297297
- uses: github/codeql-action/init@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
298298
with:
299299
languages: ${{ inputs.code-ql }}
@@ -306,7 +306,7 @@ jobs:
306306
contents: read
307307
runs-on: *ci-runner
308308
steps:
309-
- uses: hoverkraft-tech/ci-github-common/actions/checkout@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
309+
- uses: hoverkraft-tech/ci-github-common/actions/checkout@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
310310
- uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2
311311

312312
setup:
@@ -327,42 +327,26 @@ jobs:
327327
volumes: ${{ fromJSON(needs.prepare.outputs.container-volumes || '[]') }}
328328
credentials: ${{ fromJSON(needs.prepare.outputs.container-username && format('{{"username":{0},"password":{1}}}',toJSON(needs.prepare.outputs.container-username),toJSON(secrets.container-password)) || '{}') }}
329329
outputs:
330-
working-directory: ${{ steps.working-directory.outputs.working-directory }}
330+
working-directory: ${{ steps.working-directory.outputs.absolute-path }}
331331
build-env: ${{ steps.build-variables.outputs.env }}
332332
build-commands: ${{ steps.build-variables.outputs.commands }}
333333
build-artifact: ${{ steps.build-variables.outputs.artifact }}
334334
steps:
335335
- name: Checkout repository
336336
if: inputs.container == ''
337-
uses: hoverkraft-tech/ci-github-common/actions/checkout@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
337+
uses: hoverkraft-tech/ci-github-common/actions/checkout@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
338338

339339
- id: working-directory
340-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
341-
env:
342-
WORKING_DIRECTORY_INPUT: ${{ inputs.working-directory }}
340+
uses: hoverkraft-tech/ci-github-common/actions/working-directory@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
343341
with:
344-
script: |
345-
const fs = require('node:fs');
346-
const path = require('node:path');
347-
348-
let workingDirectory = process.env.WORKING_DIRECTORY_INPUT || '.';
349-
if (!path.isAbsolute(workingDirectory)) {
350-
workingDirectory = path.join(process.env.GITHUB_WORKSPACE, workingDirectory);
351-
}
352-
353-
if (!fs.existsSync(workingDirectory)) {
354-
core.setFailed(`The specified working directory does not exist: ${workingDirectory}`);
355-
return;
356-
}
357-
workingDirectory = path.resolve(workingDirectory);
358-
core.debug(`Running in working directory: ${workingDirectory}`);
359-
core.setOutput('working-directory', workingDirectory);
342+
working-directory: ${{ inputs.working-directory }}
343+
enforce-path-in-workspace: ${{ inputs.container && 'false' || 'true' }}
360344

361345
- id: build-variables
362346
if: inputs.build != ''
363347
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
364348
env:
365-
WORKING_DIRECTORY: ${{ steps.working-directory.outputs.working-directory }}
349+
WORKING_DIRECTORY: ${{ steps.working-directory.outputs.absolute-path }}
366350
BUILD_INPUT: ${{ inputs.build }}
367351
with:
368352
script: |
@@ -460,11 +444,11 @@ jobs:
460444
packages: read
461445
id-token: write # Needed for getting local workflow actions
462446
steps:
463-
- uses: hoverkraft-tech/ci-github-common/actions/checkout@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
447+
- uses: hoverkraft-tech/ci-github-common/actions/checkout@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
464448
if: inputs.container == ''
465449

466450
- id: local-workflow-actions
467-
uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
451+
uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
468452
with:
469453
actions-path: actions
470454

@@ -500,7 +484,7 @@ jobs:
500484
path-mapping: ${{ needs.prepare.outputs.path-mapping || '' }}
501485

502486
# jscpd:ignore-start
503-
- uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
487+
- uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
504488
if: always() && steps.local-workflow-actions.outputs.repository
505489
with:
506490
actions-path: actions
@@ -523,11 +507,11 @@ jobs:
523507
outputs:
524508
artifact-id: ${{ steps.build.outputs.artifact-id }}
525509
steps:
526-
- uses: hoverkraft-tech/ci-github-common/actions/checkout@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
510+
- uses: hoverkraft-tech/ci-github-common/actions/checkout@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
527511
if: needs.setup.outputs.build-commands && inputs.container == ''
528512

529513
- id: local-workflow-actions
530-
uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
514+
uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
531515
with:
532516
actions-path: actions
533517

@@ -543,7 +527,7 @@ jobs:
543527
build-artifact: ${{ needs.setup.outputs.build-artifact }}
544528

545529
# jscpd:ignore-start
546-
- uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
530+
- uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
547531
if: always() && steps.local-workflow-actions.outputs.repository
548532
with:
549533
actions-path: actions
@@ -566,7 +550,7 @@ jobs:
566550
packages: read
567551
id-token: write # Needed for getting local workflow actions
568552
steps:
569-
- uses: hoverkraft-tech/ci-github-common/actions/checkout@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
553+
- uses: hoverkraft-tech/ci-github-common/actions/checkout@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
570554
if: inputs.container == ''
571555

572556
- if: needs.build.outputs.artifact-id && inputs.container == ''
@@ -576,7 +560,7 @@ jobs:
576560
path: "/"
577561

578562
- id: local-workflow-actions
579-
uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
563+
uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
580564
with:
581565
actions-path: actions
582566

@@ -618,7 +602,7 @@ jobs:
618602
github-token: ${{ secrets.github-token || github.token }}
619603

620604
# jscpd:ignore-start
621-
- uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@4bfbc05c189f1177cf7d47d3060cd1cbddf04ce2 # 0.32.0
605+
- uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
622606
if: always() && steps.local-workflow-actions.outputs.repository
623607
with:
624608
actions-path: actions

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ _Actions for continuous integration steps: build, lint, and test._
2626

2727
#### - [Codecov](actions/codecov/README.md)
2828

29+
#### - [Package](actions/package/README.md)
30+
2931
#### - [Lint](actions/lint/README.md)
3032

3133
#### - [Test](actions/test/README.md)

actions/build/action.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ runs:
7070
# FIXME: workaround until will be merged: https://github.com/actions/runner/pull/1684
7171
run: mkdir -p ./self-build-action/ && cp -r $GITHUB_ACTION_PATH/../* ./self-build-action/
7272

73+
- id: working-directory
74+
uses: hoverkraft-tech/ci-github-common/actions/working-directory@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
75+
with:
76+
working-directory: ${{ inputs.working-directory }}
77+
enforce-path-in-workspace: ${{ inputs.container && 'false' || 'true' }}
78+
7379
- id: setup-node
7480
if: inputs.container != 'true'
7581
uses: ./self-build-action/setup-node
7682
with:
77-
working-directory: ${{ inputs.working-directory }}
83+
working-directory: ${{ steps.working-directory.outputs.absolute-path }}
7884
dependencies-cache: |
7985
nx
8086
gatsby
@@ -86,7 +92,7 @@ runs:
8692
if: inputs.container == 'true'
8793
uses: ./self-build-action/get-package-manager
8894
with:
89-
working-directory: ${{ inputs.working-directory }}
95+
working-directory: ${{ steps.working-directory.outputs.absolute-path }}
9096

9197
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
9298
env:
@@ -122,15 +128,10 @@ runs:
122128
env:
123129
BUILD_COMMANDS: ${{ inputs.build-commands }}
124130
RUN_SCRIPT_COMMAND: ${{ inputs.container == 'true' && steps.get-package-manager.outputs.run-script-command || steps.setup-node.outputs.run-script-command }}
125-
WORKING_DIRECTORY: ${{ inputs.working-directory }}
131+
WORKING_DIRECTORY: ${{ steps.working-directory.outputs.absolute-path }}
126132
with:
127133
script: |
128-
const fs = require('node:fs');
129134
const workingDirectory = process.env.WORKING_DIRECTORY;
130-
if (!fs.existsSync(workingDirectory)) {
131-
core.setFailed(`The specified working directory does not exist: ${workingDirectory}`);
132-
return;
133-
}
134135
core.debug(`Running in working directory: ${workingDirectory}`);
135136
process.chdir(workingDirectory);
136137

actions/codecov/action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ inputs:
2323
runs:
2424
using: "composite"
2525
steps:
26+
- id: working-directory
27+
uses: hoverkraft-tech/ci-github-common/actions/working-directory@f5847cb398fe65d53794e6aba98ebdfa0801f691 # 0.32.0
28+
with:
29+
working-directory: ${{ inputs.working-directory }}
30+
2631
# Check and install dependencies for codecov
2732
- name: Check Codecov dependencies
2833
id: check-codecov-deps
@@ -153,9 +158,9 @@ runs:
153158
- name: 📊 Upload coverage to Codecov
154159
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
155160
with:
156-
directory: ${{ inputs.working-directory }}
157-
root_dir: ${{ inputs.working-directory }}
158-
working-directory: ${{ inputs.working-directory }}
161+
directory: ${{ steps.working-directory.outputs.workspace-relative-path }}
162+
root_dir: ${{ steps.working-directory.outputs.workspace-relative-path }}
163+
working-directory: ${{ steps.working-directory.outputs.workspace-relative-path }}
159164
use_oidc: true
160165
disable_telem: true
161166
fail_ci_if_error: false

0 commit comments

Comments
 (0)