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+ It should generate lint reports in standard formats.
60+
61+ Example:
62+
63+ ```json:package.json
64+ {
65+ "lint:ci": "eslint . --output-file eslint-report.json --format json"
66+ }
67+ ```
5968 type : string
6069 required : false
6170 default : " true"
7988 Whether to enable testing.
8089 Set to `null` or empty to disable.
8190 Accepts a JSON object for test options. See [test action](../actions/test/README.md).
91+ If coverage is enabled, it should generate test and coverage reports in standard formats.
92+
93+ Example:
94+
95+ ```json:package.json
96+ {
97+ "test:ci": "vitest run --reporter=default --reporter=junit --outputFile=junit.xml --coverage.enabled --coverage.reporter=lcov --coverage.reporter=text"
98+ }
99+ ```
82100 type : string
83101 required : false
84102 default : " true"
111129 "volumes": ["/tmp:/tmp", "/cache:/cache"],
112130 "credentials": {
113131 "username": "myusername"
132+ },
133+ pathMapping: {
134+ "/app": "./relative/path/to/app"
114135 }
115136 }
116137 ```
123144 - `ports` (array)
124145 - `volumes` (array)
125146 - `credentials` (object with `username`).
147+ - `pathMapping` (object) path mapping from container paths to repository paths. Defaults is working directory is mapped with repository root.
126148
127149 See https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container.
128150
@@ -171,12 +193,14 @@ jobs:
171193 container-ports : ${{ steps.parse.outputs.container-ports }}
172194 container-volumes : ${{ steps.parse.outputs.container-volumes }}
173195 container-username : ${{ steps.parse.outputs.container-username }}
196+ path-mapping : ${{ steps.parse.outputs.path-mapping }}
174197 steps :
175198 - id : parse
176199 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
177200 env :
178201 CONTAINER_INPUT : ${{ inputs.container }}
179202 CONTAINER_PASSWORD : ${{ secrets.container-password }}
203+ WORKING_DIRECTORY : ${{ inputs.working-directory }}
180204 with :
181205 script : |
182206 const containerInput = process.env.CONTAINER_INPUT.trim();
@@ -192,16 +216,26 @@ jobs:
192216 options: '--user root:root'
193217 };
194218
219+ let pathMapping = {
220+ [process.env.WORKING_DIRECTORY || '.']: process.env.GITHUB_WORKSPACE,
221+ };
222+
195223 if (isJson) {
196224 try {
197- const parsedContainer = JSON.parse(containerInput);
225+ const {pathMapping: parsedPathMapping, ... parsedContainer} = JSON.parse(containerInput);
198226 core.debug(`Parsed container input as JSON: ${JSON.stringify(parsedContainer)}`);
227+
199228 container = {
200229 ...container,
201230 ...parsedContainer,
202231 options: `${container.options} ${parsedContainer.options || ''}`.trim()
203232 };
204233
234+ core.debug(`Parsed path mapping: ${JSON.stringify(parsedPathMapping)}`);
235+ if (parsedPathMapping){
236+ pathMapping = parsedPathMapping;
237+ }
238+
205239 } catch (error) {
206240 return core.setFailed(`Failed to parse container input as JSON: ${error.message}`,{ cause: error });
207241 }
@@ -242,6 +276,16 @@ jobs:
242276 return core.setFailed('Container credentials username must be provided when container password is specified.');
243277 }
244278
279+ core.debug(`Parsed path mapping: ${JSON.stringify(pathMapping)}`);
280+ if (!pathMapping || typeof pathMapping !== 'object' || Object.keys(pathMapping).length === 0){
281+ return core.setFailed('At least one path mapping must be specified in the container configuration.');
282+ }
283+
284+ core.setOutput('path-mapping', Object.entries(pathMapping).reduce((acc, [containerPath, repoPath]) => {
285+ acc += `${acc?',' : ''}${containerPath}:${repoPath}`;
286+ return acc;
287+ }, ""));
288+
245289 code-ql :
246290 name : 🛡️ CodeQL Analysis
247291 if : inputs.checks == true && inputs.code-ql != ''
@@ -449,6 +493,7 @@ jobs:
449493 container : ${{ inputs.container != '' && 'true' || 'false' }}
450494 command : ${{ steps.preparel-lint-options.outputs.command }}
451495 report-file : ${{ steps.preparel-lint-options.outputs.report-file }}
496+ path-mapping : ${{ needs.prepare.outputs.path-mapping || '' }}
452497
453498 build :
454499 if : inputs.checks == true
@@ -559,7 +604,7 @@ jobs:
559604 testOptions.coverage = 'github';
560605 }
561606 core.setOutput('coverage', testOptions.coverage );
562- core.setOutput('coverage-files ', testOptions['coverage-files '] || '');
607+ core.setOutput('report-file ', testOptions['report-file '] || '');
563608 core.setOutput('command', testOptions.command || 'test:ci');
564609
565610 - name : Run tests
@@ -569,5 +614,6 @@ jobs:
569614 container : ${{ inputs.container != '' && 'true' || 'false' }}
570615 command : ${{ steps.prepare-test-options.outputs.command }}
571616 coverage : ${{ steps.prepare-test-options.outputs.coverage }}
572- coverage-files : ${{ steps.prepare-test-options.outputs.coverage-files }}
617+ report-file : ${{ steps.prepare-test-options.outputs.report-file }}
618+ path-mapping : ${{ needs.prepare.outputs.path-mapping || '' }}
573619 github-token : ${{ secrets.github-token || github.token }}
0 commit comments