Skip to content

Commit 578fa89

Browse files
authored
Add docker/action.yml to allow setting docker registry and image (#688)
Fixes #685.
1 parent 45cb788 commit 578fa89

File tree

8 files changed

+598
-141
lines changed

8 files changed

+598
-141
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
load: true
7676
push: false
7777
platforms: linux/${{ matrix.arch }}
78-
tags: enricomi/publish-unit-test-result-action:latest
78+
tags: local/enricomi/publish-unit-test-result-action:latest
7979
outputs: type=docker
8080
env:
8181
DOCKER_BUILD_RECORD_UPLOAD: false
@@ -88,110 +88,17 @@ jobs:
8888
- name: Publish Test Results
8989
id: test-results
9090
if: (!cancelled())
91-
env:
92-
INPUT_GITHUB_TOKEN: ${{ github.token }}
93-
INPUT_CHECK_NAME: Test Results (Docker Image ${{ matrix.arch }})
94-
INPUT_FILES: "artifacts/**/*.xml"
95-
INPUT_JSON_FILE: "tests.json"
96-
INPUT_JSON_SUITE_DETAILS: true
97-
INPUT_JSON_TEST_CASE_RESULTS: true
98-
INPUT_REPORT_SUITE_LOGS: "any"
99-
run: |
100-
docker run --platform linux/${{ matrix.arch }} \
101-
--workdir $GITHUB_WORKSPACE \
102-
--rm \
103-
-e "INPUT_CHECK_NAME" \
104-
-e "INPUT_JSON_FILE" \
105-
-e "INPUT_JSON_SUITE_DETAILS" \
106-
-e "INPUT_JSON_TEST_CASE_RESULTS" \
107-
-e "INPUT_LOG_LEVEL" \
108-
-e "INPUT_ROOT_LOG_LEVEL" \
109-
-e "INPUT_GITHUB_TOKEN" \
110-
-e "INPUT_GITHUB_RETRIES" \
111-
-e "INPUT_SSL_VERIFY" \
112-
-e "INPUT_COMMIT" \
113-
-e "INPUT_COMMENT_TITLE" \
114-
-e "INPUT_COMMENT_MODE" \
115-
-e "INPUT_FAIL_ON" \
116-
-e "INPUT_ACTION_FAIL" \
117-
-e "INPUT_ACTION_FAIL_ON_INCONCLUSIVE" \
118-
-e "INPUT_FILES" \
119-
-e "INPUT_JUNIT_FILES" \
120-
-e "INPUT_NUNIT_FILES" \
121-
-e "INPUT_XUNIT_FILES" \
122-
-e "INPUT_TRX_FILES" \
123-
-e "INPUT_TIME_UNIT" \
124-
-e "INPUT_TEST_FILE_PREFIX" \
125-
-e "INPUT_REPORT_INDIVIDUAL_RUNS" \
126-
-e "INPUT_REPORT_SUITE_LOGS" \
127-
-e "INPUT_DEDUPLICATE_CLASSES_BY_FILE_NAME" \
128-
-e "INPUT_LARGE_FILES" \
129-
-e "INPUT_IGNORE_RUNS" \
130-
-e "INPUT_CHECK_RUN" \
131-
-e "INPUT_JOB_SUMMARY" \
132-
-e "INPUT_COMPARE_TO_EARLIER_COMMIT" \
133-
-e "INPUT_PULL_REQUEST_BUILD" \
134-
-e "INPUT_EVENT_FILE" \
135-
-e "INPUT_EVENT_NAME" \
136-
-e "INPUT_TEST_CHANGES_LIMIT" \
137-
-e "INPUT_CHECK_RUN_ANNOTATIONS" \
138-
-e "INPUT_CHECK_RUN_ANNOTATIONS_BRANCH" \
139-
-e "INPUT_SECONDS_BETWEEN_GITHUB_READS" \
140-
-e "INPUT_SECONDS_BETWEEN_GITHUB_WRITES" \
141-
-e "INPUT_SECONDARY_RATE_LIMIT_WAIT_SECONDS" \
142-
-e "INPUT_JSON_THOUSANDS_SEPARATOR" \
143-
-e "INPUT_SEARCH_PULL_REQUESTS" \
144-
-e "HOME" \
145-
-e "GITHUB_JOB" \
146-
-e "GITHUB_REF" \
147-
-e "GITHUB_SHA" \
148-
-e "GITHUB_REPOSITORY" \
149-
-e "GITHUB_REPOSITORY_OWNER" \
150-
-e "GITHUB_RUN_ID" \
151-
-e "GITHUB_RUN_NUMBER" \
152-
-e "GITHUB_RETENTION_DAYS" \
153-
-e "GITHUB_RUN_ATTEMPT" \
154-
-e "GITHUB_ACTOR" \
155-
-e "GITHUB_TRIGGERING_ACTOR" \
156-
-e "GITHUB_WORKFLOW" \
157-
-e "GITHUB_HEAD_REF" \
158-
-e "GITHUB_BASE_REF" \
159-
-e "GITHUB_EVENT_NAME" \
160-
-e "GITHUB_SERVER_URL" \
161-
-e "GITHUB_API_URL" \
162-
-e "GITHUB_GRAPHQL_URL" \
163-
-e "GITHUB_REF_NAME" \
164-
-e "GITHUB_REF_PROTECTED" \
165-
-e "GITHUB_REF_TYPE" \
166-
-e "GITHUB_WORKSPACE" \
167-
-e "GITHUB_ACTION" \
168-
-e "GITHUB_EVENT_PATH" \
169-
-e "GITHUB_ACTION_REPOSITORY" \
170-
-e "GITHUB_ACTION_REF" \
171-
-e "GITHUB_PATH" \
172-
-e "GITHUB_ENV" \
173-
-e "GITHUB_STEP_SUMMARY" \
174-
-e "GITHUB_STATE" \
175-
-e "GITHUB_OUTPUT" \
176-
-e "RUNNER_OS" \
177-
-e "RUNNER_ARCH" \
178-
-e "RUNNER_NAME" \
179-
-e "RUNNER_TOOL_CACHE" \
180-
-e "RUNNER_TEMP" \
181-
-e "RUNNER_WORKSPACE" \
182-
-e "ACTIONS_RUNTIME_URL" \
183-
-e "ACTIONS_RUNTIME_TOKEN" \
184-
-e "ACTIONS_CACHE_URL" \
185-
-e GITHUB_ACTIONS=true \
186-
-e CI=true \
187-
-v "$RUNNER_TEMP":"$RUNNER_TEMP" \
188-
-v "/var/run/docker.sock":"/var/run/docker.sock" \
189-
-v "/home/runner/work/_temp/_github_home":"/github/home" \
190-
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
191-
-v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" \
192-
-v "/home/runner/work/publish-unit-test-result-action/publish-unit-test-result-action":"$GITHUB_WORKSPACE" \
193-
enricomi/publish-unit-test-result-action:latest
194-
shell: bash
91+
uses: ./docker
92+
with:
93+
check_name: Test Results (Docker Image ${{ matrix.arch }})
94+
files: "artifacts/**/*.xml"
95+
json_file: "tests.json"
96+
json_suite_details: true
97+
json_test_case_results: true
98+
report_suite_logs: "any"
99+
docker_registry: local
100+
docker_tag: latest
101+
log_level: DEBUG
195102

196103
- name: JSON output
197104
uses: ./misc/action/json-output
@@ -204,7 +111,7 @@ jobs:
204111
uses: crazy-max/ghaction-container-scan@v3
205112
continue-on-error: true
206113
with:
207-
image: enricomi/publish-unit-test-result-action:latest
114+
image: local/enricomi/publish-unit-test-result-action:latest
208115
dockerfile: ./Dockerfile
209116
annotations: true
210117
- name: Upload SARIF artifact

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,28 @@ and removal, and `skipped tests` to detect new skipped and un-skipped tests, as
356356
`check_run_annotations_branch` to contain your default branch.
357357
</details>
358358

359+
<details>
360+
<summary>Options related to Docker</summary>
361+
362+
You can control the Docker image used for the action as below. For this, you need to run the action as follows:
363+
364+
```yaml
365+
- name: Publish Test Results
366+
uses: EnricoMi/publish-unit-test-result-action/docker@v2
367+
if: (!cancelled())
368+
with:
369+
docker_registry: ghcr.io
370+
files: …
371+
```
372+
373+
| Option | Default Value | Description |
374+
|:------------------|:------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------|
375+
| `docker_registry` | `ghcr.io` | The docker registry to pull the pre-built action from. Defaults to the Github registry `ghcr.io`. |
376+
| `docker_image` | `enricomi/publish-unit-test-result-action` | The docker image name to pull the pre-built action from. Defaults to `enricomi/publish-unit-test-result-action`. |
377+
| `docker_tag` | *The same version as in `uses:`* | The docker tag to pull the pre-built action from. This is usually not needed. |
378+
| `docker_platform` | | The platform to use when pulling the docker image. |
379+
</details>
380+
359381
## JSON result
360382

361383
The gathered test information are accessible as JSON via [GitHub Actions steps outputs](https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context) string or JSON file.

docker/action-types.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# See https://github.com/typesafegithub/github-actions-typing/
2+
inputs:
3+
github_token:
4+
type: string
5+
6+
github_token_actor:
7+
type: string
8+
9+
github_retries:
10+
type: integer
11+
12+
ssl_verify:
13+
type: boolean
14+
15+
commit:
16+
type: string
17+
18+
check_name:
19+
type: string
20+
21+
comment_title:
22+
type: string
23+
24+
comment_mode:
25+
type: enum
26+
allowed-values:
27+
- always
28+
- changes
29+
- changes in failures
30+
- changes in errors
31+
- failures
32+
- errors
33+
- off
34+
35+
fail_on:
36+
type: enum
37+
allowed-values:
38+
- nothing
39+
- errors
40+
- test failures
41+
42+
action_fail:
43+
type: boolean
44+
45+
action_fail_on_inconclusive:
46+
type: boolean
47+
48+
files:
49+
type: list
50+
separator: '\n'
51+
list-item:
52+
type: string
53+
54+
junit_files:
55+
type: list
56+
separator: '\n'
57+
list-item:
58+
type: string
59+
60+
nunit_files:
61+
type: list
62+
separator: '\n'
63+
list-item:
64+
type: string
65+
66+
xunit_files:
67+
type: list
68+
separator: '\n'
69+
list-item:
70+
type: string
71+
72+
trx_files:
73+
type: list
74+
separator: '\n'
75+
list-item:
76+
type: string
77+
78+
time_unit:
79+
type: enum
80+
allowed-values:
81+
- seconds
82+
- milliseconds
83+
84+
test_file_prefix:
85+
type: string
86+
87+
report_individual_runs:
88+
type: boolean
89+
90+
report_suite_logs:
91+
type: enum
92+
allowed-values:
93+
- info
94+
- error
95+
- any
96+
- none
97+
98+
deduplicate_classes_by_file_name:
99+
type: boolean
100+
101+
large_files:
102+
type: boolean
103+
104+
ignore_runs:
105+
type: boolean
106+
107+
check_run:
108+
type: boolean
109+
110+
job_summary:
111+
type: boolean
112+
113+
compare_to_earlier_commit:
114+
type: boolean
115+
116+
pull_request_build:
117+
type: enum
118+
allowed-values:
119+
- commit
120+
- merge
121+
122+
event_file:
123+
type: string
124+
125+
event_name:
126+
type: string
127+
128+
test_changes_limit:
129+
type: integer
130+
131+
check_run_annotations:
132+
type: list
133+
separator: ','
134+
list-item:
135+
type: enum
136+
allowed-values:
137+
- all tests
138+
- skipped tests
139+
- none
140+
141+
check_run_annotations_branch:
142+
type: list
143+
separator: ','
144+
list-item:
145+
type: string
146+
147+
seconds_between_github_reads:
148+
type: float
149+
150+
seconds_between_github_writes:
151+
type: float
152+
153+
secondary_rate_limit_wait_seconds:
154+
type: float
155+
156+
json_file:
157+
type: string
158+
159+
json_thousands_separator:
160+
type: string
161+
162+
json_suite_details:
163+
type: boolean
164+
165+
json_test_case_results:
166+
type: boolean
167+
168+
search_pull_requests:
169+
type: boolean
170+
171+
docker_platform:
172+
type: string
173+
174+
docker_registry:
175+
type: string
176+
177+
docker_image:
178+
type: string
179+
180+
docker_tag:
181+
type: string
182+
183+
outputs:
184+
json:
185+
type: string

0 commit comments

Comments
 (0)