|
1 | 1 | # .github/workflows/build-tock.yml |
2 | | -name: Build Tock OS (Abacus Variants) |
| 2 | +name: Build Tock OS (Abacus CI) |
3 | 3 |
|
4 | 4 | on: |
5 | 5 | push: |
6 | | - branches: ["**"] |
| 6 | + branches: ["**"] # any branch push |
7 | 7 | pull_request: |
| 8 | + branches: [main] # merges into main |
| 9 | + schedule: |
| 10 | + - cron: "0 6 * * *" # nightly (6 AM UTC) |
8 | 11 | workflow_dispatch: |
9 | 12 |
|
10 | 13 | jobs: |
11 | | - build-tock: |
12 | | - name: nrf52 (abacus = ${{ matrix.source }}) |
| 14 | + determine-matrix: |
13 | 15 | runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 18 | + steps: |
| 19 | + - id: set-matrix |
| 20 | + run: | |
| 21 | + echo "Event: ${{ github.event_name }}" |
| 22 | + echo "Ref: ${{ github.ref_name }}" |
| 23 | +
|
| 24 | + if [[ "${{ github.event_name }}" == "push" ]]; then |
| 25 | + # Only test the pushed branch (fast dev loop) |
| 26 | + echo 'matrix={"source":["ci-branch"]}' >> $GITHUB_OUTPUT |
| 27 | +
|
| 28 | + elif [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 29 | + # Full integration test for merges into main |
| 30 | + echo 'matrix={"source":["ci-branch","main","crate"]}' >> $GITHUB_OUTPUT |
| 31 | +
|
| 32 | + elif [[ "${{ github.event_name }}" == "schedule" ]]; then |
| 33 | + # Nightly stability check (main + future crate) |
| 34 | + echo 'matrix={"source":["main","crate"]}' >> $GITHUB_OUTPUT |
14 | 35 |
|
| 36 | + else |
| 37 | + # Manual dispatch = full test |
| 38 | + echo 'matrix={"source":["ci-branch","main","crate"]}' >> $GITHUB_OUTPUT |
| 39 | + fi |
| 40 | +
|
| 41 | + build-tock: |
| 42 | + needs: determine-matrix |
| 43 | + runs-on: ubuntu-latest |
15 | 44 | strategy: |
16 | 45 | fail-fast: false |
17 | | - matrix: |
18 | | - source: |
19 | | - - main |
20 | | - - ci-branch |
21 | | - # - crates-io # enable once crate is published |
| 46 | + matrix: ${{ fromJson(needs.determine-matrix.outputs.matrix) }} |
| 47 | + |
| 48 | + name: nrf52840dk (abacus = ${{ matrix.source }}) |
22 | 49 |
|
23 | 50 | steps: |
24 | | - - name: Checkout workflow repo |
25 | | - uses: actions/checkout@v4 |
26 | | - |
27 | | - - name: Install Rust + ARM target |
28 | | - run: | |
29 | | - rustup toolchain install stable |
30 | | - rustup default stable |
31 | | - rustup target add thumbv7em-none-eabihf |
32 | | -
|
33 | | - - name: Install system dependencies |
34 | | - run: | |
35 | | - sudo apt-get update |
36 | | - sudo apt-get install -y llvm clang make |
37 | | -
|
38 | | - - name: Clone Tock fork |
39 | | - run: | |
40 | | - git clone https://github.com/abacus-rs/tock.git |
41 | | - cd tock |
42 | | - git checkout master |
43 | | - git submodule update --init --recursive |
44 | | -
|
45 | | - # ------------------------------------ |
46 | | - # GLOBAL PATCH: abacus -> main |
47 | | - # Applies to entire workspace |
48 | | - # ------------------------------------ |
49 | | - - name: Override abacus_registers -> main (workspace-wide) |
50 | | - if: matrix.source == 'main' |
51 | | - run: | |
52 | | - cd tock |
53 | | - printf '\n[patch."https://github.com/abacus-rs/abacus-registers"]\n' >> Cargo.toml |
54 | | - printf 'abacus_registers = { git = "https://github.com/abacus-rs/abacus-registers", branch = "main" }\n' >> Cargo.toml |
55 | | -
|
56 | | - # ------------------------------------ |
57 | | - # GLOBAL PATCH: abacus -> CI branch |
58 | | - # Uses branch that triggered CI |
59 | | - # ------------------------------------ |
60 | | - - name: Override abacus_registers -> CI branch (workspace-wide) |
61 | | - if: matrix.source == 'ci-branch' |
62 | | - run: | |
63 | | - echo "CI branch detected: ${GITHUB_REF_NAME}" |
64 | | - cd tock |
65 | | - printf '\n[patch."https://github.com/abacus-rs/abacus-registers"]\n' >> Cargo.toml |
66 | | - printf 'abacus_registers = { git = "https://github.com/abacus-rs/abacus-registers", branch = "%s" }\n' "${GITHUB_REF_NAME}" >> Cargo.toml |
67 | | -
|
68 | | - # (Future) when crate is published |
69 | | - # - name: Override abacus_registers -> crates.io |
70 | | - # if: matrix.source == 'crates-io' |
71 | | - # run: | |
72 | | - # cd tock |
73 | | - # printf '\n[patch.crates-io]\n' >> Cargo.toml |
74 | | - # printf 'abacus_registers = { version = "*" }\n' >> Cargo.toml |
75 | | - |
76 | | - - name: Verify resolved abacus source |
77 | | - run: | |
78 | | - cd tock |
79 | | - cargo tree -i abacus_registers || true |
80 | | -
|
81 | | - - name: Build nrf52840dk |
82 | | - run: | |
83 | | - cd tock |
84 | | - make -C boards/nordic/nrf52840dk |
| 51 | + - name: Checkout abacus-registers repo (current branch) |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Install Rust + ARM target |
| 55 | + run: | |
| 56 | + rustup toolchain install stable |
| 57 | + rustup default stable |
| 58 | + rustup target add thumbv7em-none-eabihf |
| 59 | +
|
| 60 | + - name: Install system dependencies |
| 61 | + run: | |
| 62 | + sudo apt-get update |
| 63 | + sudo apt-get install -y llvm clang make |
| 64 | +
|
| 65 | + - name: Clone Tock |
| 66 | + run: | |
| 67 | + git clone https://github.com/abacus-rs/tock.git |
| 68 | + cd tock |
| 69 | + git checkout master |
| 70 | + git submodule update --init --recursive |
| 71 | +
|
| 72 | + # ------------------------------------------------- |
| 73 | + # Variant 1: Use CURRENT CI branch (most important) |
| 74 | + # BEST for pushes to feature branches |
| 75 | + # ------------------------------------------------- |
| 76 | + - name: Patch abacus_registers -> local checkout (CI branch) |
| 77 | + if: matrix.source == 'ci-branch' |
| 78 | + run: | |
| 79 | + echo "Using local abacus-registers checkout (branch: ${GITHUB_REF_NAME})" |
| 80 | + cd tock |
| 81 | + printf '\n[patch.crates-io]\n' >> Cargo.toml |
| 82 | + printf 'abacus_registers = { path = "../" }\n' >> Cargo.toml |
| 83 | +
|
| 84 | + # ------------------------------------------------- |
| 85 | + # Variant 2: Force main branch of abacus_registers |
| 86 | + # Used for PRs + nightly |
| 87 | + # ------------------------------------------------- |
| 88 | + - name: Patch abacus_registers -> git main |
| 89 | + if: matrix.source == 'main' |
| 90 | + run: | |
| 91 | + cd tock |
| 92 | + printf '\n[patch."https://github.com/abacus-rs/abacus-registers"]\n' >> Cargo.toml |
| 93 | + printf 'abacus_registers = { git = "https://github.com/abacus-rs/abacus-registers", branch = "main" }\n' >> Cargo.toml |
| 94 | +
|
| 95 | + # ------------------------------------------------- |
| 96 | + # Variant 3: crates.io (disabled until published) |
| 97 | + # ------------------------------------------------- |
| 98 | + - name: Patch abacus_registers -> crates.io |
| 99 | + if: matrix.source == 'crate' |
| 100 | + run: | |
| 101 | + cd tock |
| 102 | + printf '\n[patch.crates-io]\n' >> Cargo.toml |
| 103 | + printf 'abacus_registers = { version = "*" }\n' >> Cargo.toml |
| 104 | +
|
| 105 | + - name: Show resolved abacus source |
| 106 | + run: | |
| 107 | + cd tock |
| 108 | + cargo tree -i abacus_registers || true |
| 109 | +
|
| 110 | + - name: Build nrf52840dk |
| 111 | + run: | |
| 112 | + cd tock |
| 113 | + make -C boards/nordic/nrf52840dk |
0 commit comments