Skip to content

Commit 4d41681

Browse files
authored
Merge pull request #55 from pimoroni/ci/refactor
CI: Rely less on GitHub actions workflows.
2 parents 96a732b + 7ad9a2f commit 4d41681

32 files changed

+888
-259
lines changed

.github/workflows/micropython.yml

Lines changed: 33 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,28 @@ on:
66
release:
77
types: [created]
88

9-
env:
10-
MICROPYTHON_VERSION: feature/presto-wireless
11-
MICROPYTHON_FLAVOUR: pimoroni
12-
PIMORONI_PICO_VERSION: feature/picovector2-and-layers
13-
149
jobs:
1510
build:
16-
name: ${{ matrix.name }} (${{ matrix.board }} ${{ matrix.variant }} ${{ matrix.modules }})
17-
runs-on: ubuntu-latest
11+
name: MicroPython ${{ matrix.name }}
12+
runs-on: ubuntu-24.04
1813
continue-on-error: true
1914
strategy:
2015
matrix:
2116
include:
2217
- name: presto
23-
board: presto
24-
variant:
25-
modules: default
2618

2719
env:
2820
# MicroPython version will be contained in github.event.release.tag_name for releases
29-
RELEASE_FILE: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython
30-
PIMORONI_PICO_DIR: "${{ github.workspace }}/pimoroni-pico"
31-
USER_C_MODULES: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.cmake"
32-
USER_FS_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.txt"
33-
USER_FS_SOURCE: "${{ github.workspace }}/src-${{ github.sha }}/examples"
34-
TAG_OR_SHA: ${{ github.event.release.tag_name || github.sha }}
35-
MICROPY_BOARD: ${{ matrix.board }}
36-
MICROPY_BOARD_VARIANT: ${{ matrix.variant }}
37-
MICROPY_BOARD_DIR: "${{ github.workspace }}/src-${{ github.sha }}/${{ matrix.BOARD }}"
38-
MICROPY_FROZEN_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.py"
39-
BOARD_NAME: ${{ matrix.name }}
40-
BUILD_TOOLS: src-${{ github.sha }}/ci/micropython.sh
21+
CI_RELEASE_FILENAME: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython
22+
CI_PROJECT_ROOT: ${{ github.workspace }}/src-${{ github.sha }}
23+
CI_BUILD_ROOT: ${{ github.workspace }}
24+
CI_USE_ENV: 1
4125

4226
steps:
4327
- name: Compiler Cache Fixup
4428
run: |
4529
mkdir -p /home/runner/.ccache
46-
30+
4731
- name: "CCache: Restore saved cache"
4832
uses: actions/cache@v4
4933
with:
@@ -53,108 +37,59 @@ jobs:
5337
ccache-micropython-${{ matrix.name }}-${{ github.ref }}
5438
ccache-micropython-${{ matrix.name }}-
5539
56-
- name: "Src: Checkout"
40+
- name: "Checkout Project"
5741
uses: actions/checkout@v4
5842
with:
5943
submodules: true
60-
path: src-${{ github.sha }}
44+
path: ${{ env.CI_PROJECT_ROOT }}
6145

62-
- name: "Pimoroni Pico: Checkout"
63-
uses: actions/checkout@v4
64-
with:
65-
repository: pimoroni/pimoroni-pico
66-
ref: ${{env.PIMORONI_PICO_VERSION}}
67-
submodules: true
68-
path: pimoroni-pico
69-
70-
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
46+
- name: "Install Arm GNU Toolchain (arm-none-eabi-gcc)"
7147
uses: carlosperate/arm-none-eabi-gcc-action@v1
7248
with:
7349
release: '13.3.Rel1'
7450

