This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tock-hardware-ci/.github/workflows/self-test.yml | |
name: Hardware CI Self-Test | |
on: | |
push: | |
branches: | |
- master | |
- dev/tock-hardware-ci | |
pull_request: | |
merge_group: | |
permissions: | |
contents: read | |
id-token: write # Required for requesting GitHub App tokens | |
jobs: | |
notify-hardware-ci: | |
runs-on: ubuntu-latest | |
# Only run on the main tock-hardware-ci repository, not on forks | |
if: github.repository == 'tock/tock-hardware-ci' | |
steps: | |
- name: Trigger hardware CI test workflow | |
uses: actions/github-script@v7 | |
with: | |
# Use the default GITHUB_TOKEN since we're triggering a workflow in the same repo | |
github-token: ${{ github.token }} | |
script: | | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'treadmill-ci-test.yml', | |
ref: '${{ github.sha }}', | |
inputs: { | |
'tock-hardware-ci-ref': '${{ github.sha }}', | |
'tock-kernel-ref': 'master', | |
'libtock-c-ref': 'master' | |
} | |
}); | |
# Run local tests that don't require hardware | |
unit-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r hwci/requirements.txt -c hwci/requirements-frozen.txt | |
- name: Run tests with mock board | |
run: | | |
cd hwci | |
export PYTHONPATH="$PWD:$PYTHONPATH" | |
python3 core/main.py --board boards/mock_board.py --test tests/c_hello.py | |
# For reference, here's how one would set up cross-repo workflow dispatch if needed: | |
# | |
# notify-external-ci: | |
# runs-on: ubuntu-latest | |
# # Only run this job if GitHub App credentials are configured | |
# if: vars.TREADMILL_GH_APP_CLIENT_ID != '' | |
# | |
# steps: | |
# - id: generate-token | |
# name: Generate token for cross-repo access | |
# uses: actions/create-github-app-token@v1 | |
# with: | |
# app-id: ${{ vars.TREADMILL_GH_APP_CLIENT_ID }} | |
# private-key: ${{ secrets.TREADMILL_GH_APP_PRIVATE_KEY }} | |
# | |
# - name: Trigger external workflow | |
# uses: actions/github-script@v7 | |
# with: | |
# github-token: ${{ steps.generate-token.outputs.token }} | |
# script: | | |
# await github.rest.actions.createWorkflowDispatch({ | |
# owner: 'external-org', | |
# repo: 'external-repo', | |
# workflow_id: 'workflow.yml', | |
# ref: 'master' | |
# });`` |