|
| 1 | +name: Build Samples |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: '*' |
| 6 | + pull_request: |
| 7 | + branches: '*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-microbit-v2-samples: |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ubuntu-20.04, macos-11, windows-2019] |
| 14 | + gcc: ['7-2017-q4', 'latest'] |
| 15 | + cmake: ['3.6.0', ''] # Empty string installs the latest CMake release |
| 16 | + fail-fast: false |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + name: ${{ matrix.os }}, gcc ${{ matrix.gcc }}, cmake ${{ matrix.cmake || 'latest'}} |
| 19 | + steps: |
| 20 | + - name: Setup Python |
| 21 | + uses: actions/setup-python@v4 |
| 22 | + with: |
| 23 | + python-version: '3.8' |
| 24 | + - name: Setup arm-none-eabi-gcc ${{ matrix.gcc }} |
| 25 | + uses: carlosperate/arm-none-eabi-gcc-action@v1 |
| 26 | + with: |
| 27 | + release: ${{ matrix.gcc }} |
| 28 | + - name: Setup CMake ${{ matrix.cmake }} |
| 29 | + uses: jwlawson/actions-setup-cmake@v1 |
| 30 | + with: |
| 31 | + cmake-version: ${{ matrix.cmake }} |
| 32 | + - name: Install latest Ninja release via PyPI |
| 33 | + run: python -m pip install ninja |
| 34 | + - name: Check Versions |
| 35 | + run: | |
| 36 | + arm-none-eabi-gcc --version |
| 37 | + cmake --version |
| 38 | + ninja --version |
| 39 | + python --version |
| 40 | + - name: Clone the microbit-v2-samples repository |
| 41 | + uses: actions/checkout@v3 |
| 42 | + with: |
| 43 | + repository: 'lancaster-university/microbit-v2-samples' |
| 44 | + # We need to use the checkout action (instead of build.py cloning the |
| 45 | + # repository) so that on PRs we can get the commit from the PR merge |
| 46 | + - name: Clone the this repository in the libraries folder |
| 47 | + uses: actions/checkout@v3 |
| 48 | + with: |
| 49 | + path: libraries/codal-microbit-v2 |
| 50 | + fetch-depth: '0' |
| 51 | + # Changing the commit SHA might be unnecessary, as we've already cloned this |
| 52 | + # repo, but could be useful to ensure codal.json points to the same commit |
| 53 | + - name: Modify codal.json files to use this codal-microbit-v2 commit |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + echo "codal.json before:" |
| 57 | + cat codal.json |
| 58 | + python -c "import pathlib; \ |
| 59 | + f1 = pathlib.Path('codal.json'); \ |
| 60 | + f1.write_text(f1.read_text().replace(',\n \"dev\": true', '')); \ |
| 61 | + f1.write_text(f1.read_text().replace('master', '${GITHUB_SHA}')); \ |
| 62 | + f2 = pathlib.Path('codal.ble.json'); \ |
| 63 | + f2.write_text(f2.read_text().replace('master', '${GITHUB_SHA}')); \ |
| 64 | + f2.write_text(f2.read_text().replace(',\n \"dev\": true', ''))" |
| 65 | + echo "codal.json after:" |
| 66 | + cat codal.json |
| 67 | + - name: Build default (non-ble) project using build.py |
| 68 | + run: python build.py |
| 69 | + - name: Upload non-ble hex file |
| 70 | + if: runner.os == 'Windows' && matrix.gcc == 'latest' && matrix.cmake == '' |
| 71 | + uses: actions/upload-artifact@v1 |
| 72 | + with: |
| 73 | + name: codal-microbit-v2-${{ github.sha }} |
| 74 | + path: MICROBIT.hex |
| 75 | + - name: Prepare BLE example |
| 76 | + run: | |
| 77 | + rm codal.json |
| 78 | + mv codal.ble.json codal.json |
| 79 | + echo "codal.json:" |
| 80 | + cat codal.json |
| 81 | + python -c "import pathlib; \ |
| 82 | + f = pathlib.Path('source/main.cpp'); \ |
| 83 | + f.write_text(f.read_text().replace('out_of_box_experience()', 'ble_test()'))" |
| 84 | + echo "main.cpp:" |
| 85 | + cat source/main.cpp |
| 86 | + - name: Build BLE project using build.py |
| 87 | + run: python build.py --clean |
| 88 | + - name: Upload BLE hex file |
| 89 | + if: runner.os == 'Windows' && matrix.gcc == 'latest' && matrix.cmake == '' |
| 90 | + uses: actions/upload-artifact@v1 |
| 91 | + with: |
| 92 | + name: codal-microbit-v2-BLE-${{ github.sha }} |
| 93 | + path: MICROBIT.hex |
0 commit comments