75-
- name: "CCache: Install"
76-
run: |
77-
source $BUILD_TOOLS
78-
apt_install_build_deps
79-
80-
- name: "MicroPython: Checkout"
81-
run: |
82-
source $BUILD_TOOLS
83-
micropython_clone
84-
85-
- name: "Py_Decl: Checkout"
86-
uses: actions/checkout@v4
87-
with:
88-
repository: gadgetoid/py_decl
89-
ref: v0.0.4
90-
path: py_decl
91-
92-
- name: "dir2uf2: Checkout"
93-
uses: actions/checkout@v4
94-
with:
95-
repository: gadgetoid/dir2uf2
96-
ref: v0.0.10
97-
path: dir2uf2
98-
99-
- name: "MicroPython: Build MPY Cross"
51+
- name: "Prepare tools & dependencies"
52+
shell: bash
10053
run: |
101-
source $BUILD_TOOLS
102-
micropython_build_mpy_cross
54+
source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug
55+
mkdir -p $CI_BUILD_ROOT
56+
ci_apt_install_build_deps
57+
ci_prepare_all
10358
10459
- name: "MicroPython: Configure"
10560
shell: bash
10661
run: |
107-
source $BUILD_TOOLS
62+
source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug
10863
micropython_version
109-
cmake_configure
64+
ci_cmake_configure ${{ matrix.name }}
11065
11166
- name: "MicroPython: Build"
11267
shell: bash
11368
run: |
114-
source $BUILD_TOOLS
115-
cmake_build
116-
117-
- name: "Py_Decl: Verify .uf2"
118-
shell: bash
119-
run: |
120-
python3 py_decl/py_decl.py --to-json --verify build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2
121-
122-
- name: "dir2uf2: Append filesystem to .uf2"
123-
shell: bash
124-
run: |
125-
python3 -m pip install littlefs-python==0.12.0
126-
./dir2uf2/dir2uf2 --fs-compact --append-to build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 --manifest ${{env.USER_FS_MANIFEST}} --filename with-filesystem.uf2 ${{env.USER_FS_SOURCE}}/
69+
source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug
70+
ci_cmake_build ${{ matrix.name }}
12771
12872
- name: "Artifacts: Upload .uf2"
12973
uses: actions/upload-artifact@v4
13074
with:
131-
name: ${{ env.RELEASE_FILE }}.uf2
132-
path: build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2
133-
134-
- name: "Artifacts: Upload .uf2 with filesystem"
75+
name: ${{ env.CI_RELEASE_FILENAME }}.uf2
76+
path: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}.uf2
77+
78+
- name: "Artifacts: Upload .uf2 (With Filesystem)"
13579
uses: actions/upload-artifact@v4
13680
with:
137-
name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
138-
path: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
81+
if-no-files-found: ignore
82+
name: ${{ env.CI_RELEASE_FILENAME }}-with-filesystem.uf2
83+
path: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}-with-filesystem.uf2
13984

14085
- name: "Release: Upload .uf2"
14186
if: github.event_name == 'release'
142-
uses: actions/upload-release-asset@v1
143-
env:
144-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
uses: softprops/action-gh-release@v1
14588
with:
146-
asset_path: build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2
147-
upload_url: ${{ github.event.release.upload_url }}
148-
asset_name: ${{ env.RELEASE_FILE }}.uf2
149-
asset_content_type: application/octet-stream
89+
files: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}.uf2
15090

151-
- name: "Release: Upload .uf2 with filesystem"
152-
if: github.event_name == 'release'
153-
uses: actions/upload-release-asset@v1
154-
env:
155-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
- name: "Release: Upload .uf2 (With Filesystem)"
92+
if: ${{ github.event_name == 'release' && hashFiles('${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}-with-filesystem.uf2') != '' }}
93+
uses: softprops/action-gh-release@v1
15694
with:
157-
asset_path: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
158-
upload_url: ${{ github.event.release.upload_url }}
159-
asset_name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
160-
asset_content_type: application/octet-stream
95+
files: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}-with-filesystem.uf2

