Skip to content

Commit

Permalink
Update treadmill-ci workflow to dynamically select hardware CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charles37 committed Nov 26, 2024
1 parent a25d927 commit e298e58
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions .github/workflows/treadmill-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ name: treadmill-ci

env:
TERM: xterm # Makes tput work in actions output
TOCK_HARDWARE_CI_REF: 'main' # Reference for tock-hardware-ci repo, change if you want a specific test suite

# Controls when the action will run. Triggers the workflow on pull request and
# merge group checks:
Expand All @@ -30,6 +31,8 @@ on:
push:
branches:
- master
# Add any additional branches you want to include
# - dev/test_ci_branch
# Pull requests from forks will not have access to the required GitHub API
# secrets below, even if they are using an appropriate deployment environment
# and the workflow runs have been approved according to this environment's
Expand All @@ -45,8 +48,56 @@ permissions:
contents: read

jobs:
determine-tests:
runs-on: ubuntu-latest

outputs:
hwci-tests-json: ${{ steps.determine-tests.outputs.hwci-tests-json }}

steps:
- name: Checkout the tock/tock repository
uses: actions/checkout@v4
with:
# Checkout the repository at the commit that triggered the workflow
repository: tock/tock
ref: ${{ github.sha }}
path: tock-tock

- name: Checkout the tock-hardware-ci repository
uses: actions/checkout@v4
with:
repository: tock/tock-hardware-ci
ref: ${{ env.TOCK_HARDWARE_CI_REF }}
path: tock-hardware-ci

- name: Analyze changes to determine relevant tests
id: analyze-changes
run: |
# Ensure Python dependencies are installed
python3 -m pip install --user --upgrade pip
# Run the select_tests.py script
python3 tock-hardware-ci/hwci/select_tests.py \
--repo-path tock-tock \
--hwci-path tock-hardware-ci/hwci \
--output selected_tests.json
echo "Selected HWCI tests:"
cat selected_tests.json
# Output the tests JSON
hwci_tests_json=$(cat selected_tests.json | jq -c '.')
echo "hwci-tests-json=${hwci_tests_json}" >> "$GITHUB_OUTPUT"
treadmill-ci:
uses: tock/tock-hardware-ci/.github/workflows/treadmill-ci.yml@main
needs: [determine-tests]

# This checks whether there is at least one test to run, see
# https://github.com/orgs/community/discussions/27125#discussioncomment-3254720
if: fromJSON(needs.determine-tests.outputs.hwci-tests-json)[0] != null

uses: tock/tock-hardware-ci/.github/workflows/treadmill-ci.yml@${{ env.TOCK_HARDWARE_CI_REF }}

with:
# Only run on a specific repository, as others will not have the right
# environments set up and secrets configured. Forks may want to change
Expand All @@ -59,9 +110,12 @@ jobs:

# Use the latest upstream Tock hardware CI tests and userspace components:
libtock-c-ref: 'master'
tock-hardware-ci-ref: 'main'
tock-hardware-ci-ref: ${{ env.TOCK_HARDWARE_CI_REF }}

# Test the tock kernel revision that triggered this workflow
tock-kernel-ref: ${{ github.sha }}

# Pass the selected tests
tests-json: ${{ needs.determine-tests.outputs.hwci-tests-json }}

secrets: inherit

0 comments on commit e298e58

Please sign in to comment.