Skip to content

Commit 35e82a5

Browse files
authored
Merge pull request adafruit#7676 from microdev1/ci
CI: Enhancements & Refactoring
2 parents e346b73 + f0b509c commit 35e82a5

22 files changed

+158
-190
lines changed

.github/actions/deps/external/action.yml

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,31 @@ inputs:
99
- cache
1010
- restore
1111

12-
platform:
12+
port:
1313
required: false
1414
default: none
15-
type: choice
16-
options:
17-
- arm
18-
- aarch
19-
- esp
20-
- riscv
21-
- none
15+
type: string
2216

2317
runs:
2418
using: composite
2519
steps:
26-
# aarch
27-
- name: Get aarch toolchain
28-
if: inputs.platform == 'aarch'
29-
run: |
30-
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
31-
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
32-
sudo apt-get install -y mtools
33-
shell: bash
34-
- name: Install mkfs.fat
35-
if: inputs.platform == 'aarch'
36-
run: |
37-
wget https://github.com/dosfstools/dosfstools/releases/download/v4.2/dosfstools-4.2.tar.gz
38-
tar -xaf dosfstools-4.2.tar.gz
39-
cd dosfstools-4.2
40-
./configure
41-
make -j 2
42-
cd src
43-
echo >> $GITHUB_PATH $(pwd)
44-
shell: bash
45-
4620
# arm
4721
- name: Get arm toolchain
48-
if: inputs.platform == 'aarch' || inputs.platform == 'arm'
22+
if: >-
23+
inputs.port != 'none' &&
24+
inputs.port != 'litex' &&
25+
inputs.port != 'espressif'
4926
uses: carlosperate/arm-none-eabi-gcc-action@v1
5027
with:
5128
release: '10-2020-q4'
5229

53-
# esp
54-
- name: Get esp toolchain
55-
if: inputs.platform == 'esp'
30+
# espressif
31+
- name: Get espressif toolchain
32+
if: inputs.port == 'espressif'
5633
run: sudo apt-get install -y ninja-build
5734
shell: bash
5835
- name: Install IDF tools
59-
if: inputs.platform == 'esp'
36+
if: inputs.port == 'espressif'
6037
run: |
6138
echo "Installing ESP-IDF tools"
6239
$IDF_PATH/tools/idf_tools.py --non-interactive install required
@@ -66,24 +43,16 @@ runs:
6643
rm -rf $IDF_TOOLS_PATH/dist
6744
shell: bash
6845
- name: Set environment
69-
if: inputs.platform == 'esp'
46+
if: inputs.port == 'espressif'
7047
run: |
7148
source $IDF_PATH/export.sh
7249
echo >> $GITHUB_ENV "IDF_PYTHON_ENV_PATH=$IDF_PYTHON_ENV_PATH"
7350
echo >> $GITHUB_PATH "$PATH"
7451
shell: bash
7552

76-
# riscv
77-
- name: Get riscv toolchain
78-
if: inputs.platform == 'riscv'
79-
run: |
80-
wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
81-
sudo tar -C /usr --strip-components=1 -xaf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
82-
shell: bash
83-
8453
# common
8554
- name: Cache python dependencies
86-
if: inputs.platform != 'esp'
55+
if: inputs.port != 'espressif'
8756
uses: ./.github/actions/deps/python
8857
with:
8958
action: ${{ inputs.action }}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ runs:
1919
if [ -z $PORT ]; then (exit 1); else echo >> $GITHUB_OUTPUT "port=$PORT"; fi
2020
shell: bash
2121

22-
- name: Set up espressif port
22+
- name: Set up broadcom
23+
if: steps.board-to-port.outputs.port == 'broadcom'
24+
uses: ./.github/actions/deps/ports/broadcom
25+
26+
- name: Set up espressif
2327
if: steps.board-to-port.outputs.port == 'espressif'
2428
uses: ./.github/actions/deps/ports/espressif
2529

