Only 2 at a time. #9861
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
schedule: | |
- cron: '00 2 * * *' # 02:00 UTC | |
push: | |
branches-ignore: | |
- "wip/**" | |
- "wip-**" | |
- "*/wip-**" | |
- "*/wip/**" | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
# Use 'inputs.<name>' when pasting into a bash `if`, like so: | |
# if [[ "${{ inputs.strip }}" == 'true' ]]; then ... | |
# | |
# When using to guard a step, use 'github.event.inputs.<name>', like so: | |
# if: ${{ github.event.inputs.<name> == 'true' }} | |
# or | |
# if: ${{ github.event.inputs.<name> != 'false' }} | |
# In the first case, the step will not run if there isn't any workflow dispatch. | |
# In the second case, the step will run if there isn't any workflow dispatch. | |
# As such, the recommendation is to use the `== true` if the default is | |
# false, and the `!= false` if the default is true. | |
strip: | |
description: "Strip executables" | |
required: false | |
type: boolean | |
default: false | |
sign-macos: | |
description: "Sign macOS executables" | |
required: false | |
type: boolean | |
default: false | |
build-arm-macos: | |
description: "Build ARM macOS executables" | |
required: false | |
type: boolean | |
default: false | |
dispatch-toitdocs: | |
description: "Dispatch toitdoc rebuild" | |
required: false | |
type: boolean | |
default: false | |
run-tests: | |
description: "Run tests" | |
required: false | |
type: boolean | |
default: true | |
test-more: | |
description: "Run more tests" | |
required: false | |
type: boolean | |
default: false | |
run-esp32-flow: | |
description: "Run the ESP32 flow" | |
required: false | |
type: boolean | |
default: true | |
do-release: | |
description: "Build release artifacts and upload with this version" | |
required: false | |
type: string | |
default: | |
enable-lto: | |
description: "Enable link-time optimizations" | |
required: false | |
type: boolean | |
default: false | |
env: | |
TOIT_VERSION: ${{ github.event.inputs.do-release || github.event.release.tag_name || '' }} | |
DO_RELEASE: ${{ github.event_name == 'release' || startsWith(github.event.inputs.do-release, 'v') }} | |
DO_MORE_TESTS: ${{ github.event_name == 'schedule' || github.event.inputs.test-more == 'true' }} | |
ESPTOOL_VERSION: "v4.8.1%2Btoitlang" | |
TEST_PI_HW: "true" | |
jobs: | |
prereqs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set strategy variables | |
id: vars | |
run: | | |
# ubuntu-20.04 so that we don't depend on a recent glibc. | |
# macos-13, since it's still intel based. | |
if [[ "${{ github.ref }}" == 'refs/heads/master' || \ | |
"${{ env.DO_RELEASE }}" == "true" || \ | |
"${{ inputs.build-arm-macos }}" == "true" || \ | |
"${{ inputs.sign-macos }}" == "true" \ | |
]]; then | |
echo 'CONTAINERS=[ "ubuntu-20.04", "macos-13", "macos-latest", "windows-latest" ]' > $GITHUB_OUTPUT | |
else | |
echo 'CONTAINERS=[ "ubuntu-20.04", "macos-13", "windows-latest" ]' > $GITHUB_OUTPUT | |
fi | |
if [[ "${{ inputs.run-tests }}" != "false" ]]; then | |
echo 'SHARDS=[1, 2, 3, 4, 5]' >> $GITHUB_OUTPUT | |
echo 'EXTRA_INCLUDES=[{"container": "ubuntu-20.04", "shard": 6}, {"container": "ubuntu-20.04", "shard": 7}]' >> $GITHUB_OUTPUT | |
echo 'SHARD_COUNT=5' >> $GITHUB_OUTPUT | |
echo 'SHARD_COUNT_LINUX=7' >> $GITHUB_OUTPUT | |
else | |
echo 'SHARDS=[1]' >> $GITHUB_OUTPUT | |
echo 'EXTRA_INCLUDES=[]' >> $GITHUB_OUTPUT | |
echo 'SHARD_COUNT=1' >> $GITHUB_OUTPUT | |
fi | |
outputs: | |
CONTAINERS: ${{ steps.vars.outputs.CONTAINERS }} | |
SHARDS: ${{ steps.vars.outputs.SHARDS }} | |
EXTRA_INCLUDES: ${{ steps.vars.outputs.EXTRA_INCLUDES }} | |
SHARD_COUNT: ${{ steps.vars.outputs.SHARD_COUNT }} | |
SHARD_COUNT_LINUX: ${{ steps.vars.outputs.SHARD_COUNT_LINUX }} | |
TEST_PI_HW: ${{ env.TEST_PI_HW }} | |
esp32: | |
if: ${{ github.event.inputs.run-esp32-flow != 'false' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up build environment | |
uses: ./actions/setup-build | |
with: | |
toit-dir: . | |
esp32: true | |
cache-key-prefix: esp32 | |
# Build using make. | |
- name: make | |
run: | | |
ccache -s | |
source third_party/esp-idf/export.sh | |
# Install the Python packages necessary for MbedTLS after | |
# setting up the virtual Python environment. | |
pip install jsonschema jinja2 | |
make esp32 | |
make ESP32_CHIP=esp32c3 esp32 | |
make ESP32_CHIP=esp32s2 esp32 | |
make ESP32_CHIP=esp32s3 esp32 | |
ccache -s | |
- name: Pack firmware artifacts | |
shell: bash | |
run: | | |
gzip --to-stdout build/esp32/firmware.envelope > build/firmware-esp32.gz | |
gzip --to-stdout build/esp32c3/firmware.envelope > build/firmware-esp32c3.gz | |
gzip --to-stdout build/esp32s2/firmware.envelope > build/firmware-esp32s2.gz | |
gzip --to-stdout build/esp32s3/firmware.envelope > build/firmware-esp32s3.gz | |
- name: Upload firmware artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: firmwares | |
path: | | |
build/firmware-esp32.gz | |
build/firmware-esp32c3.gz | |
build/firmware-esp32s2.gz | |
build/firmware-esp32s3.gz | |
# The raspbian executable is also built on the 'cross' job, but we want to | |
# run the serial test as fast as possible and don't want to wait for the | |
# 'cross' job to finish. | |
rpi: | |
runs-on: ubuntu-latest | |
needs: prereqs | |
if: needs.prereqs.outputs.TEST_PI_HW == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set version | |
run: | | |
if [ -z "$TOIT_VERSION" ]; then | |
TOIT_VERSION=$(cmake -DPRINT_VERSION=1 -P tools/gitversion.cmake) | |
fi | |
echo "TOIT_GIT_VERSION=$TOIT_VERSION" >> $GITHUB_ENV | |
- name: Set up build environment | |
uses: ./actions/setup-build | |
with: | |
toit-dir: . | |
cache-key-prefix: cross-pi | |
- name: Make | |
# Note that the TOIT_GIT_VERSION is set. The make step will thus not | |
# compute the version from git. | |
run: | | |
make raspbian | |
- name: Pack artifacts | |
shell: bash | |
# Note that we use `cp -R` first, since that works on every platform. | |
run: | | |
cp -R ./build/raspbian/sdk ./build/raspbian/toit | |
tar -czf build/rpi.tar.gz -C ./build/raspbian --dereference toit | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rpi-build | |
path: | | |
build/rpi.tar.gz | |
serial: | |
needs: [prereqs, rpi, esp32] | |
if: needs.prereqs.outputs.TEST_PI_HW == 'true' | |
runs-on: serial | |
steps: | |
- name: Clean workspace | |
run: | | |
rm -rf ${{ github.workspace }}/* | |
- uses: actions/checkout@v4 | |
# We need a more recent version of cmake than is installed globally. | |
- name: Add local bin to PATH | |
run: | | |
echo "$HOME/local/bin" >> $GITHUB_PATH | |
# Download the Pi artifact. | |
- name: Download the SDK | |
uses: actions/download-artifact@v4 | |
with: | |
name: rpi-build | |
- name: Unpack the Toit SDK | |
run: | | |
mkdir -p rpi | |
tar x -zf rpi.tar.gz -C rpi | |
- name: Download esptool | |
# The Toit SDK we got is not yet combined and thus missing the esptool. | |
run: | | |
export ESPTOOL_ARCH=linux-armv7 | |
curl -O -L /~https://github.com/toitlang/esptool/releases/download/$ESPTOOL_VERSION/esptool-$ESPTOOL_ARCH.zip | |
unzip esptool-$ESPTOOL_ARCH.zip | |
cp esptool-$ESPTOOL_ARCH/esptool$EXTENSION rpi/toit/tools/esptool$EXTENSION | |
chmod +x rpi/toit/tools/esptool$EXTENSION | |
- name: Download ESP32 envelopes | |
uses: actions/download-artifact@v4 | |
with: | |
name: firmwares | |
- name: Unpack the ESP32 firmware | |
run: | | |
gunzip firmware-esp32.gz | |
gunzip firmware-esp32s3.gz | |
- name: Test Raspberry Pi | |
env: | |
TOIT_EXE_HW: ${{ github.workspace }}/rpi/toit/bin/toit | |
ESP32_ENVELOPE: ${{ github.workspace }}/firmware-esp32 | |
ESP32S3_ENVELOPE: ${{ github.workspace }}/firmware-esp32s3 | |
run: | | |
# Get the pin configuration from the file in the runner's home. | |
source $HOME/pi-test.env | |
# Get the esp32 port and wifi configuration from the file in the runner's home. | |
source $HOME/esp32-test.env | |
make TOIT_EXE_HW=${{ github.workspace }}/rpi/toit/bin/toit test-hw |