Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS-specific composite actions #576

Merged
merged 42 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4352505
Split composite action into linux/macos/windows
EnricoMi Feb 21, 2024
3e1a5d3
Rework echoing endgroup
EnricoMi Feb 22, 2024
2719129
Migrate action to Windows PowerShell
EnricoMi Feb 22, 2024
3b8a5d6
Make linux and macos OS specific
EnricoMi Feb 22, 2024
7b24ef5
fix endgroup
EnricoMi Feb 22, 2024
f8d8051
Write error as GH actions error
EnricoMi Feb 22, 2024
434ba4d
Use deprecated Windows bash version for default composite action
EnricoMi Feb 22, 2024
cebf9c5
Fail on unsupported operating system
EnricoMi Feb 22, 2024
2808751
Add new actions to README.md
EnricoMi Feb 22, 2024
c6642a7
Move os-specific composit actions into project root
EnricoMi Feb 22, 2024
b80e99e
Test and do forward inputs to actions
EnricoMi Feb 22, 2024
9fee217
Fix uses in composite action
EnricoMi Feb 22, 2024
ff4d56b
Make env.RUNNER_OS available to if
EnricoMi Feb 22, 2024
a2bdda8
Fix windows shell
EnricoMi Feb 22, 2024
b7fd4c9
Publish with os-specific actions thoroughly, composite once per OS
EnricoMi Feb 22, 2024
581113c
Fix access to env var in powershell
EnricoMi Feb 22, 2024
88369ab
Fix escaped backslashes and env var
EnricoMi Feb 22, 2024
546639f
Add log level inputs to action.yml files
EnricoMi Feb 23, 2024
5f7584c
Remove `trap "echo '##[endgroup]'" EXIT`
EnricoMi Feb 23, 2024
59547f9
Remove some more escaped backslashes
EnricoMi Feb 23, 2024
ee791ad
Fix grouping lines in GH actions output
EnricoMi Feb 23, 2024
86ad968
Move windows-bash/ to windows/bash
EnricoMi Feb 23, 2024
a97d0b1
Use actions relative to composite/action.yml
EnricoMi Feb 23, 2024
5a87324
Reduce test space
EnricoMi Feb 23, 2024
afd456f
Reduce publish space
EnricoMi Feb 23, 2024
20ee7c9
Redirect composite action through dynamic action
EnricoMi Feb 23, 2024
0949ea4
Test composite with sha
EnricoMi Feb 23, 2024
dd90871
Revert composite action
EnricoMi Feb 24, 2024
ddf2431
Revert "Add log level inputs to action.yml files"
EnricoMi Feb 24, 2024
fb7d567
Revert "Test composite with sha"
EnricoMi Feb 24, 2024
34f9085
Ammend readme
EnricoMi Feb 24, 2024
08e6618
Align action yamls
EnricoMi Feb 24, 2024
e98432e
Revert "Reduce publish space"
EnricoMi Feb 24, 2024
db278d7
Fix composite action test
EnricoMi Feb 24, 2024
2eea822
Revert "Reduce test space"
EnricoMi Feb 24, 2024
20929ed
Remove redundant composite/proxy.sh
EnricoMi Feb 24, 2024
65a3238
Remove redundant steps from publish-composite job
EnricoMi Feb 24, 2024
ab47cbd
Replace mentioning of 'composite' with 'non-Docker'
EnricoMi Feb 24, 2024
7afc3cd
Deprecate composite action
EnricoMi Feb 24, 2024
c1155fe
Reduce deprecation warning to single line, link to readme
EnricoMi Feb 24, 2024
62d3b4f
Link in readme from composite to non-Docker section
EnricoMi Feb 24, 2024
dff220b
Beautify logs
EnricoMi Feb 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 180 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ jobs:
with:
sarif_file: ${{ steps.scan.outputs.sarif }}

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

strategy:
fail-fast: false
max-parallel: 3
max-parallel: 2
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
include:
- os: ubuntu-latest
os-label: Linux
python: "3.8"
- os: ubuntu-latest
os-label: Linux
python: "venv"
- os: ubuntu-latest
os-label: Linux
python: "installed"
- os: ubuntu-20.04
os-label: Linux 20.04
python: "installed"

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
if: matrix.python != 'installed' && matrix.python != 'venv'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install virtualenv
if: matrix.python == 'venv'
run: python3 -m pip install virtualenv
shell: bash

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish Test Results
id: test-results
uses: ./linux
with:
check_name: Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
files: artifacts/**/*.xml
json_file: "tests.json"
json_suite_details: true
json_test_case_results: true
report_suite_logs: "any"