26-
- name: Set up nrf port
30+
- name: Set up litex
31+
if: steps.board-to-port.outputs.port == 'litex'
32+
uses: ./.github/actions/deps/ports/litex
33+
34+
- name: Set up nrf
2735
if: steps.board-to-port.outputs.port == 'nrf'
2836
uses: ./.github/actions/deps/ports/nrf
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Fetch broadcom port deps
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Get broadcom toolchain
7+
run: |
8+
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
9+
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
10+
sudo apt-get install -y mtools
11+
shell: bash
12+
- name: Install mkfs.fat
13+
run: |
14+
wget https://github.com/dosfstools/dosfstools/releases/download/v4.2/dosfstools-4.2.tar.gz
15+
tar -xaf dosfstools-4.2.tar.gz
16+
cd dosfstools-4.2
17+
./configure
18+
make -j 2
19+
cd src
20+
echo >> $GITHUB_PATH $(pwd)
21+
shell: bash
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Fetch litex port deps
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Get litex toolchain
7+
run: |
8+
wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
9+
sudo tar -C /usr --strip-components=1 -xaf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
10+
shell: bash

.github/workflows/build-boards.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ name: Build boards
33
on:
44
workflow_call:
55
inputs:
6-
platform:
7-
required: true
8-
type: string
96
boards:
107
required: true
118
type: string
@@ -19,7 +16,7 @@ on:
1916
required: false
2017

2118
jobs:
22-
build:
19+
board:
2320
runs-on: ubuntu-22.04
2421
env:
2522
CP_VERSION: ${{ inputs.cp-version }}
@@ -38,6 +35,7 @@ jobs:
3835
with:
3936
python-version: 3.x
4037
- name: Set up port
38+
id: set-up-port
4139
uses: ./.github/actions/deps/ports
4240
with:
4341
board: ${{ matrix.board }}
@@ -47,7 +45,7 @@ jobs:
4745
- name: Set up external
4846
uses: ./.github/actions/deps/external
4947
with:
50-
platform: ${{ inputs.platform }}
48+
port: ${{ steps.set-up-port.outputs.port }}
5149
- name: Set up mpy-cross
5250
if: steps.set-up-submodules.outputs.frozen == 'True'
5351
uses: ./.github/actions/mpy_cross

.github/workflows/build.yml

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ concurrency:
1818

1919
jobs:
2020
scheduler:
21-
runs-on: ubuntu-20.04
21+
runs-on: ubuntu-22.04
2222
outputs:
23-
build-doc: ${{ steps.set-matrix.outputs.build-doc }}
24-
build-boards: ${{ steps.set-matrix.outputs.build-boards }}
25-
build-windows: ${{ steps.set-matrix.outputs.build-windows }}
26-
boards-aarch: ${{ steps.set-matrix.outputs.boards-aarch }}
27-
boards-arm: ${{ steps.set-matrix.outputs.boards-arm }}
28-
boards-atmel: ${{ steps.set-matrix.outputs.boards-atmel }}
29-
boards-esp: ${{ steps.set-matrix.outputs.boards-esp }}
30-
boards-riscv: ${{ steps.set-matrix.outputs.boards-riscv }}
23+
docs: ${{ steps.set-matrix.outputs.docs }}
24+
ports: ${{ steps.set-matrix.outputs.ports }}
25+
windows: ${{ steps.set-matrix.outputs.windows }}
3126
cp-version: ${{ steps.set-up-submodules.outputs.version }}
3227
steps:
3328
- name: Dump GitHub context
@@ -99,7 +94,7 @@ jobs:
9994

10095
mpy-cross:
10196
needs: scheduler
102-
if: needs.scheduler.outputs.build-boards == 'True'
97+
if: needs.scheduler.outputs.ports != '{}'
10398
uses: ./.github/workflows/build-mpy-cross.yml
10499
secrets: inherit
105100
with:
@@ -108,7 +103,7 @@ jobs:
108103
mpy-cross-mac:
109104
runs-on: macos-11
110105
needs: scheduler
111-
if: needs.scheduler.outputs.build-boards == 'True'
106+
if: needs.scheduler.outputs.ports != '{}'
112107
env:
113108
CP_VERSION: ${{ needs.scheduler.outputs.cp-version }}
114109
steps:
@@ -160,10 +155,10 @@ jobs:
160155
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
161156
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
162157