boards/common.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Make sure we get our VirtualEnv Python
2+
set(Python_FIND_VIRTUALENV "FIRST")
3+
set(Python_FIND_UNVERSIONED_NAMES "FIRST")
4+
set(Python_FIND_STRATEGY "LOCATION")
5+
find_package (Python COMPONENTS Interpreter Development)
6+
7+
message("dir2uf2/py_decl: Using Python ${Python_EXECUTABLE}")
8+
MESSAGE("dir2uf2/py_decl: Using pimoroni tools dir ${PIMORONI_TOOLS_DIR}")
9+
10+
# Convert supplies paths to absolute, for a quieter life
11+
get_filename_component(PIMORONI_UF2_MANIFEST ${PIMORONI_UF2_MANIFEST} REALPATH)
12+
get_filename_component(PIMORONI_UF2_DIR ${PIMORONI_UF2_DIR} REALPATH)
13+
14+
if (EXISTS "${PIMORONI_TOOLS_DIR}/py_decl/py_decl.py")
15+
MESSAGE("py_decl: py_decl.py found, will verify uf2.")
16+
add_custom_target("${MICROPY_TARGET}-verify" ALL
17+
COMMAND ${Python_EXECUTABLE} "${PIMORONI_TOOLS_DIR}/py_decl/py_decl.py" --to-json --verify "${CMAKE_CURRENT_BINARY_DIR}/${MICROPY_TARGET}.uf2"
18+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
19+
COMMENT "pydecl: Verifying ${MICROPY_TARGET}.uf2"
20+
DEPENDS ${MICROPY_TARGET}
21+
)
22+
endif()
23+
24+
if (EXISTS "${PIMORONI_TOOLS_DIR}/dir2uf2/dir2uf2" AND EXISTS "${PIMORONI_UF2_MANIFEST}" AND EXISTS "${PIMORONI_UF2_DIR}")
25+
MESSAGE("dir2uf2: Using manifest ${PIMORONI_UF2_MANIFEST}.")
26+
MESSAGE("dir2uf2: Using root ${PIMORONI_UF2_DIR}.")
27+
add_custom_target("${MICROPY_TARGET}-with-filesystem.uf2" ALL
28+
COMMAND ${Python_EXECUTABLE} "${PIMORONI_TOOLS_DIR}/dir2uf2/dir2uf2" --fs-compact --sparse --append-to "${MICROPY_TARGET}.uf2" --manifest "${PIMORONI_UF2_MANIFEST}" --filename with-filesystem.uf2 "${PIMORONI_UF2_DIR}"
29+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
30+
COMMENT "dir2uf2: Appending filesystem to ${MICROPY_TARGET}.uf2."
31+
DEPENDS ${MICROPY_TARGET}
32+
DEPENDS "${MICROPY_TARGET}-verify"
33+
)
34+
else()
35+
MESSAGE("dir2uf2: Could not find manifest ${PIMORONI_UF2_MANIFEST}")
36+
MESSAGE(" and/or root ${PIMORONI_UF2_DIR}.")
37+
endif()

modules/default.py renamed to boards/manifest-common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
include("$(BOARD_DIR)/manifest.py")
2020

2121
# Include pga/modules/py_frozen
22-
freeze("py_frozen/")
22+
freeze("../modules/py_frozen/")

boards/presto/manifest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include("$(PORT_DIR)/boards/manifest.py")
2+
include("../manifest-common.py")

boards/presto/manifest.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.af
2+
*.png
3+
main.py
4+
cheerlights_bulb.py
5+
cubes.py
6+
image_gallery.py
7+
random_maze.py
8+
secrets.py
9+
stop_watch.py
10+
tomato.py
11+
vector_clock_full.py
12+
word_clock.py
13+
gallery/*.jpg

presto/mpconfigboard.cmake renamed to boards/presto/mpconfigboard.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,11 @@ set(MICROPY_BLUETOOTH_BTSTACK ON)
4040
# MICROPY_PY_BLUETOOTH_CYW43 = 1
4141
set(MICROPY_PY_BLUETOOTH_CYW43 ON)
4242

43-
set(MICROPY_HW_ENABLE_PSRAM ON)
43+
set(MICROPY_HW_ENABLE_PSRAM ON)
44+
45+
# Board specific version of the frozen manifest
46+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
47+
48+
set(PIMORONI_UF2_MANIFEST ${MICROPY_BOARD_DIR}/manifest.txt)
49+
set(PIMORONI_UF2_DIR ${CMAKE_CURRENT_LIST_DIR}/../../examples)
50+
include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake)
File renamed without changes.
File renamed without changes.

presto/presto.h renamed to boards/presto/presto.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
#define PICO_DEFAULT_I2C 0
4545
#endif
4646
#ifndef PICO_DEFAULT_I2C_SDA_PIN
47-
#define PICO_DEFAULT_I2C_SDA_PIN 4
47+
#define PICO_DEFAULT_I2C_SDA_PIN 40
4848
#endif
4949
#ifndef PICO_DEFAULT_I2C_SCL_PIN
50-
#define PICO_DEFAULT_I2C_SCL_PIN 5
50+
#define PICO_DEFAULT_I2C_SCL_PIN 41
5151
#endif
5252

5353
// --- SPI ---

boards/presto/usermodules.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../")
2+
3+
include(usermod-common)

0 commit comments

Comments
 (0)