Skip to content

Commit 923a3e5

Browse files
authored
Move build_tools unit tests to a standalone workflow file (#3076)
## Motivation I'm adding a new unit test in #3057 that validates our github actions workflows. I want that test to run when any workflow file is modified and to be a "required check" that blocks merging. Our current filtering via [`configure_ci.py`](https://github.com/ROCm/TheRock/blob/main/build_tools/github_actions/configure_ci.py) has various exclusions that skip running the existing "build_*_artifacts.yml" workflows if only "skippable paths" or "files unrelated to CI" are modified. Rather than extend the filtering there, I figured a standalone workflow file that always runs would be more natural. ## Technical Details * The new `unit_tests_summary` job gives us an anchor point that depends on all unit test jobs (currently just the Linux and Windows matrix jobs) to use as a required check. * The `toJson()` code in that job is forked from the similar step in ci.yml. Yes, it's gross. Yes, I want to move it to a reusable workflow or script. * Creating a standalone workflow like this will also 1. Exclude these tests from workflow runs in rocm-libraries / rocm-systems 2. Keep these tests included when we switch from [`ci.yml`](https://github.com/ROCm/TheRock/blob/main/.github/workflows/ci.yml) to [`multi_arch_ci.yml`](https://github.com/ROCm/TheRock/blob/main/.github/workflows/multi_arch_ci.yml) * Unit tests use standard github-hosted runners and take 1 minute on average. If we add tests that depend on self-hosted runners in some way we could switch them over. * Setting `GITHUB_TOKEN: ${{ github.token }}` in the env allows these tests to run: https://github.com/ROCm/TheRock/blob/901d88d25b246cd3af1405179b6acc31f435eb02/build_tools/github_actions/tests/github_actions_utils_test.py#L21-L29 ## Test Plan Tested in my fork: * With tests passing: https://github.com/ScottTodd/TheRock/actions/runs/21300728642 * With tests failing: https://github.com/ScottTodd/TheRock/actions/runs/21300780457 Tested on this PR: https://github.com/ROCm/TheRock/actions/runs/21368145938?pr=3076 ## Test Result Test workflow runs succeeded and failed as expected. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
1 parent d072e26 commit 923a3e5

File tree

3 files changed

+72
-8
lines changed

3 files changed

+72
-8
lines changed

.github/workflows/build_portable_linux_artifacts.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ jobs:
105105
run: |
106106
./build_tools/health_status.py
107107
108-
- name: Test build_tools
109-
run: |
110-
python -m pytest build_tools/tests build_tools/github_actions/tests
111-
112108
- name: Fetch sources
113109
timeout-minutes: 30
114110
run: |

.github/workflows/build_windows_artifacts.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ jobs:
113113
ccache --zero-stats
114114
python ./build_tools/health_status.py
115115
116-
- name: Test build_tools
117-
run: |
118-
python -m pytest build_tools/tests build_tools/github_actions/tests
119-
120116
# TODO: We shouldn't be using a cache on actual release branches, but it
121117
# really helps for iteration time.
122118
- name: Enable cache

.github/workflows/unit_tests.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/therock-*
8+
pull_request:
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
unit_tests:
16+
name: "Unit Tests :: ${{ matrix.runs-on}}"
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
runs-on: [ubuntu-24.04, windows-2022]
21+
runs-on: ${{ matrix.runs-on }}
22+
defaults:
23+
run:
24+
shell: bash
25+
env:
26+
GITHUB_TOKEN: ${{ github.token }}
27+
28+
steps:
29+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
30+
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
31+
with:
32+
python-version: 3.12
33+
34+
- name: Install python deps
35+
run: pip install -r requirements-test.txt
36+
37+
# Note: build_tools/github_actions/ contains complicated tests in some
38+
# subdirectories that do not support pytest:
39+
# build_tools/github_actions/benchmarks/scripts/
40+
# build_tools/github_actions/test_executable_scripts/
41+
# We could move them if we want a simple `pytest build_tools/` to work.
42+
# TODO(scotttodd): enable code coverage collection/reporting here
43+
- name: Test build_tools
44+
run: |
45+
python -m pytest -vv \
46+
build_tools/tests \
47+
build_tools/github_actions/tests
48+
49+
# TODO(scotttodd): share code with ci_summary in ci.yml
50+
# Could reuse this from prior projects:
51+
# https://github.com/iree-org/iree/blob/main/.github/workflows/workflow_summary.yml
52+
# (including support for sending alerts on failures)
53+
unit_tests_summary:
54+
name: Unit Tests Summary
55+
if: always()
56+
needs:
57+
- unit_tests
58+
runs-on: ubuntu-24.04
59+
steps:
60+
- name: Output failed jobs
61+
run: |
62+
echo '${{ toJson(needs) }}'
63+
FAILED_JOBS="$(echo '${{ toJson(needs) }}' \
64+
| jq --raw-output \
65+
'map_values(select(.result!="success" and .result!="skipped")) | keys | join(",")' \
66+
)"
67+
if [[ "${FAILED_JOBS}" != "" ]]; then
68+
echo "The following jobs failed: ${FAILED_JOBS}"
69+
exit 1
70+
else
71+
echo "All required jobs succeeded."
72+
fi

0 commit comments

Comments
 (0)