Skip to content

Commit bf657e6

Browse files
authored
Merge pull request #7631 from MicroDev1/ci
CI: More fixes and refactoring
2 parents d5e936c + 60a9c7e commit bf657e6

File tree

8 files changed

+176
-161
lines changed

8 files changed

+176
-161
lines changed

.github/actions/deps/ports/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Fetch port deps
2+
3+
inputs:
4+
board:
5+
required: true
6+
type: string
7+
8+
outputs:
9+
port:
10+
value: ${{ steps.board-to-port.outputs.port }}
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Board to port
16+
id: board-to-port
17+
run: |
18+
PORT=$(find ports/*/boards/ -type d -name ${{ inputs.board }} | sed 's/^ports\///g;s/\/boards.*//g')
19+
if [ -z $PORT ]; then (exit 1); else echo >> $GITHUB_OUTPUT "port=$PORT"; fi
20+
shell: bash
21+
22+
- name: Set up espressif port
23+
if: steps.board-to-port.outputs.port == 'espressif'
24+
uses: ./.github/actions/deps/ports/espressif

.github/workflows/build-boards-custom.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,15 @@ jobs:
5151
if: inputs.debug || inputs.flags != ''
5252
run: |
5353
> custom-build && git add custom-build
54-
- name: Get port
55-
id: get-port
56-
run: |
57-
PORT=$(find ports/*/boards/ -type d -name ${{ inputs.board }} | sed 's/^ports\///g;s/\/boards.*//g')
58-
if [ -z $PORT ]; then (exit 1); else echo >> $GITHUB_OUTPUT "port=$PORT"; fi
59-
- name: Port to platform
60-
run: echo >> $GITHUB_ENV "PLATFORM=${{ env[format('PLATFORM_{0}', steps.get-port.outputs.port)] }}"
6154
- name: Set up python
6255
uses: actions/setup-python@v4
6356
with:
6457
python-version: 3.x
6558
- name: Set up port
66-
if: env.PLATFORM == 'esp'
67-
uses: ./.github/actions/deps/ports/espressif
59+
id: set-up-port
60+
uses: ./.github/actions/deps/ports
61+
with:
62+
board: ${{ inputs.board }}
6863
- name: Set up submodules
6964
id: set-up-submodules
7065
uses: ./.github/actions/deps/submodules
@@ -75,7 +70,7 @@ jobs:
7570
uses: ./.github/actions/deps/external
7671
with:
7772
action: cache
78-
platform: ${{ env.PLATFORM }}
73+
platform: ${{ env[format('PLATFORM_{0}', steps.set-up-port.outputs.port)] }}
7974
- name: Set up mpy-cross
8075
if: steps.set-up-submodules.outputs.frozen == 'True'
8176
uses: ./.github/actions/mpy_cross
@@ -96,9 +91,9 @@ jobs:
9691
mkfs.fat --version || true
9792
- name: Build board
9893
run: make -j2 ${{ inputs.flags }} BOARD=${{ inputs.board }} DEBUG=${{ inputs.debug && '1' || '0' }} TRANSLATION=${{ inputs.language }}
99-
working-directory: ports/${{ steps.get-port.outputs.port }}
94+
working-directory: ports/${{ steps.set-up-port.outputs.port }}
10095
- name: Upload artifact
10196
uses: actions/upload-artifact@v3
10297
with:
10398
name: ${{ inputs.board }}-${{ inputs.language }}-${{ inputs.version }}${{ inputs.flags != '' && '-custom' || '' }}${{ inputs.debug && '-debug' || '' }}
104-
path: ports/${{ steps.get-port.outputs.port }}/build-${{ inputs.board }}/firmware.*
99+
path: ports/${{ steps.set-up-port.outputs.port }}/build-${{ inputs.board }}/firmware.*

.github/workflows/build-boards.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ jobs:
3838
with:
3939
python-version: 3.x
4040
- name: Set up port
41-
if: inputs.platform == 'esp'
42-
uses: ./.github/actions/deps/ports/espressif
41+
uses: ./.github/actions/deps/ports
42+
with:
43+
board: ${{ matrix.board }}
4344
- name: Set up submodules
4445
id: set-up-submodules
4546
uses: ./.github/actions/deps/submodules

.github/workflows/build.yml

Lines changed: 86 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ jobs:
2222
outputs:
2323
build-doc: ${{ steps.set-matrix.outputs.build-doc }}
2424
build-boards: ${{ steps.set-matrix.outputs.build-boards }}
25+
build-windows: ${{ steps.set-matrix.outputs.build-windows }}
2526
boards-aarch: ${{ steps.set-matrix.outputs.boards-aarch }}
2627
boards-arm: ${{ steps.set-matrix.outputs.boards-arm }}
28+
boards-atmel: ${{ steps.set-matrix.outputs.boards-atmel }}
2729
boards-esp: ${{ steps.set-matrix.outputs.boards-esp }}
2830
boards-riscv: ${{ steps.set-matrix.outputs.boards-riscv }}
29-
boards-rpi: ${{ steps.set-matrix.outputs.boards-rpi }}
3031
cp-version: ${{ steps.set-up-submodules.outputs.version }}
3132
steps:
3233
- name: Dump GitHub context
@@ -54,6 +55,10 @@ jobs:
5455
uses: ./.github/actions/deps/external
5556
with:
5657
action: cache
58+
- name: Set up mpy-cross
59+
uses: ./.github/actions/mpy_cross
60+
with:
61+
download: false
5762
- name: Get last commit with checks
5863
id: get-last-commit-with-checks
5964
if: github.event_name == 'pull_request'
@@ -63,14 +68,10 @@ jobs:
6368
REPO: ${{ github.repository }}
6469
PULL: ${{ github.event.number }}
6570
GITHUB_TOKEN: ${{ github.token }}
66-
EXCLUDE_COMMIT: ${{ github.event.after }}
67-
- name: Set up mpy-cross
68-
uses: ./.github/actions/mpy_cross
69-
with:
70-
download: false
71+
EXCLUDE_COMMIT: ${{ github.event.pull_request.head.sha }}
7172
- name: Set head sha
7273
if: github.event_name == 'pull_request'
73-
run: echo "HEAD_SHA=$(git show -s --format=%s $GITHUB_SHA | grep -o -P "(?<=Merge ).*(?= into)")" >> $GITHUB_ENV
74+
run: echo "HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
7475
- name: Set base sha
7576
if: github.event_name == 'pull_request'
7677
run: |
@@ -218,6 +219,74 @@ jobs:
218219
[ -z "$TWINE_USERNAME" ] || echo "Uploading dev release to PyPi"
219220
[ -z "$TWINE_USERNAME" ] || twine upload circuitpython-stubs/dist/*
220221
222+
build-windows:
223+
runs-on: windows-2022
224+
needs: scheduler
225+
if: ${{ needs.scheduler.outputs.build-windows == 'True' }}
226+
env:
227+
CP_VERSION: ${{ needs.scheduler.outputs.cp-version }}
228+
defaults:
229+
run:
230+
# We define a custom shell script here, although `msys2.cmd` does neither exist nor is it available in the PATH yet
231+
shell: msys2 {0}
232+
steps:
233+
# We want to change the configuration of the git command that actions/checkout will be using
234+
# (since it is not possible to set autocrlf through the action yet, see actions/checkout#226).
235+
- run: git config --global core.autocrlf input
236+
shell: bash
237+
- name: Check python coding (cmd)
238+
run: python -c "import sys, locale; print(sys.getdefaultencoding(), locale.getpreferredencoding(False))"
239+
shell: cmd
240+
# We use a JS Action, which calls the system terminal or other custom terminals directly, if required
241+
- uses: msys2/setup-msys2@v2
242+
with:
243+
install: base-devel git wget unzip gcc python-pip
244+
# The goal of this was to test how things worked when the default file encoding (locale.getpreferedencoding())
245+
# was not UTF-8. However, msys2 python does use utf-8 as the preferred file encoding, and using actions/setup-python
246+
# python3.8 gave a broken build, so we're not really testing what we wanted to test.
247+
# However, commandline length limits are being tested so that does some good.
248+
- name: Check python coding (msys2)
249+
run: |
250+
locale -v
251+
which python; python --version
252+
python -c "import sys, locale; print(sys.getdefaultencoding(), locale.getpreferredencoding(False))"
253+
which python3; python3 --version
254+
python3 -c "import sys, locale; print(sys.getdefaultencoding(), locale.getpreferredencoding(False))"
255+
- name: Install dependencies
256+
run: |
257+
wget --no-verbose -O gcc-arm.zip https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-win32.zip
258+
unzip -q -d /tmp gcc-arm.zip
259+
tar -C /tmp/gcc-arm-none-* -cf - . | tar -C /usr/local -xf -
260+
pip install wheel
261+
# requirements_dev.txt doesn't install on windows. (with msys2 python)
262+
# instead, pick a subset for what we want to do
263+
pip install cascadetoml jinja2 typer click intelhex
264+
# check that installed packages work....?
265+
which python; python --version; python -c "import cascadetoml"
266+
which python3; python3 --version; python3 -c "import cascadetoml"
267+
- name: Set up repository
268+
uses: actions/checkout@v3
269+
with:
270+
submodules: false
271+
fetch-depth: 1
272+
- name: Set up submodules
273+
uses: ./.github/actions/deps/submodules
274+
- name: build mpy-cross
275+
run: make -j2 -C mpy-cross
276+
- name: build rp2040
277+
run: make -j2 -C ports/raspberrypi BOARD=adafruit_feather_rp2040 TRANSLATION=de_DE
278+
- name: build samd21
279+
run: make -j2 -C ports/atmel-samd BOARD=feather_m0_express TRANSLATION=zh_Latn_pinyin
280+
- name: build samd51
281+
run: make -j2 -C ports/atmel-samd BOARD=feather_m4_express TRANSLATION=es
282+
- name: build nrf
283+
run: make -j2 -C ports/nrf BOARD=feather_nrf52840_express TRANSLATION=fr
284+
- name: build stm
285+
run: make -j2 -C ports/stm BOARD=feather_stm32f405_express TRANSLATION=pt_BR
286+
# I gave up trying to do esp builds on windows when I saw
287+
# ERROR: Platform MINGW64_NT-10.0-17763-x86_64 appears to be unsupported
288+
# https://github.com/espressif/esp-idf/issues/7062
289+
221290
aarch:
222291
needs: [scheduler, mpy-cross, tests]
223292
if: ${{ needs.scheduler.outputs.boards-aarch != '[]' }}
@@ -238,6 +307,16 @@ jobs:
238307
boards: ${{ needs.scheduler.outputs.boards-arm }}
239308
cp-version: ${{ needs.scheduler.outputs.cp-version }}
240309

310+
atmel:
311+
needs: [scheduler, mpy-cross, tests]
312+
if: ${{ needs.scheduler.outputs.boards-atmel != '[]' }}
313+
uses: ./.github/workflows/build-boards.yml
314+
secrets: inherit
315+
with:
316+
platform: arm
317+
boards: ${{ needs.scheduler.outputs.boards-atmel }}
318+
cp-version: ${{ needs.scheduler.outputs.cp-version }}
319+
241320
esp:
242321
needs: [scheduler, mpy-cross, tests]
243322
if: ${{ needs.scheduler.outputs.boards-esp != '[]' }}
@@ -257,13 +336,3 @@ jobs:
257336
platform: riscv
258337
boards: ${{ needs.scheduler.outputs.boards-riscv }}
259338
cp-version: ${{ needs.scheduler.outputs.cp-version }}
260-
261-
rpi:
262-
needs: [scheduler, mpy-cross, tests]
263-
if: ${{ needs.scheduler.outputs.boards-rpi != '[]' }}
264-
uses: ./.github/workflows/build-boards.yml
265-
secrets: inherit
266-
with:
267-
platform: arm
268-
boards: ${{ needs.scheduler.outputs.boards-rpi }}
269-
cp-version: ${{ needs.scheduler.outputs.cp-version }}

.github/workflows/ports_windows.yml

Lines changed: 0 additions & 111 deletions
This file was deleted.

tools/ci_changes_per_commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def get_bad_check_runs(query_check_runs):
172172

173173
run_types = ["failed", "incomplete"]
174174

175-
regex_matrix = re.compile("^[^\n ]+ \/ (build|run) \([^\n ]+\)$")
175+
regex_matrix = re.compile(r"^\S+ \/ (build|run) \(\S+\)$")
176176

177177
while more_pages:
178178
check_runs = query_check_runs.fetch()["data"]["node"]

tools/ci_fetch_deps.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@ def main():
8080
submodules = ["extmod/ulab", "lib/", "tools/"]
8181
elif TARGET == "build-doc":
8282
# used in .readthedocs.yml to generate RTD
83-
submodules = ["extmod/ulab", "frozen/"]
83+
submodules = ["extmod/ulab"]
84+
submodules_tags = ["frozen/"]
8485
elif TARGET == "mpy-cross" or TARGET == "mpy-cross-mac":
8586
submodules = ["tools/"] # for huffman
86-
elif TARGET == "windows":
87+
elif TARGET == "build-windows":
8788
# This builds one board from a number of ports so fill out a bunch of submodules
8889
submodules = ["extmod/ulab", "lib/", "tools/", "ports/", "data/nvm.toml"]
8990
elif TARGET == "website":
90-
submodules = ["tools/adabot/", "frozen/"]
91+
submodules = ["tools/adabot/"]
92+
submodules_tags = ["frozen/"]
9193
elif TARGET == "pre-commit":
9294
submodules = ["extmod/ulab"]
9395
else:

0 commit comments

Comments
 (0)