- name: JSON output
uses: ./misc/action/json-output
with:
json: '${{ steps.test-results.outputs.json }}'
json_file: 'tests.json'

publish-macos:
name: Publish Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
runs-on: ${{ matrix.os }}
permissions:
checks: write
pull-requests: write

strategy:
fail-fast: false
max-parallel: 2
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# test *-latest and newer (because newer eventually become 'latest' and should be tested to work before that)
include:
- os: macos-latest
os-label: macOS
Expand All @@ -248,19 +310,56 @@ jobs:
os-label: macOS 14
python: "installed"

- os: ubuntu-latest
os-label: Linux
python: "3.8"
- os: ubuntu-latest
os-label: Linux
python: "venv"
- os: ubuntu-latest
os-label: Linux
python: "installed"
- os: ubuntu-20.04
os-label: Linux 20.04
python: "installed"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
if: matrix.python != 'installed' && matrix.python != 'venv'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install virtualenv
if: matrix.python == 'venv'
run: python3 -m pip install virtualenv
shell: bash

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish Test Results
id: test-results
uses: ./macos
with:
check_name: Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
files: artifacts/**/*.xml
json_file: "tests.json"
json_suite_details: true
json_test_case_results: true
report_suite_logs: "any"

- name: JSON output
uses: ./misc/action/json-output
with:
json: '${{ steps.test-results.outputs.json }}'
json_file: 'tests.json'

publish-windows:
name: Publish Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
runs-on: ${{ matrix.os }}
permissions:
checks: write
pull-requests: write

strategy:
fail-fast: false
max-parallel: 2
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
include:
- os: windows-latest
os-label: Windows
python: "installed"
Expand All @@ -283,8 +382,7 @@ jobs:

- name: Install virtualenv
if: matrix.python == 'venv'
run: |
python3 -m pip install virtualenv
run: python3 -m pip install virtualenv
shell: bash

- name: Download Artifacts
Expand All @@ -294,9 +392,73 @@ jobs:

- name: Publish Test Results
id: test-results
uses: ./composite
uses: ./windows
with:
check_name: Test Results (${{ matrix.os-label }} python ${{ matrix.python }})
files: artifacts\**\*.xml
json_file: "tests.json"
json_suite_details: true
json_test_case_results: true
report_suite_logs: "any"

- name: JSON output
uses: ./misc/action/json-output
with:
json: '${{ steps.test-results.outputs.json }}'
json_file: 'tests.json'

- name: Publish Test Results (Bash)
id: test-results-bash
uses: ./windows/bash
with:
check_name: Test Results (${{ matrix.os-label }} bash python ${{ matrix.python }})
files: artifacts\**\*.xml
json_file: "tests.json"
json_suite_details: true
json_test_case_results: true
report_suite_logs: "any"

- name: JSON output (Bash)
uses: ./misc/action/json-output
with:
json: '${{ steps.test-results-bash.outputs.json }}'
json_file: 'tests.json'

publish-composite:
name: Publish Test Results (${{ matrix.os-label }} composite)
runs-on: ${{ matrix.os }}
permissions:
checks: write
pull-requests: write

