|
| 1 | +name: TRICE Library CI (Reusable) |
| 2 | + |
| 3 | +on: |
| 4 | + # This workflow is not triggered directly by pushes or schedules. |
| 5 | + # It is meant to be called from other workflows via "workflow_call". |
| 6 | + workflow_call: |
| 7 | + inputs: |
| 8 | + toolchain_gcc_trice_on: |
| 9 | + description: "Run gcc build for all targets with TRICE enabled" |
| 10 | + required: false |
| 11 | + type: boolean |
| 12 | + default: true |
| 13 | + toolchain_gcc_trice_off: |
| 14 | + description: "Run gcc build for all targets with TRICE disabled (TRICE_OFF=1)" |
| 15 | + required: false |
| 16 | + type: boolean |
| 17 | + default: true |
| 18 | + toolchain_clang: |
| 19 | + description: "Run clang build(s) that exist (currently only G0B1_inst/build_with_clang.sh via ci_build.sh)" |
| 20 | + required: false |
| 21 | + type: boolean |
| 22 | + default: true |
| 23 | + |
| 24 | + configs_mode: |
| 25 | + description: "Configuration sweep mode: none|quick|full" |
| 26 | + required: false |
| 27 | + type: string |
| 28 | + default: "none" |
| 29 | + |
| 30 | + configs_start: |
| 31 | + description: "Start configuration for quick mode (inclusive)" |
| 32 | + required: false |
| 33 | + type: number |
| 34 | + default: 0 |
| 35 | + configs_end: |
| 36 | + description: "End configuration for quick mode (inclusive)" |
| 37 | + required: false |
| 38 | + type: number |
| 39 | + default: 10 |
| 40 | + |
| 41 | + upload_artifacts: |
| 42 | + description: "Upload .elf/.hex/.bin as workflow artifacts" |
| 43 | + required: false |
| 44 | + type: boolean |
| 45 | + default: true |
| 46 | + |
| 47 | +permissions: |
| 48 | + contents: read |
| 49 | + |
| 50 | +jobs: |
| 51 | + build: |
| 52 | + name: Heavy build & compile checks |
| 53 | + runs-on: ubuntu-latest |
| 54 | + |
| 55 | + # Concurrency prevents multiple heavy builds for the same branch from running |
| 56 | + # in parallel, which can waste significant CI minutes. |
| 57 | + concurrency: |
| 58 | + group: trice-lib-ci-${{ github.workflow }}-${{ github.ref }} |
| 59 | + cancel-in-progress: false |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + # Full history makes it easier to debug "what changed", and allows git-based |
| 66 | + # checks if you ever add them inside the build scripts. |
| 67 | + fetch-depth: 0 |
| 68 | + |
| 69 | + - name: Install toolchains and build tools |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + set -euxo pipefail |
| 73 | + sudo apt-get update |
| 74 | + sudo apt-get install -y \ |
| 75 | + make \ |
| 76 | + python3 \ |
| 77 | + gcc-arm-none-eabi \ |
| 78 | + binutils-arm-none-eabi \ |
| 79 | + clang \ |
| 80 | + llvm \ |
| 81 | + lld |
| 82 | +
|
| 83 | + - name: Print tool versions |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + set -euxo pipefail |
| 87 | + arm-none-eabi-gcc --version || true |
| 88 | + arm-none-eabi-objcopy --version || true |
| 89 | + clang --version || true |
| 90 | + llvm-objcopy --version || true |
| 91 | + make --version |
| 92 | +
|
| 93 | + - name: Run build orchestrator (ci_build.sh) |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + set -euxo pipefail |
| 97 | + chmod +x ./ci_build.sh |
| 98 | +
|
| 99 | + # Make objcopy deterministic in CI. |
| 100 | + # This helps avoid failures caused by missing llvm-objcopy in PATH, |
| 101 | + # and matches the typical embedded toolchain expectation. |
| 102 | + export OBJCOPY=arm-none-eabi-objcopy |
| 103 | +
|
| 104 | + # 1) GCC all-target builds (TRICE ON/OFF) |
| 105 | + if [ "${{ inputs.toolchain_gcc_trice_on }}" = "true" ]; then |
| 106 | + ./ci_build.sh \ |
| 107 | + --toolchain=gcc \ |
| 108 | + --trice=on \ |
| 109 | + --configs=${{ inputs.configs_mode }} \ |
| 110 | + --configs-start=${{ inputs.configs_start }} \ |
| 111 | + --configs-end=${{ inputs.configs_end }} |
| 112 | + fi |
| 113 | +
|
| 114 | + if [ "${{ inputs.toolchain_gcc_trice_off }}" = "true" ]; then |
| 115 | + ./ci_build.sh \ |
| 116 | + --toolchain=gcc \ |
| 117 | + --trice=off \ |
| 118 | + --configs=none |
| 119 | + fi |
| 120 | +
|
| 121 | + # 2) Clang build(s) (as implemented in ci_build.sh) |
| 122 | + if [ "${{ inputs.toolchain_clang }}" = "true" ]; then |
| 123 | + ./ci_build.sh \ |
| 124 | + --toolchain=clang \ |
| 125 | + --trice=on \ |
| 126 | + --configs=none |
| 127 | + fi |
| 128 | +
|
| 129 | + - name: Upload build artifacts |
| 130 | + if: ${{ inputs.upload_artifacts }} |
| 131 | + uses: actions/upload-artifact@v4 |
| 132 | + with: |
| 133 | + name: trice-lib-artifacts |
| 134 | + path: | |
| 135 | + examples/**/out.*/*.elf |
| 136 | + examples/**/out.*/*.hex |
| 137 | + examples/**/out.*/*.bin |
| 138 | + if-no-files-found: warn |
0 commit comments