5656 Whether to enable linting.
5757 Set to `null` or empty to disable.
5858 Accepts a JSON object for lint options. See [lint action](../actions/lint/README.md).
59-
60- Supported options:
61- - `command`: NPM script to run (default: "lint:ci"). The command should generate lint report files.
62- - `report-file`: Path to lint report file for annotations.
63-
64- Example:
65- ```json
66- {
67- "command": "lint:ci",
68- "report-file": "reports/eslint.json"
69- }
70- ```
7159 type : string
7260 required : false
7361 default : " true"
8674 Whether to enable testing.
8775 Set to `null` or empty to disable.
8876 Accepts a JSON object for test options. See [test action](../actions/test/README.md).
89-
90- Supported options:
91- - `command`: NPM script to run (default: "test:ci"). The command should generate coverage report files.
92- - `coverage`: Coverage reporter ("github", "codecov", or "" for none).
93- - `coverage-files`: Path to coverage files for reporting.
94-
95- Example:
96- ```json
97- {
98- "command": "test:ci",
99- "coverage": "github",
100- "coverage-files": "coverage/cobertura-coverage.xml"
101- }
102- ```
10377 type : string
10478 required : false
10579 default : " true"
@@ -162,14 +136,14 @@ on:
162136 outputs :
163137 build-artifact-id :
164138 description : " ID of the build artifact) uploaded during the build step."
165- value : ${{ jobs.build.outputs.artifact-id }}
139+ value : ${{ jobs.build-host.outputs.artifact-id || jobs.build-container .outputs.artifact-id }}
166140
167141permissions : {}
168142
169143jobs :
170144 prepare :
171145 name : 📦 Prepare configuration
172- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
146+ runs-on : &ci-runner ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
173147 permissions : {}
174148 outputs :
175149 container-image : ${{ steps.parse.outputs.container-image }}
@@ -254,7 +228,7 @@ jobs:
254228 if : inputs.checks == true && inputs.code-ql != ''
255229 permissions :
256230 security-events : write
257- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
231+ runs-on : *ci-runner
258232 steps :
259233 - uses : hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
260234 - uses : github/codeql-action/init@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
@@ -267,32 +241,28 @@ jobs:
267241 if : github.event_name == 'pull_request' && inputs.checks == true && inputs.dependency-review
268242 permissions :
269243 contents : read
270- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
244+ runs-on : *ci-runner
271245 steps :
272246 - uses : hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
273247 - uses : actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2
274248
275- setup :
276- name : ⚙️ Setup
277- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
278- needs : prepare
279- container : &container-setup
280- image : ${{ needs.prepare.outputs.container-image || '' }}
281- env : ${{ fromJSON(needs.prepare.outputs.container-env || '{}') }}
282- options : ${{ needs.prepare.outputs.container-options || ' ' }}
283- ports : ${{ fromJSON(needs.prepare.outputs.container-ports || '[]') }}
284- volumes : ${{ fromJSON(needs.prepare.outputs.container-volumes || '[]') }}
285- credentials : ${{ fromJSON(needs.prepare.outputs.container-username && format('{{"username":{0},"password":{1}}}',toJSON(needs.prepare.outputs.container-username),toJSON(secrets.container-password)) || '{}') }}
249+ setup-host :
250+ if : ${{ inputs.container == '' }}
251+ name : &setup-name ⚙️ Setup
252+ runs-on : *ci-runner
253+ needs :
254+ - prepare
286255 permissions :
287256 contents : read
288257 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
289258 id-token : write
290- outputs :
259+ outputs : &setup-outputs
291260 build-env : ${{ steps.build-variables.outputs.env }}
292261 build-commands : ${{ steps.build-variables.outputs.commands }}
293262 build-artifact : ${{ steps.build-variables.outputs.artifact }}
294- steps :
295- - if : needs.prepare.outputs.container-image == null
263+ steps : &setup-steps
264+ - name : Checkout repository
265+ if : inputs.container == ''
296266 uses : hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
297267
298268 - id : build-variables
@@ -394,22 +364,40 @@ jobs:
394364 core.setOutput('commands', sanitizedCommands.join('\n'));
395365 core.setOutput('env', JSON.stringify(env));
396366
397- lint :
398- name : 👕 Lint
399- if : inputs.checks == true && inputs.lint
367+ setup-container :
368+ if : ${{ inputs.container != '' }}
369+ permissions :
370+ contents : read
371+ # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
372+ id-token : write
373+ needs :
374+ - prepare
375+ container : &ci-container
376+ image : ${{ needs.prepare.outputs.container-image }}
377+ env : ${{ fromJSON(needs.prepare.outputs.container-env || '{}') }}
378+ options : ${{ needs.prepare.outputs.container-options || ' ' }}
379+ ports : ${{ fromJSON(needs.prepare.outputs.container-ports || '[]') }}
380+ volumes : ${{ fromJSON(needs.prepare.outputs.container-volumes || '[]') }}
381+ credentials : ${{ fromJSON(needs.prepare.outputs.container-username && format('{{"username":{0},"password":{1}}}',toJSON(needs.prepare.outputs.container-username),toJSON(secrets.container-password)) || '{}') }}
382+ name : *setup-name
383+ runs-on : *ci-runner
384+ outputs : *setup-outputs
385+ steps : *setup-steps
386+
387+ lint-host :
388+ if : ${{ inputs.checks == true && inputs.lint && inputs.container == '' }}
389+ name : &lint-name 👕 Lint
390+ runs-on : *ci-runner
400391 needs :
401392 - prepare
402- - setup
403- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
404- container : *container-setup
405- # jscpd:ignore-start
393+ - setup-host
406394 permissions :
407395 contents : read
408396 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
409397 id-token : write
410- steps :
398+ steps : &lint-steps
411399 - uses : hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
412- if : needs.prepare.outputs. container-image == null
400+ if : inputs. container == ''
413401
414402 - id : oidc
415403 uses : ChristopherHX/oidc@73eee1ff03fdfce10eda179f617131532209edbd # v3
@@ -423,7 +411,7 @@ jobs:
423411 - run : |
424412 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
425413 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
426- # jscpd:ignore-end
414+
427415 - id : preparel-lint-options
428416 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
429417 env :
@@ -446,93 +434,119 @@ jobs:
446434 core.setOutput('command', lintOptions.command || 'lint:ci');
447435 core.setOutput('report-file', lintOptions['report-file'] || '');
448436
449- - uses : ./self-workflow/actions/lint
437+ - name : Run lint
438+ uses : ./self-workflow/actions/lint
450439 with :
451440 working-directory : ${{ inputs.working-directory }}
452- container : ${{ needs.prepare.outputs. container-image && 'true' || 'false' }}
441+ container : ${{ inputs. container != '' && 'true' || 'false' }}
453442 command : ${{ steps.preparel-lint-options.outputs.command }}
454443 report-file : ${{ steps.preparel-lint-options.outputs.report-file }}
455444
456- - name : 🔄 Rewrite lint report paths (container mode)
457- if : always() && needs.prepare.outputs.container-image
458- uses : ./self-workflow/actions/rewrite-report-paths
459- with :
460- working-directory : ${{ inputs.working-directory }}
461- report-files : |
462- **/*eslint*.json
463- **/*checkstyle*.xml
464- reports/**/*.json
465- reports/**/*.xml
466-
467- build :
468- name : 🏗️ Build
469- if : inputs.checks == true
470- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
471- container : *container-setup
472- # jscpd:ignore-start
445+ lint-container :
446+ if : ${{ inputs.checks == true && inputs.lint && inputs.container != '' }}
447+ permissions :
448+ contents : read
449+ # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
450+ id-token : write
451+ needs :
452+ - prepare
453+ - setup-container
454+ name : *lint-name
455+ runs-on : *ci-runner
456+ container : *ci-container
457+ steps : *lint-steps
458+
459+ build-host :
460+ if : ${{ inputs.checks == true && inputs.container == '' }}
461+ name : &build-name 🏗️ Build
462+ runs-on : *ci-runner
473463 needs :
474464 - prepare
475- - setup
465+ - setup-host
476466 permissions :
477467 contents : read
478468 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
479469 id-token : write
480- outputs :
470+ outputs : &build-outputs
481471 artifact-id : ${{ steps.build.outputs.artifact-id }}
482- steps :
472+ env :
473+ BUILD_COMMANDS : ${{ needs.setup-host.outputs.build-commands }}
474+ BUILD_ENV : ${{ needs.setup-host.outputs.build-env }}
475+ BUILD_ARTIFACT : ${{ needs.setup-host.outputs.build-artifact }}
476+ steps : &build-steps
483477 - uses : hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
484- if : needs.setup.outputs.build-commands && needs.prepare.outputs. container-image == null
478+ if : env.BUILD_COMMANDS && inputs. container == ''
485479
486480 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
487481 - id : oidc
488- if : needs.setup.outputs.build-commands
482+ if : env.BUILD_COMMANDS
489483 uses : ChristopherHX/oidc@73eee1ff03fdfce10eda179f617131532209edbd # v3
490484 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
491- if : needs.setup.outputs.build-commands
485+ if : env.BUILD_COMMANDS
492486 with :
493487 path : ./self-workflow
494488 repository : ${{ steps.oidc.outputs.job_workflow_repo_name_and_owner }}
495489 ref : ${{ steps.oidc.outputs.job_workflow_repo_ref }}
496490 sparse-checkout : |
497491 actions
498- - if : needs.setup.outputs.build-commands
492+ - if : env.BUILD_COMMANDS
499493 run : |
500494 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
501495 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
502- # jscpd:ignore-end
496+
503497 - id : build
504- if : needs.setup.outputs.build-commands
498+ if : env.BUILD_COMMANDS
505499 uses : ./self-workflow/actions/build
506500 with :
501+ container : ${{ inputs.container != '' && 'true' || 'false' }}
507502 working-directory : ${{ inputs.working-directory }}
508- build-commands : ${{ needs.setup.outputs.build-commands }}
509- build-env : ${{ needs.setup.outputs.build-env }}
510503 build-secrets : ${{ secrets.build-secrets }}
511- build-artifact : ${{ needs.setup.outputs.build-artifact }}
512- container : ${{ needs.prepare.outputs.container-image && 'true' || 'false' }}
513-
514- test :
515- name : 🧪 Test
516- if : inputs.checks == true && inputs.test
517- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
518- container : *container-setup
504+ build-commands : ${{ env.BUILD_COMMANDS }}
505+ build-env : ${{ env.BUILD_ENV }}
506+ build-artifact : ${{ env.BUILD_ARTIFACT }}
507+
508+ build-container :
509+ if : ${{ inputs.checks == true && inputs.container != '' }}
510+ permissions :
511+ contents : read
512+ # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
513+ id-token : write
519514 needs :
520515 - prepare
521- - setup
522- - build
516+ - setup-container
517+ env :
518+ BUILD_COMMANDS : ${{ needs.setup-container.outputs.build-commands }}
519+ BUILD_ENV : ${{ needs.setup-container.outputs.build-env }}
520+ BUILD_ARTIFACT : ${{ needs.setup-container.outputs.build-artifact }}
521+ name : *build-name
522+ runs-on : *ci-runner
523+ container : *ci-container
524+ outputs : *build-outputs
525+ steps : *build-steps
526+
527+ test-host :
528+ if : ${{ inputs.checks == true && inputs.test && inputs.container == '' }}
529+ name : &test-name 🧪 Test
530+ runs-on : *ci-runner
531+ needs :
532+ - prepare
533+ - setup-host
534+ - build-host
523535 permissions :
524536 contents : read
525537 pull-requests : write
526538 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
527539 id-token : write
528- steps :
540+ env :
541+ BUILD_ARTIFACT_ID : ${{ needs.build-host.outputs.artifact-id }}
542+ steps : &test-steps
529543 - uses : hoverkraft-tech/ci-github-common/actions/checkout@753288393de1f3d92f687a6761d236ca800f5306 # 0.28.1
530- if : needs.prepare.outputs. container-image == null
544+ if : inputs. container == ''
531545
532- - if : needs.build.outputs.artifact-id && needs.prepare.outputs. container-image == null
546+ - if : env.BUILD_ARTIFACT_ID && inputs. container == ''
533547 uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
534548 with :
535- artifact-ids : ${{ needs.build.outputs.artifact-id }}
549+ artifact-ids : ${{ env.BUILD_ARTIFACT_ID }}
536550 path : " /"
537551
538552 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
@@ -575,22 +589,30 @@ jobs:
575589 core.setOutput('coverage-files', testOptions['coverage-files'] || '');
576590 core.setOutput('command', testOptions.command || 'test:ci');
577591
578- - uses : ./self-workflow/actions/test
592+ - name : Run tests
593+ uses : ./self-workflow/actions/test
579594 with :
580595 working-directory : ${{ inputs.working-directory }}
581- container : ${{ needs.prepare.outputs. container-image && 'true' || 'false' }}
596+ container : ${{ inputs. container != '' && 'true' || 'false' }}
582597 command : ${{ steps.prepare-test-options.outputs.command }}
583598 coverage : ${{ steps.prepare-test-options.outputs.coverage }}
584599 coverage-files : ${{ steps.prepare-test-options.outputs.coverage-files }}
585600 github-token : ${{ github.token }}
586601
587- - name : 🔄 Rewrite coverage report paths (container mode)
588- if : always() && needs.prepare.outputs.container-image
589- uses : ./self-workflow/actions/rewrite-report-paths
590- with :
591- working-directory : ${{ inputs.working-directory }}
592- report-files : |
593- coverage/**/*.xml
594- coverage/**/*.info
595- coverage/**/*.json
596- test-results/**/*.xml
602+ test-container :
603+ if : ${{ inputs.checks == true && inputs.test && inputs.container != '' }}
604+ needs :
605+ - prepare
606+ - setup-container
607+ - build-container
608+ permissions :
609+ contents : read
610+ pull-requests : write
611+ # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
612+ id-token : write
613+ env :
614+ BUILD_ARTIFACT_ID : ${{ needs.build-container.outputs.artifact-id }}
615+ name : *test-name
616+ runs-on : *ci-runner
617+ container : *ci-container
618+ steps : *test-steps
0 commit comments