Skip to content

Commit 23bb17c

Browse files
committed
use composite actions and reusable workflow
1 parent baaa236 commit 23bb17c

File tree

5 files changed

+293
-311
lines changed

5 files changed

+293
-311
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Fetch external deps
2+
3+
inputs:
4+
platform:
5+
required: false
6+
default: none
7+
type: choice
8+
options:
9+
- arm
10+
- aarch
11+
- espressif
12+
- riscv
13+
- none
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
# aarch
19+
- name: Get aarch toolchain
20+
if: inputs.platform == 'aarch'
21+
run: |
22+
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
23+
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
24+
sudo apt-get install -y mtools
25+
shell: bash
26+
- name: Install mkfs.fat
27+
if: inputs.platform == 'aarch'
28+
run: |
29+
wget https://github.com/dosfstools/dosfstools/releases/download/v4.2/dosfstools-4.2.tar.gz
30+
tar -xaf dosfstools-4.2.tar.gz
31+
cd dosfstools-4.2
32+
./configure
33+
make -j 2
34+
cd src
35+
echo >> $GITHUB_PATH $(pwd)
36+
shell: bash
37+
38+
# arm
39+
- name: Get arm toolchain
40+
if: inputs.platform == 'aarch' || inputs.platform == 'arm'
41+
uses: carlosperate/arm-none-eabi-gcc-action@v1
42+
with:
43+
release: '10-2020-q4'
44+
45+
# espressif
46+
- name: Get espressif toolchain
47+
if: inputs.platform == 'espressif'
48+
run: sudo apt-get install -y ninja-build
49+
shell: bash
50+
- name: Install IDF tools
51+
if: inputs.platform == 'espressif'
52+
run: |
53+
echo "Installing ESP-IDF tools"
54+
$IDF_PATH/tools/idf_tools.py --non-interactive install required
55+
$IDF_PATH/tools/idf_tools.py --non-interactive install cmake
56+
echo "Installing Python environment and packages"
57+
$IDF_PATH/tools/idf_tools.py --non-interactive install-python-env
58+
rm -rf $IDF_TOOLS_PATH/dist
59+
shell: bash
60+
- name: Set environment
61+
if: inputs.platform == 'espressif'
62+
run: |
63+
source $IDF_PATH/export.sh
64+
echo >> $GITHUB_ENV "IDF_PYTHON_ENV_PATH=$IDF_PYTHON_ENV_PATH"
65+
echo >> $GITHUB_PATH "$PATH"
66+
shell: bash
67+
68+
# riscv
69+
- name: Get riscv toolchain
70+
if: inputs.platform == 'riscv'
71+
run: |
72+
wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
73+
sudo tar -C /usr --strip-components=1 -xaf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
74+
shell: bash
75+
76+
# common
77+
- name: Install dependencies
78+
run: |
79+
sudo apt-get install -y gettext
80+
pip install -r requirements-dev.txt
81+
shell: bash

.github/actions/port_deps/action.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Fetch port deps
2+
3+
inputs:
4+
platform:
5+
required: false
6+
default: none
7+
type: choice
8+
options:
9+
- espressif
10+
- none
11+
12+
runs:
13+
using: composite
14+
steps:
15+
# espressif
16+
- name: Set IDF env
17+
if: inputs.platform == 'espressif'
18+
run: |
19+
echo >> $GITHUB_ENV "IDF_PATH=$GITHUB_WORKSPACE/ports/espressif/esp-idf"
20+
echo >> $GITHUB_ENV "IDF_TOOLS_PATH=$GITHUB_WORKSPACE/.idf_tools"
21+
shell: bash
22+
23+
- name: Get IDF commit
24+
if: inputs.platform == 'espressif'
25+
id: idf-commit
26+
run: |
27+
COMMIT=$(git submodule status ports/espressif/esp-idf | grep -o -P '(?<=^-).*(?= )')
28+
echo "$COMMIT"
29+
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
30+
shell: bash
31+
32+
- name: Cache IDF submodules
33+
if: inputs.platform == 'espressif'
34+
uses: actions/cache@v3
35+
with:
36+
path: |
37+
.git/modules/ports/espressif/esp-idf
38+
ports/espressif/esp-idf
39+
key: submodules-idf-${{ steps.idf-commit.outputs.commit }}
40+
41+
- name: Cache IDF tools
42+
if: inputs.platform == 'espressif'
43+
uses: actions/cache@v3
44+
with:
45+
path: ${{ env.IDF_TOOLS_PATH }}
46+
key: tools-idf-${{ steps.idf-commit.outputs.commit }}-${{ runner.os }}-${{ env.pythonLocation }}
47+
48+
- name: Initialize IDF submodules
49+
if: inputs.platform == 'espressif'
50+
run: git submodule update --init --depth=1 --recursive $IDF_PATH
51+
shell: bash

