Skip to content

Commit

Permalink
Merge pull request #291 from pimoroni/experiment/multi-board-ci
Browse files Browse the repository at this point in the history
Build MicroPython for multiple boards
  • Loading branch information
Gadgetoid authored Mar 11, 2022
2 parents ab80bdd + dece2aa commit faa8398
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 225 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ jobs:
name: Linux
cache-key: linux
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk -DPICO_SDK_POST_LIST_DIRS=$GITHUB_WORKSPACE/pico-extras'
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
apt-packages: ccache

runs-on: ${{matrix.os}}

env:
PICO_SDK_PATH: $GITHUB_WORKSPACE/pico-sdk

steps:
- name: Compiler Cache
uses: actions/cache@v2
with:
path: /home/runner/.ccache
key: ccache-cmake-${{github.ref}}-${{github.sha}}
restore-keys: |
ccache-cmake-${{github.ref}}
ccache-cmake
- uses: actions/checkout@v2
with:
submodules: true
Expand All @@ -44,24 +53,35 @@ jobs:
with:
repository: raspberrypi/pico-extras
path: pico-extras
submodules: false # lwip breaks audio submodule fetchin
submodules: false # lwip breaks audio submodule fetching

# Linux deps
- name: Install deps
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install ${{matrix.apt-packages}}
- name: Install ARM Toolchain
if: runner.os == 'Linux'
working-directory: ${{runner.workspace}}
run: |
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
tar xf gcc-*.tar.bz2
cd gcc*/bin
pwd >> $GITHUB_PATH
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE ${{matrix.cmake-args}}
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${{matrix.cmake-args}}

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
run: |
ccache --zero-stats || true
cmake --build . --config $BUILD_TYPE -j 2
ccache --show-stats || true
116 changes: 80 additions & 36 deletions .github/workflows/micropython-badger2040.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,84 +7,128 @@ on:
types: [created]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
MICROPYTHON_VERSION: v1.18
BUILD_TYPE: Release
BOARD_TYPE: PICO
BOARD_TYPE: PICO
# MicroPython version will be contained in github.event.release.tag_name for releases
RELEASE_FILE: pimoroni-badger2040-${{github.event.release.tag_name || github.sha}}-micropython.uf2

jobs:
build:
name: ${{matrix.name}}
strategy:
matrix:
include:
- os: ubuntu-20.04
name: Linux
cache-key: linux
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk'
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib

runs-on: ${{matrix.os}}

deps:
runs-on: ubuntu-20.04
name: Dependencies
steps:
- name: Workspace Cache
id: cache
uses: actions/cache@v2
with:
path: ${{runner.workspace}}
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
restore-keys: |
workspace-micropython-${{env.MICROPYTHON_VERSION}}
# Check out MicroPython
- name: Checkout MicroPython
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: micropython/micropython
ref: ${{env.MICROPYTHON_VERSION}}
submodules: false # MicroPython submodules are hideously broken
path: micropython

- name: Fetch base MicroPython submodules
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: micropython
run: git submodule update --init

- name: Fetch Pico SDK submodules
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: micropython/lib/pico-sdk
run: git submodule update --init

- name: Build mpy-cross
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: micropython/mpy-cross
run: make

build:
needs: deps
name: Build Badger 2040
runs-on: ubuntu-20.04

steps:
- name: Compiler Cache
uses: actions/cache@v2
with:
path: /home/runner/.ccache
key: ccache-micropython-badger2040-${{github.ref}}-${{github.sha}}
restore-keys: |
ccache-micropython-badger2040-${{github.ref}}
ccache-micropython-badger2040-
- name: Workspace Cache
uses: actions/cache@v2
with:
path: ${{runner.workspace}}
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}
restore-keys: |
workspace-micropython-${{env.MICROPYTHON_VERSION}}
- uses: actions/checkout@v2
with:
submodules: true
path: pimoroni-pico-${{ github.sha }}

# Copy Python module files
- name: HACK - Copy board config fixup
if: env.BOARD_TYPE == 'PICO'
run: |
cp pimoroni-pico-${GITHUB_SHA}/micropython/badger2040-mpconfigboard.h micropython/ports/rp2/boards/PICO/mpconfigboard.h
# Linux deps
- name: Install deps
- name: Install Compiler & CCache
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install ${{matrix.apt-packages}}
sudo apt update && sudo apt install ccache
python3 -m pip install pillow
- name: Fetch base MicroPython submodules
shell: bash
working-directory: micropython
run: git submodule update --init

- name: Fetch Pico SDK submodules
shell: bash
working-directory: micropython/lib/pico-sdk
run: git submodule update --init
- name: Install ARM Toolchain
if: runner.os == 'Linux'
working-directory: ${{runner.workspace}}
run: |
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
tar xf gcc-*.tar.bz2
cd gcc*/bin
pwd >> $GITHUB_PATH
- name: Build mpy-cross
- name: Configure MicroPython
shell: bash
working-directory: micropython/mpy-cross
run: make
working-directory: micropython/ports/rp2
run: |
cmake -S . -B build-${{env.BOARD_TYPE}} -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/badger2040-micropython.cmake -DMICROPY_BOARD=${{env.BOARD_TYPE}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build MicroPython
shell: bash
working-directory: micropython/ports/rp2
run: make USER_C_MODULES=../../../pimoroni-pico-${GITHUB_SHA}/micropython/modules/badger2040-micropython.cmake -j2
run: |
ccache --zero-stats || true
cmake --build build-${{env.BOARD_TYPE}} -j 2
ccache --show-stats || true
- name: Rename .uf2 for artifact
shell: bash
working-directory: micropython/ports/rp2/build-${{env.BOARD_TYPE}}
run: |
cp firmware.uf2 ${{github.event.repository.name}}-${{github.sha}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
cp firmware.uf2 ${{github.event.repository.name}}-${{github.event.release.tag_name}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
cp firmware.uf2 ${{env.RELEASE_FILE}}
- name: Store .uf2 as artifact
uses: actions/upload-artifact@v2
with:
name: ${{github.event.repository.name}}-${{github.sha}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/${{github.event.repository.name}}-${{github.sha}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
name: ${{env.RELEASE_FILE}}
path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/${{env.RELEASE_FILE}}

- name: Upload .uf2
if: github.event_name == 'release'
Expand All @@ -94,5 +138,5 @@ jobs:
with:
asset_path: micropython/ports/rp2/build-${{env.BOARD_TYPE}}/firmware.uf2
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{github.event.repository.name}}-${{github.event.release.tag_name}}-badger2040-micropython-${{env.MICROPYTHON_VERSION}}.uf2
asset_name: ${{env.RELEASE_FILE}}
asset_content_type: application/octet-stream
11 changes: 10 additions & 1 deletion .github/workflows/micropython-with-blinka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: Linux
cache-key: linux
cmake-args: '-DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk'
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
apt-packages: ccache

runs-on: ${{matrix.os}}

Expand Down Expand Up @@ -82,6 +82,15 @@ jobs:
run: |
sudo apt update && sudo apt install ${{matrix.apt-packages}}
- name: Install ARM Toolchain
if: runner.os == 'Linux'
working-directory: ${{runner.workspace}}
run: |
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
tar xf gcc-*.tar.bz2
cd gcc*/bin
pwd >> $GITHUB_PATH
- name: Fetch base MicroPython submodules
shell: bash
working-directory: micropython
Expand Down
Loading

0 comments on commit faa8398

Please sign in to comment.