Skip to content

Commit fe2d5fc

Browse files
authored
OS-specific composite actions (#576)
1 parent b91eeb9 commit fe2d5fc

File tree

9 files changed

+1526
-62
lines changed

9 files changed

+1526
-62
lines changed

.github/workflows/publish.yml

Lines changed: 180 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
with:
216216
sarif_file: ${{ steps.scan.outputs.sarif }}
217217

218-
publish-composite:
218+
publish-linux:
219219
name: Publish Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
220220
runs-on: ${{ matrix.os }}
221221
permissions:
@@ -224,10 +224,72 @@ jobs:
224224

225225
strategy:
226226
fail-fast: false
227-
max-parallel: 3
227+
max-parallel: 2
228+
matrix:
229+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
230+
include:
231+
- os: ubuntu-latest
232+
os-label: Linux
233+
python: "3.8"
234+
- os: ubuntu-latest
235+
os-label: Linux
236+
python: "venv"
237+
- os: ubuntu-latest
238+
os-label: Linux
239+
python: "installed"
240+
- os: ubuntu-20.04
241+
os-label: Linux 20.04
242+
python: "installed"
243+
244+
steps:
245+
- name: Checkout
246+
uses: actions/checkout@v4
247+
248+
- name: Setup Python
249+
if: matrix.python != 'installed' && matrix.python != 'venv'
250+
uses: actions/setup-python@v5
251+
with:
252+
python-version: ${{ matrix.python }}
253+
254+
- name: Install virtualenv
255+
if: matrix.python == 'venv'
256+
run: python3 -m pip install virtualenv
257+
shell: bash
258+
259+
- name: Download Artifacts
260+
uses: actions/download-artifact@v4
261+
with:
262+
path: artifacts
263+
264+
- name: Publish Test Results
265+
id: test-results
266+
uses: ./linux
267+
with:
268+
check_name: Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
269+
files: artifacts/**/*.xml
270+
json_file: "tests.json"
271+
json_suite_details: true
272+
json_test_case_results: true
273+
report_suite_logs: "any"
274+
275+
- name: JSON output
276+
uses: ./misc/action/json-output
277+
with:
278+
json: '${{ steps.test-results.outputs.json }}'
279+
json_file: 'tests.json'
280+
281+
publish-macos:
282+
name: Publish Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
283+
runs-on: ${{ matrix.os }}
284+
permissions:
285+
checks: write
286+
pull-requests: write
287+
288+
strategy:
289+
fail-fast: false
290+
max-parallel: 2
228291
matrix:
229292
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
230-
# test *-latest and newer (because newer eventually become 'latest' and should be tested to work before that)
231293
include:
232294
- os: macos-latest
233295
os-label: macOS
@@ -248,19 +310,56 @@ jobs:
248310
os-label: macOS 14
249311
python: "installed"
250312

251-
- os: ubuntu-latest
252-
os-label: Linux
253-
python: "3.8"
254-
- os: ubuntu-latest
255-
os-label: Linux
256-
python: "venv"
257-
- os: ubuntu-latest
258-
os-label: Linux
259-
python: "installed"
260-
- os: ubuntu-20.04
261-
os-label: Linux 20.04
262-
python: "installed"
313+
steps:
314+
- name: Checkout
315+
uses: actions/checkout@v4
263316

317+
- name: Setup Python
318+
if: matrix.python != 'installed' && matrix.python != 'venv'
319+
uses: actions/setup-python@v5
320+
with:
321+
python-version: ${{ matrix.python }}
322+
323+
- name: Install virtualenv
324+
if: matrix.python == 'venv'
325+
run: python3 -m pip install virtualenv
326+
shell: bash
327+
328+
- name: Download Artifacts
329+
uses: actions/download-artifact@v4
330+
with:
331+
path: artifacts
332+
333+
- name: Publish Test Results
334+
id: test-results
335+
uses: ./macos
336+
with:
337+
check_name: Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
338+
files: artifacts/**/*.xml
339+
json_file: "tests.json"
340+
json_suite_details: true
341+
json_test_case_results: true
342+
report_suite_logs: "any"
343+
344+
- name: JSON output
345+
uses: ./misc/action/json-output
346+
with:
347+
json: '${{ steps.test-results.outputs.json }}'
348+
json_file: 'tests.json'
349+
350+
publish-windows:
351+
name: Publish Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
352+
runs-on: ${{ matrix.os }}
353+
permissions:
354+
checks: write
355+
pull-requests: write
356+
357+
strategy:
358+
fail-fast: false
359+
max-parallel: 2
360+
matrix:
361+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
362+
include:
264363
- os: windows-latest
265364
os-label: Windows
266365
python: "installed"
@@ -283,8 +382,7 @@ jobs:
283382

284383
- name: Install virtualenv
285384
if: matrix.python == 'venv'
286-
run: |
287-
python3 -m pip install virtualenv
385+
run: python3 -m pip install virtualenv
288386
shell: bash
289387

290388
- name: Download Artifacts
@@ -294,9 +392,73 @@ jobs:
294392

295393
- name: Publish Test Results
296394
id: test-results
297-
uses: ./composite
395+
uses: ./windows
298396
with:
299397
check_name: Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
398+
files: artifacts\**\*.xml
399+
json_file: "tests.json"
400+
json_suite_details: true
401+
json_test_case_results: true
402+
report_suite_logs: "any"
403+
404+
- name: JSON output
405+
uses: ./misc/action/json-output
406+
with:
407+
json: '${{ steps.test-results.outputs.json }}'
408+
json_file: 'tests.json'
409+
410+
- name: Publish Test Results (Bash)
411+
id: test-results-bash
412+
uses: ./windows/bash
413+
with:
414+
check_name: Test Results (${{ matrix.os-label }} bash python ${{ matrix.python }})
415+
files: artifacts\**\*.xml
416+
json_file: "tests.json"
417+
json_suite_details: true
418+
json_test_case_results: true
419+
report_suite_logs: "any"
420+
421+
- name: JSON output (Bash)
422+
uses: ./misc/action/json-output
423+
with:
424+
json: '${{ steps.test-results-bash.outputs.json }}'
425+
json_file: 'tests.json'
426+
427+
publish-composite:
428+
name: Publish Test Results (${{ matrix.os-label }} composite)
429+
runs-on: ${{ matrix.os }}
430+
permissions:
431+
checks: write
432+
pull-requests: write
433+
434+
strategy:
435+
fail-fast: false
436+
max-parallel: 1
437+
matrix:
438+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
439+
# test *-latest and newer (because newer eventually become 'latest' and should be tested to work before that)
440+
include:
441+
- os: macos-latest
442+
os-label: macOS
443+
- os: ubuntu-latest
444+
os-label: Linux
445+
- os: windows-latest
446+
os-label: Windows
447+
448+
steps:
449+
- name: Checkout
450+
uses: actions/checkout@v4
451+
452+
- name: Download Artifacts
453+
uses: actions/download-artifact@v4
454+
with:
455+
path: artifacts
456+
457+
- name: Publish Test Results
458+
id: test-results
459+
uses: ./composite
460+
with:
461+
check_name: Test Results (${{ matrix.os-label }} composite python ${{ matrix.python }})
300462
files: |
301463
artifacts/**/*.xml
302464
artifacts\**\*.xml

README.md

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ publishes the results on GitHub. It supports [JSON (Dart, Mocha), TRX (MSTest, V
2121
and runs on Linux, macOS and Windows.
2222

2323
You can use this action with ![Ubuntu Linux](misc/badge-ubuntu.svg) runners (e.g. `runs-on: ubuntu-latest`)
24-
or ![ARM Linux](misc/badge-arm.svg) self-hosted runners:
24+
or ![ARM Linux](misc/badge-arm.svg) self-hosted runners that support Docker:
2525

2626
```yaml
2727
- name: Publish Test Results
@@ -36,12 +36,34 @@ or ![ARM Linux](misc/badge-arm.svg) self-hosted runners:
3636
3737
See the [notes on running this action with absolute paths](#running-with-absolute-paths) if you cannot use relative test result file paths.
3838
39-
Use this for ![macOS](misc/badge-macos.svg) (e.g. `runs-on: macos-latest`)
40-
and ![Windows](misc/badge-windows.svg) (e.g. `runs-on: windows-latest`) runners:
39+
Use this for ![macOS](misc/badge-macos.svg) (e.g. `runs-on: macos-latest`) runners:
40+
```yaml
41+
- name: Publish Test Results
42+
uses: EnricoMi/publish-unit-test-result-action/macos@v2
43+
if: always()
44+
with:
45+
files: |
46+
test-results/**/*.xml
47+
test-results/**/*.trx
48+
test-results/**/*.json
49+
```
4150

51+
… and ![Windows](misc/badge-windows.svg) (e.g. `runs-on: windows-latest`) runners:
4252
```yaml
4353
- name: Publish Test Results
44-
uses: EnricoMi/publish-unit-test-result-action/composite@v2
54+
uses: EnricoMi/publish-unit-test-result-action/windows@v2
55+
if: always()
56+
with:
57+
files: |
58+
test-results\**\*.xml
59+
test-results\**\*.trx
60+
test-results\**\*.json
61+
```
62+
63+
For **self-hosted** Linux GitHub Actions runners **without Docker** installed, please use:
64+
```yaml
65+
- name: Publish Test Results
66+
uses: EnricoMi/publish-unit-test-result-action/linux@v2
4567
if: always()
4668
with:
4769
files: |
@@ -50,7 +72,7 @@ and ![Windows](misc/badge-windows.svg) (e.g. `runs-on: windows-latest`) runners:
5072
test-results/**/*.json
5173
```
5274

53-
See the [notes on running this action as a composite action](#running-as-a-composite-action) if you run it on Windows or macOS.
75+
See the [notes on running this action as a non-Docker action](#running-as-a-non-docker-action).
5476

5577
If you see the `"Resource not accessible by integration"` error, you have to grant additional [permissions](#permissions), or
5678
[setup the support for pull requests from fork repositories and branches created by Dependabot](#support-fork-repositories-and-dependabot-branches).
@@ -273,7 +295,7 @@ The list of most notable options:
273295

274296
|Option|Default Value|Description|
275297
|:-----|:-----:|:----------|
276-
|`files`|_no default_|File patterns of test result files. Relative paths are known to work best, while the composite action [also works with absolute paths](#running-with-absolute-paths). Supports `*`, `**`, `?`, and `[]` character ranges. Use multiline string for multiple patterns. Patterns starting with `!` exclude the matching files. There have to be at least one pattern starting without a `!`.|
298+
|`files`|_no default_|File patterns of test result files. Relative paths are known to work best, while the non-Docker action [also works with absolute paths](#running-with-absolute-paths). Supports `*`, `**`, `?`, and `[]` character ranges. Use multiline string for multiple patterns. Patterns starting with `!` exclude the matching files. There have to be at least one pattern starting without a `!`.|
277299
|`check_name`|`"Test Results"`|An alternative name for the check result. Required to be unique for each instance in one workflow.|
278300
|`comment_title`|same as `check_name`|An alternative name for the pull request comment.|
279301
|`comment_mode`|`always`|The action posts comments to pull requests that are associated with the commit. Set to:<br/>`always` - always comment<br/>`changes` - comment when changes w.r.t. the target branch exist<br/>`changes in failures` - when changes in the number of failures and errors exist<br/>`changes in errors` - when changes in the number of (only) errors exist<br/>`failures` - when failures or errors exist<br/>`errors` - when (only) errors exist<br/>`off` - to not create pull request comments.|
@@ -783,10 +805,14 @@ You can then use the badge via this URL: https://gist.githubusercontent.com/{use
783805
## Running with absolute paths
784806

785807
It is known that this action works best with relative paths (e.g. `test-results/**/*.xml`),
786-
but most absolute paths (e.g. `/tmp/test-results/**/*.xml`) require to use the composite variant
787-
of this action (`uses: EnricoMi/publish-unit-test-result-action/composite@v2`).
808+
but most absolute paths (e.g. `/tmp/test-results/**/*.xml`) require to use the non-Docker variant
809+
of this action:
788810

789-
If you have to use absolute paths with the non-composite variant of this action (`uses: EnricoMi/publish-unit-test-result-action@v2`),
811+
uses: EnricoMi/publish-unit-test-result-action/linux@v2
812+
uses: EnricoMi/publish-unit-test-result-action/macos@v2
813+
uses: EnricoMi/publish-unit-test-result-action/windows@v2
814+
815+
If you have to use absolute paths with the Docker variant of this action (`uses: EnricoMi/publish-unit-test-result-action@v2`),
790816
you have to copy files to a relative path first, and then use the relative path:
791817

792818
```yaml
@@ -806,14 +832,18 @@ you have to copy files to a relative path first, and then use the relative path:
806832
test-results/**/*.json
807833
```
808834

809-
Using the non-composite variant of this action is recommended as it starts up much quicker.
835+
Using the Docker variant of this action is recommended as it starts up much quicker.
810836

811-
## Running as a composite action
837+
## Running as a non-Docker action
812838

813-
Running this action as a composite action allows to run it on various operating systems as it
814-
does not require Docker. The composite action, however, requires a Python3 environment to be setup
815-
on the action runner. All GitHub-hosted runners (Ubuntu, Windows Server and macOS) provide a suitable
816-
Python3 environment out-of-the-box.
839+
Running this action as below allows to run it on action runners that do not provide Docker:
840+
841+
uses: EnricoMi/publish-unit-test-result-action/linux@v2
842+
uses: EnricoMi/publish-unit-test-result-action/macos@v2
843+
uses: EnricoMi/publish-unit-test-result-action/windows@v2
844+
845+
These actions, however, require a Python3 environment to be setup on the action runner.
846+
All GitHub-hosted runners (Ubuntu, Windows Server and macOS) provide a suitable Python3 environment out-of-the-box.
817847

818848
Self-hosted runners may require setting up a Python environment first:
819849

@@ -824,6 +854,19 @@ Self-hosted runners may require setting up a Python environment first:
824854
python-version: 3.8
825855
```
826856

827-
Self-hosted runners for Windows require Bash shell to be installed. Easiest way to have one is by installing
828-
Git for Windows, which comes with Git BASH. Make sure that the location of `bash.exe` is part of the `PATH`
829-
environment variable seen by the self-hosted runner.
857+
Start-up of the action is faster with `virtualenv` or `venv`, as well as `wheel` packages are installed.
858+
859+
## Running as a composite action
860+
861+
Running this action via:
862+
863+
uses: EnricoMi/publish-unit-test-result-action/composite@v2
864+
865+
is **deprecated**, please use an action appropriate for your operating system and shell:
866+
867+
- Linux (Bash shell): `uses: EnricoMi/publish-unit-test-result-action/linux@v2`
868+
- macOS (Bash shell): `uses: EnricoMi/publish-unit-test-result-action/macos@v2`
869+
- Windows (PowerShell): `uses: EnricoMi/publish-unit-test-result-action/windows@v2`
870+
- Windows (Bash shell): `uses: EnricoMi/publish-unit-test-result-action/windows/bash@v2`
871+
872+
These are non-Docker variations of this action. For details, see section ["Running as a non-Docker action"](#running-as-a-non-docker-action) above.

action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ inputs:
4242
default: 'false'
4343
required: false
4444
files:
45-
description: 'File patterns of test result files. Relative paths are known to work best, while the composite action also works with absolute paths. Supports "*", "**", "?", and "[]" character ranges. Use multiline string for multiple patterns. Patterns starting with "!" exclude the matching files. There have to be at least one pattern starting without a "!".'
45+
description: 'File patterns of test result files. Relative paths are known to work best, while the non-Docker action also works with absolute paths. Supports "*", "**", "?", and "[]" character ranges. Use multiline string for multiple patterns. Patterns starting with "!" exclude the matching files. There have to be at least one pattern starting without a "!".'
4646
required: false
4747
junit_files:
4848
description: 'Deprecated, use "files" option instead.'
@@ -142,6 +142,7 @@ inputs:
142142
description: 'Prior to v2.6.0, the action used the "/search/issues" REST API to find pull requests related to a commit. If you need to restore that behaviour, set this to "true". Defaults to "false".'
143143
default: 'false'
144144
required: false
145+
145146
outputs:
146147
json:
147148
description: "Test results as JSON"

0 commit comments

Comments
 (0)