|
| 1 | +name: Build MicroPython |
| 2 | + |
| 3 | +# MicroPython has to git clone/checkout this repo commit SHA, so only run this |
| 4 | +# workflow on pushes, as PRs generate a "merge commit" that is not clonable. |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: '*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-micropython: |
| 11 | + runs-on: ubuntu-22.04 |
| 12 | + name: Build MicroPython |
| 13 | + steps: |
| 14 | + - name: Clone MicroPython |
| 15 | + uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + repository: 'microbit-foundation/micropython-microbit-v2' |
| 18 | + submodules: true |
| 19 | + - name: Setup arm-none-eabi-gcc v10.3 |
| 20 | + uses: carlosperate/arm-none-eabi-gcc-action@v1 |
| 21 | + with: |
| 22 | + release: 10.3-2021.10 |
| 23 | + - name: Install CMake v3.22 via PyPI |
| 24 | + run: python -m pip install cmake==3.22.1 |
| 25 | + - name: Check Versions |
| 26 | + run: | |
| 27 | + arm-none-eabi-gcc --version |
| 28 | + cmake --version |
| 29 | + - name: Modify codal.json to use this codal-microbit-v2 commit |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + python - << EOF |
| 33 | + import json, collections |
| 34 | +
|
| 35 | + with open('src/codal_app/codal.json', 'r') as f: |
| 36 | + codal_json = json.loads(f.read(), object_pairs_hook=collections.OrderedDict) |
| 37 | +
|
| 38 | + try: |
| 39 | + if codal_json['target']['url'] != "https://github.com/lancaster-university/codal-microbit-v2": |
| 40 | + print("Unexpected target URL value.") |
| 41 | + exit(1) |
| 42 | + # Just need to check this exists, we don't care about the value |
| 43 | + _ = codal_json['target']['branch'] |
| 44 | + except KeyError as e: |
| 45 | + print('The src/codal_app/codal.json structure has changed and expected keys are not found.') |
| 46 | + exit(1) |
| 47 | + else: |
| 48 | + codal_json['target']['url'] = codal_json['target']['url'].replace( |
| 49 | + 'lancaster-university/codal-microbit-v2', '${GITHUB_REPOSITORY}' |
| 50 | + ) |
| 51 | + codal_json['target']['branch'] = '${GITHUB_SHA}' |
| 52 | +
|
| 53 | + with open('src/codal_app/codal.json', 'w') as f: |
| 54 | + f.write(json.dumps(codal_json, indent=4)) |
| 55 | + EOF |
| 56 | + git diff src/codal_app/codal.json |
| 57 | + - name: Build MicroPython |
| 58 | + run: | |
| 59 | + make -C lib/micropython/mpy-cross -j4 |
| 60 | + cd src |
| 61 | + make -j4 |
| 62 | + - name: Upload hex file |
| 63 | + uses: actions/upload-artifact@v1 |
| 64 | + with: |
| 65 | + name: micropython-${{ github.sha }}.hex |
| 66 | + path: src/MICROBIT.hex |
0 commit comments