163-
build-doc:
158+
docs:
164159
runs-on: ubuntu-22.04
165160
needs: scheduler
166-
if: needs.scheduler.outputs.build-doc == 'True'
161+
if: needs.scheduler.outputs.docs == 'True'
167162
env:
168163
CP_VERSION: ${{ needs.scheduler.outputs.cp-version }}
169164
steps:
@@ -218,10 +213,10 @@ jobs:
218213
[ -z "$TWINE_USERNAME" ] || echo "Uploading dev release to PyPi"
219214
[ -z "$TWINE_USERNAME" ] || twine upload circuitpython-stubs/dist/*
220215
221-
build-windows:
216+
windows:
222217
runs-on: windows-2022
223218
needs: scheduler
224-
if: needs.scheduler.outputs.build-windows == 'True'
219+
if: needs.scheduler.outputs.windows == 'True'
225220
env:
226221
CP_VERSION: ${{ needs.scheduler.outputs.cp-version }}
227222
defaults:
@@ -286,52 +281,15 @@ jobs:
286281
# ERROR: Platform MINGW64_NT-10.0-17763-x86_64 appears to be unsupported
287282
# https://github.com/espressif/esp-idf/issues/7062
288283

289-
aarch:
290-
needs: [scheduler, mpy-cross, tests]
291-
if: ${{ needs.scheduler.outputs.boards-aarch != '[]' }}
292-
uses: ./.github/workflows/build-boards.yml
293-
secrets: inherit
294-
with:
295-
platform: aarch
296-
boards: ${{ needs.scheduler.outputs.boards-aarch }}
297-
cp-version: ${{ needs.scheduler.outputs.cp-version }}
298-
299-
arm:
300-
needs: [scheduler, mpy-cross, tests]
301-
if: ${{ needs.scheduler.outputs.boards-arm != '[]' }}
302-
uses: ./.github/workflows/build-boards.yml
303-
secrets: inherit
304-
with:
305-
platform: arm
306-
boards: ${{ needs.scheduler.outputs.boards-arm }}
307-
cp-version: ${{ needs.scheduler.outputs.cp-version }}
308-
309-
atmel:
310-
needs: [scheduler, mpy-cross, tests]
311-
if: ${{ needs.scheduler.outputs.boards-atmel != '[]' }}
312-
uses: ./.github/workflows/build-boards.yml
313-
secrets: inherit
314-
with:
315-
platform: arm
316-
boards: ${{ needs.scheduler.outputs.boards-atmel }}
317-
cp-version: ${{ needs.scheduler.outputs.cp-version }}
318-
319-
esp:
320-
needs: [scheduler, mpy-cross, tests]
321-
if: ${{ needs.scheduler.outputs.boards-esp != '[]' }}
322-
uses: ./.github/workflows/build-boards.yml
323-
secrets: inherit
324-
with:
325-
platform: esp
326-
boards: ${{ needs.scheduler.outputs.boards-esp }}
327-
cp-version: ${{ needs.scheduler.outputs.cp-version }}
328-
329-
riscv:
284+
ports:
330285
needs: [scheduler, mpy-cross, tests]
331-
if: ${{ needs.scheduler.outputs.boards-riscv != '[]' }}
286+
if: needs.scheduler.outputs.ports != '{}'
332287
uses: ./.github/workflows/build-boards.yml
333288
secrets: inherit
289+
strategy:
290+
fail-fast: false
291+
matrix:
292+
port: ${{ fromJSON(needs.scheduler.outputs.ports).ports }}
334293
with:
335-
platform: riscv
336-
boards: ${{ needs.scheduler.outputs.boards-riscv }}
294+
boards: ${{ toJSON(fromJSON(needs.scheduler.outputs.ports)[matrix.port]) }}
337295
cp-version: ${{ needs.scheduler.outputs.cp-version }}

.github/workflows/build-boards-custom.yml renamed to .github/workflows/custom-board-build.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ run-name: ${{ inputs.board }}-${{ inputs.language }}-${{ inputs.version }}${{ in
3232
jobs:
3333
build:
3434
runs-on: ubuntu-22.04
35-
env:
36-
PLATFORM_atmel-samd: arm
37-
PLATFORM_broadcom: aarch
38-
PLATFORM_cxd56: arm
39-
PLATFORM_espressif: esp
40-
PLATFORM_litex: riscv
41-
PLATFORM_mimxrt10xx: arm
42-
PLATFORM_nrf: arm
43-
PLATFORM_raspberrypi: arm
44-
PLATFORM_stm: arm
4535
steps:
4636
- name: Set up repository
4737
run: |
@@ -70,7 +60,7 @@ jobs:
7060
uses: ./.github/actions/deps/external
7161
with:
7262
action: cache
73-
platform: ${{ env[format('PLATFORM_{0}', steps.set-up-port.outputs.port)] }}
63+
port: ${{ steps.set-up-port.outputs.port }}
7464
- name: Set up mpy-cross
7565
if: steps.set-up-submodules.outputs.frozen == 'True'
7666
uses: ./.github/actions/mpy_cross

.github/workflows/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
run:
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
strategy:
1414
fail-fast: false
1515
matrix:
@@ -31,7 +31,7 @@ jobs:
3131
- name: Set up python
3232
uses: actions/setup-python@v4
3333
with:
34-
python-version: 3.x
34+
python-version: 3.8
3535
- name: Set up submodules
3636
uses: ./.github/actions/deps/submodules
3737
with:

ports/atmel-samd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE)
367367
$(STEPECHO) "LINK $@"
368368
$(Q)echo $(OBJ) > $(BUILD)/firmware.objs
369369
$(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group
370-
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE)
370+
$(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)
371371

372372
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
373373
$(STEPECHO) "Create $@"

ports/espressif/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ $(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
434434
$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_info.py
435435
$(STEPECHO) "Create $@"
436436
$(Q)esptool.py --chip $(IDF_TARGET) elf2image $(FLASH_FLAGS) --elf-sha256-offset 0xb0 -o $@ $^
437-
$(Q)$(PYTHON) tools/build_memory_info.py $< $(BUILD)/esp-idf/sdkconfig $@
437+
$(Q)$(PYTHON) tools/build_memory_info.py $< $(BUILD)/esp-idf/sdkconfig $@ $(BUILD)
438438

439439
$(BUILD)/firmware.bin: $(BUILD)/circuitpython-firmware.bin | esp-idf-stamp
440440
$(Q)$(PYTHON) ../../tools/join_bins.py $@ $(BOOTLOADER_OFFSET) $(BUILD)/esp-idf/bootloader/bootloader.bin $(PARTITION_TABLE_OFFSET) $(BUILD)/esp-idf/partition_table/partition-table.bin $(FIRMWARE_OFFSET) $(BUILD)/circuitpython-firmware.bin

ports/espressif/tools/build_memory_info.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
# SPDX-License-Identifier: MIT
77

88
import csv
9+
import json
910
import os
10-
import re
1111
import sys
1212

1313
from elftools.elf.elffile import ELFFile
1414

15-
print()
1615

1716
internal_memory = {
1817
"esp32": [
@@ -117,8 +116,12 @@ def find_region(start_address):
117116

118117
# This file is the bin
119118
used_flash = os.stat(sys.argv[3]).st_size
120-
121119
free_flash = firmware_region - used_flash
120+
121+
with open(f"{sys.argv[4]}/firmware.size.json", "w") as f:
122+
json.dump({"used_flash": used_flash, "firmware_region": firmware_region}, f)
123+
124+
print()
122125
print(
123126
"{:7} bytes used, {:7} bytes free in flash firmware space out of {} bytes ({}kB).".format(
124127
used_flash, free_flash, firmware_region, firmware_region / 1024

0 commit comments

Comments
 (0)