strategy:
fail-fast: false
max-parallel: 1
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# test *-latest and newer (because newer eventually become 'latest' and should be tested to work before that)
include:
- os: macos-latest
os-label: macOS
- os: ubuntu-latest
os-label: Linux
- os: windows-latest
os-label: Windows

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish Test Results
id: test-results
uses: ./composite
with:
check_name: Test Results (${{ matrix.os-label }} composite python ${{ matrix.python }})
files: |
artifacts/**/*.xml
artifacts\**\*.xml
Expand Down
79 changes: 61 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ publishes the results on GitHub. It supports [JSON (Dart, Mocha), TRX (MSTest, V
and runs on Linux, macOS and Windows.

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

```yaml
- name: Publish Test Results
Expand All @@ -36,12 +36,34 @@ or ![ARM Linux](misc/badge-arm.svg) self-hosted runners:

See the [notes on running this action with absolute paths](#running-with-absolute-paths) if you cannot use relative test result file paths.

Use this for ![macOS](misc/badge-macos.svg) (e.g. `runs-on: macos-latest`)
and ![Windows](misc/badge-windows.svg) (e.g. `runs-on: windows-latest`) runners:
Use this for ![macOS](misc/badge-macos.svg) (e.g. `runs-on: macos-latest`) runners:
```yaml
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/macos@v2
if: always()
with:
files: |
test-results/**/*.xml
test-results/**/*.trx
test-results/**/*.json
```

… and ![Windows](misc/badge-windows.svg) (e.g. `runs-on: windows-latest`) runners:
```yaml
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
test-results\**\*.xml
test-results\**\*.trx
test-results\**\*.json
```

For **self-hosted** Linux GitHub Actions runners **without Docker** installed, please use:
```yaml
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: always()
with:
files: |
Expand All @@ -50,7 +72,7 @@ and ![Windows](misc/badge-windows.svg) (e.g. `runs-on: windows-latest`) runners:
test-results/**/*.json
```

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

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

|Option|Default Value|Description|
|:-----|:-----:|:----------|
|`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 `!`.|
|`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 `!`.|
|`check_name`|`"Test Results"`|An alternative name for the check result. Required to be unique for each instance in one workflow.|
|`comment_title`|same as `check_name`|An alternative name for the pull request comment.|
|`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.|
Expand Down Expand Up @@ -783,10 +805,14 @@ You can then use the badge via this URL: https://gist.githubusercontent.com/{use
## Running with absolute paths

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

If you have to use absolute paths with the non-composite variant of this action (`uses: EnricoMi/publish-unit-test-result-action@v2`),
uses: EnricoMi/publish-unit-test-result-action/linux@v2
uses: EnricoMi/publish-unit-test-result-action/macos@v2
uses: EnricoMi/publish-unit-test-result-action/windows@v2

If you have to use absolute paths with the Docker variant of this action (`uses: EnricoMi/publish-unit-test-result-action@v2`),
you have to copy files to a relative path first, and then use the relative path:

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

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

## Running as a composite action
## Running as a non-Docker action

Running this action as a composite action allows to run it on various operating systems as it
does not require Docker. The composite action, however, requires a Python3 environment to be setup
on the action runner. All GitHub-hosted runners (Ubuntu, Windows Server and macOS) provide a suitable
Python3 environment out-of-the-box.
Running this action as below allows to run it on action runners that do not provide Docker:

uses: EnricoMi/publish-unit-test-result-action/linux@v2
uses: EnricoMi/publish-unit-test-result-action/macos@v2
uses: EnricoMi/publish-unit-test-result-action/windows@v2

These actions, however, require a Python3 environment to be setup on the action runner.
All GitHub-hosted runners (Ubuntu, Windows Server and macOS) provide a suitable Python3 environment out-of-the-box.

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

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

Self-hosted runners for Windows require Bash shell to be installed. Easiest way to have one is by installing
Git for Windows, which comes with Git BASH. Make sure that the location of `bash.exe` is part of the `PATH`
environment variable seen by the self-hosted runner.
Start-up of the action is faster with `virtualenv` or `venv`, as well as `wheel` packages are installed.

## Running as a composite action

Running this action via:

uses: EnricoMi/publish-unit-test-result-action/composite@v2

is **deprecated**, please use an action appropriate for your operating system and shell:

- Linux (Bash shell): `uses: EnricoMi/publish-unit-test-result-action/linux@v2`
- macOS (Bash shell): `uses: EnricoMi/publish-unit-test-result-action/macos@v2`
- Windows (PowerShell): `uses: EnricoMi/publish-unit-test-result-action/windows@v2`
- Windows (Bash shell): `uses: EnricoMi/publish-unit-test-result-action/windows/bash@v2`

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.
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ inputs:
default: 'false'
required: false
files:
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 "!".'
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 "!".'
required: false
junit_files:
description: 'Deprecated, use "files" option instead.'
Expand Down Expand Up @@ -142,6 +142,7 @@ inputs:
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".'
default: 'false'
required: false

outputs:
json:
description: "Test results as JSON"
Expand Down
Loading
Loading