.github/actions/upload_aws/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Upload to AWS S3
2+
3+
4+
inputs:
5+
source:
6+
required: true
7+
type: string
8+
9+
destination:
10+
required: true
11+
type: string
12+
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Upload to S3
18+
if: >-
19+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
20+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
21+
run: |
22+
pip install awscli
23+
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1
24+
env:
25+
AWS_PAGER: ''
26+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/build-boards.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Build boards
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
platform:
7+
required: true
8+
type: string
9+
10+
boards:
11+
required: true
12+
type: string
13+
14+
cp-version:
15+
required: true
16+
type: string
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-22.04
21+
env:
22+
CP_VERSION: ${{ inputs.cp-version }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
board: ${{ fromJSON(inputs.boards) }}
27+
steps:
28+
- name: Dump GitHub context
29+
run: echo "$GITHUB_CONTEXT"
30+
env:
31+
GITHUB_CONTEXT: ${{ toJson(github) }}
32+
- name: Set up repository
33+
uses: actions/checkout@v3
34+
with:
35+
submodules: false
36+
fetch-depth: 1
37+
- name: Set up python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: 3.x
41+
- name: Set up port
42+
uses: ./.github/actions/port_deps
43+
with:
44+
platform: ${{ inputs.platform }}
45+
- name: Set up submodules
46+
id: set-up-submodules
47+
uses: ./.github/actions/fetch_submodules
48+
- name: Set up external
49+
uses: ./.github/actions/external_deps
50+
with:
51+
platform: ${{ inputs.platform }}
52+
53+
- name: Versions
54+
run: |
55+
gcc --version
56+
python3 --version
57+
cmake --version || true
58+
ninja --version || true
59+
aarch64-none-elf-gcc --version || true
60+
arm-none-eabi-gcc --version || true
61+
xtensa-esp32-elf-gcc --version || true
62+
riscv32-esp-elf-gcc --version || true
63+
riscv64-unknown-elf-gcc --version || true
64+
mkfs.fat --version || true
65+
66+
- name: Download mpy-cross
67+
if: ${{ steps.set-up-submodules.outputs.frozen == 'True' }}
68+
uses: actions/download-artifact@v3
69+
with:
70+
name: mpy-cross
71+
path: mpy-cross
72+
- name: Make mpy-cross executable
73+
if: ${{ steps.set-up-submodules.outputs.frozen == 'True' }}
74+
run: sudo chmod +x mpy-cross/mpy-cross
75+
76+
- name: Set up build failure matcher
77+
run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json"
78+
- name: Build
79+
run: python3 -u build_release_files.py
80+
working-directory: tools
81+
env:
82+
BOARDS: ${{ matrix.board }}
83+
84+
- name: Upload artifact
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: ${{ matrix.board }}
88+
path: bin/${{ matrix.board }}
89+
- name: Upload to S3
90+
if: >-
91+
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
92+
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
93+
run: |
94+
pip install awscli
95+
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1
96+
env:
97+
AWS_PAGER: ''
98+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
99+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

0 commit comments

Comments
 (0)