.github: workflow update to be conditional jobs #5
This file contains hidden or 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
| # .github/workflows/build-tock.yml | |
| name: Build Tock OS (Abacus CI) | |
| on: | |
| push: | |
| branches: ["**"] # any branch push | |
| pull_request: | |
| branches: [main] # merges into main | |
| schedule: | |
| - cron: "0 6 * * *" # nightly (6 AM UTC) | |
| workflow_dispatch: | |
| jobs: | |
| determine-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - id: set-matrix | |
| run: | | |
| echo "Event: ${{ github.event_name }}" | |
| echo "Ref: ${{ github.ref_name }}" | |
| if [[ "${{ github.event_name }}" == "push" ]]; then | |
| # Only test the pushed branch (fast dev loop) | |
| echo 'matrix={"source":["ci-branch"]}' >> $GITHUB_OUTPUT | |
| elif [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| # Full integration test for merges into main | |
| echo 'matrix={"source":["ci-branch","main","crate"]}' >> $GITHUB_OUTPUT | |
| elif [[ "${{ github.event_name }}" == "schedule" ]]; then | |
| # Nightly stability check (main + future crate) | |
| echo 'matrix={"source":["main","crate"]}' >> $GITHUB_OUTPUT | |
| else | |
| # Manual dispatch = full test | |
| echo 'matrix={"source":["ci-branch","main","crate"]}' >> $GITHUB_OUTPUT | |
| fi | |
| build-tock: | |
| needs: determine-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.determine-matrix.outputs.matrix) }} | |
| name: nrf52840dk (abacus = ${{ matrix.source }}) | |
| steps: | |
| - name: Checkout abacus-registers repo (current branch) | |
| uses: actions/checkout@v4 | |
| - name: Install Rust + ARM target | |
| run: | | |
| rustup toolchain install stable | |
| rustup default stable | |
| rustup target add thumbv7em-none-eabihf | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y llvm clang make | |
| - name: Clone Tock | |
| run: | | |
| git clone https://github.com/abacus-rs/tock.git | |
| cd tock | |
| git checkout master | |
| git submodule update --init --recursive | |
| # ------------------------------------------------- | |
| # Variant 1: Use CURRENT CI branch (most important) | |
| # BEST for pushes to feature branches | |
| # ------------------------------------------------- | |
| - name: Patch abacus_registers -> local checkout (CI branch) | |
| if: matrix.source == 'ci-branch' | |
| run: | | |
| echo "Using local abacus-registers checkout (branch: ${GITHUB_REF_NAME})" | |
| cd tock | |
| printf '\n[patch.crates-io]\n' >> Cargo.toml | |
| printf 'abacus_registers = { path = "../" }\n' >> Cargo.toml | |
| # ------------------------------------------------- | |
| # Variant 2: Force main branch of abacus_registers | |
| # Used for PRs + nightly | |
| # ------------------------------------------------- | |
| - name: Patch abacus_registers -> git main | |
| if: matrix.source == 'main' | |
| run: | | |
| cd tock | |
| printf '\n[patch."https://github.com/abacus-rs/abacus-registers"]\n' >> Cargo.toml | |
| printf 'abacus_registers = { git = "https://github.com/abacus-rs/abacus-registers", branch = "main" }\n' >> Cargo.toml | |
| # ------------------------------------------------- | |
| # Variant 3: crates.io (disabled until published) | |
| # ------------------------------------------------- | |
| - name: Patch abacus_registers -> crates.io | |
| if: matrix.source == 'crate' | |
| run: | | |
| cd tock | |
| printf '\n[patch.crates-io]\n' >> Cargo.toml | |
| printf 'abacus_registers = { version = "*" }\n' >> Cargo.toml | |
| - name: Show resolved abacus source | |
| run: | | |
| cd tock | |
| cargo tree -i abacus_registers || true | |
| - name: Build nrf52840dk | |
| run: | | |
| cd tock | |
| make -C boards/nordic/nrf52840dk |