|
| 1 | +name: Build Project |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + preset: |
| 7 | + description: | |
| 8 | + 'CMake preset to build the project, run `cmake --build --list-presets' to see a complete list of options' |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + default: 'nucleo-debug' |
| 12 | + outputs: |
| 13 | + build-artifact: |
| 14 | + description: 'Build result artifact id for later use' |
| 15 | + value: ${{ jobs.build.outputs.build-artifact }} |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + preset: |
| 19 | + description: | |
| 20 | + 'CMake preset to build the project, run `cmake --build --list-presets' to see a complete list of options' |
| 21 | + required: true |
| 22 | + type: string |
| 23 | + default: 'nucleo-debug' |
| 24 | + |
| 25 | +jobs: |
| 26 | + build: |
| 27 | + name: Build Project |
| 28 | + runs-on: ubuntu-24.04 |
| 29 | + outputs: |
| 30 | + build-artifact: ${{ steps.upload-build-artifact.outputs.artifact-id }} |
| 31 | + container: |
| 32 | + image: jmaralo/hyperloop-upv-firmware:latest |
| 33 | + steps: |
| 34 | + - name: Clone Project |
| 35 | + uses: actions/checkout@v3 |
| 36 | + with: |
| 37 | + submodules: recursive |
| 38 | + - name: Configure |
| 39 | + run: | |
| 40 | + apt update && apt install -y sudo |
| 41 | + sudo apt update |
| 42 | + apt install -y python3.12-venv |
| 43 | + python3 -m venv virtual |
| 44 | + source virtual/bin/activate |
| 45 | + pip install -r requirements.txt |
| 46 | + shell: bash |
| 47 | + - name: Build |
| 48 | + run: | |
| 49 | + source virtual/bin/activate |
| 50 | + cmake --preset ${{ inputs.preset }} . |
| 51 | + cmake --build --preset ${{ inputs.preset }} |
| 52 | + shell: bash |
| 53 | + - name: Run Simulator Tests |
| 54 | + if: inputs.preset == 'simulator' |
| 55 | + run: | |
| 56 | + cd Tests |
| 57 | + echo "Running tests against $(cd .. && pwd)/out/build/simulator/latest.elf" |
| 58 | + set -e |
| 59 | + python3 test.py -uut="$(cd .. && pwd)/out/build/latest.elf" |
| 60 | + - name: Upload Build |
| 61 | + id: upload-build-artifact |
| 62 | + uses: actions/upload-artifact@v4 |
| 63 | + with: |
| 64 | + name: ${{ inputs.preset }} |
| 65 | + path: out/build/latest.elf |
| 66 | + retention-days: 7 |
| 67 | + compression-level: 0 |
| 68 | + if-no-files-found: error |
| 69 | + |
0 commit comments