Skip to content

Update packages.

Update packages. #7251

Workflow file for this run

name: CI
on:
push:
branches-ignore:
- "wip/**"
- "wip-**"
- "*/wip-**"
- "*/wip/**"
release:
types: [published]
workflow_dispatch:
env:
ESPTOOL_VERSION: v4.6
jobs:
build:
strategy:
# The matrix will run all possible combinations in parallel.
matrix:
# ubuntu-20.04 so that we don't depend on a recent glibc.
container: [ ubuntu-20.04, macos-latest, windows-latest ]
shard: [1, 2, 3, 4, 5]
include:
- container: ubuntu-20.04
shard: 6
- container: ubuntu-20.04
shard: 7
- container: ubuntu-20.04
shard: 8
runs-on: ${{ matrix.container }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up constants
id: constants
shell: bash
run: |
echo "flaky_result=flaky-result/$RUNNER_OS-${{ matrix.shard }}.txt" >> $GITHUB_OUTPUT
echo "flaky_result_name=flaky-result-${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_OUTPUT
echo "external_result=external-result/$RUNNER_OS-${{ matrix.shard }}.txt" >> $GITHUB_OUTPUT
echo "external_result_name=external-result-${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_OUTPUT
echo "debug_root_dir=debug-ci" >> $GITHUB_OUTPUT
echo "debug_dir=debug-ci/$RUNNER_OS-${{ matrix.shard }}" >> $GITHUB_OUTPUT
TOIT_VERSION=$(cmake -DPRINT_VERSION=1 -P tools/gitversion.cmake)
echo $TOIT_VERSION
echo "toit_version=$TOIT_VERSION" >> $GITHUB_OUTPUT
if [ "$RUNNER_OS" == "Linux" ]; then
echo "artifact=toit-linux.tar.gz" >> $GITHUB_OUTPUT
echo "total_shards=8" >> $GITHUB_OUTPUT
elif [ "$RUNNER_OS" == "macOS" ]; then
echo "artifact=toit-macos.tar.gz" >> $GITHUB_OUTPUT
echo "total_shards=5" >> $GITHUB_OUTPUT
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "artifact=toit-windows.tar.gz" >> $GITHUB_OUTPUT
echo "total_shards=5" >> $GITHUB_OUTPUT
else
echo "UNSUPPORTED RUNNER: $RUNNER_OS"
exit 1
fi
# Anything in the debug dir will be uploaded as artifact.
- name: Setup debug dir
shell: sh
run: |
mkdir -p ${{ steps.constants.outputs.debug_dir }}
# We only need the mbedtls submodule for building.
- name: Initialize mbedtls submodule
run: |
cd third_party/esp-idf
git submodule update --init .
git submodule update --init components/mbedtls
# Use Go 1.20
- name: Switch to Go 1.20
shell: bash
run:
echo "$GOROOT_1_20_X64"/bin >> $GITHUB_PATH
# Get values for cache paths to be used in later steps.
- name: Get Go paths
id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Go cache
# On Windows this takes 3-5 minutes, and doesn't seem to help the build speed much.
if: runner.os != 'Windows'
uses: actions/cache@v3
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Ccache cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.ccache
key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: ${{ runner.os }}-ccache-
# Cache deb files.
- name: Apt cache - Linux
if: runner.os == 'Linux'
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/apt-cacher-ng
key: ${{ runner.os }}-apt-${{ github.sha }}
restore-keys: ${{ runner.os }}-apt
- name: Install and configure apt-cacher-ng - Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -q
sudo apt-get install -q apt-cacher-ng
sudo systemctl stop apt-cacher-ng
if [[ -f apt-cacher-ng/cache.tar.gz ]]; then
sudo tar -xzf apt-cacher-ng/cache.tar.gz -C /var/cache/apt-cacher-ng
fi
echo "Acquire::http::Proxy \"http://localhost:3142\";" | sudo tee /etc/apt/apt.conf.d/00proxy
echo "PassThroughPattern: .*" | sudo tee -a /etc/apt-cacher-ng/acng.conf
sudo systemctl restart apt-cacher-ng
# Fetch the dependencies. Different for each platform.
- name: Install dependencies - Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -q
sudo apt-get install -q ninja-build ccache gcc-multilib g++-multilib socat valgrind
ninja --version
cmake --version
gcc --version
socat -V
- name: Install dependencies - macOS
if: runner.os == 'macOS'
run: |
brew install ninja ccache
ninja --version
cmake --version
- name: Install dependencies - Windows
if: runner.os == 'Windows'
run: |
choco install ninja ccache
ninja --version
ccache --version
cmake --version
- name: Copy apt cache back - Linux
if: runner.os == 'Linux'
run: |
mkdir -p apt-cacher-ng
sudo tar -czf apt-cacher-ng/cache.tar.gz -C /var/cache/apt-cacher-ng .
sudo chown $(whoami) apt-cacher-ng/cache.tar.gz
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: third_party/esp-idf/components/mbedtls/mbedtls/scripts/driver.requirements.txt
- name: Set up Python modules for MbedTLS
run: |
pip install jsonschema jinja2
- name: Setup compilation env
shell: bash
run: |
echo 'IDF_PATH=${{ github.workspace }}/third_party/esp-idf' >> $GITHUB_ENV
echo 'CCACHE_DIR=${{ github.workspace }}/.ccache' >> $GITHUB_ENV
echo 'CCACHE_BASEDIR=${{ github.workspace }}' >> $GITHUB_ENV
echo "CCACHE_COMPRESS=true" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=6" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=400M" >> $GITHUB_ENV
echo "SHARD_START=${{ matrix.shard }}" >> $GITHUB_ENV
echo "SHARD_STRIDE=${{ steps.constants.outputs.total_shards }}" >> $GITHUB_ENV
# Build using make.
- name: Build sdk
shell: bash
run: |
ccache -s
make sdk
if [ "$RUNNER_OS" == "Linux" ]; then
make HOST=host32 BUILD_TYPE=Debug sdk
make HOST=host-ctp TOOLCHAIN=host TOIT_CHECK_PROPAGATED_TYPES=1 sdk
fi
ccache -s
# Test.
- name: Test
shell: bash # This is crucial, as the powershell doesn't abort when there is an error.
run: |
make test
make test-health
- name: Test flaky
continue-on-error: true
shell: bash # This is crucial, as the powershell doesn't abort when there is an error.
run: |
mkdir -p $(dirname ${{ steps.constants.outputs.flaky_result }})
echo fail > ${{ steps.constants.outputs.flaky_result }}
make test-flaky
# If we reach here, then the test-flaky target succeeded.
echo success > ${{ steps.constants.outputs.flaky_result }}
- name: Test type propagator
if: runner.os == 'Linux'
run: |
make HOST=host-ctp TOIT_CHECK_PROPAGATED_TYPES=1 test
- name: Test 32-bit debug
if: runner.os == 'Linux'
run: |
make HOST=host32 BUILD_TYPE=Debug test
# Test external code.
- name: Test external
# External tests are allowed to fail, but we record them and
# fail a non-required job if they do.
continue-on-error: true
env:
IDF_PATH: ${{ github.workspace }}/third_party/esp-idf
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: '6'
CCACHE_MAXSIZE: 400M
SHARD_START: ${{ matrix.shard }}
SHARD_STRIDE: ${{ steps.constants.outputs.total_shards }}
shell: bash
run: |
# Mark the external test as failing, and update it at the end of this step.
mkdir -p $(dirname ${{ steps.constants.outputs.external_result }})
echo fail > ${{ steps.constants.outputs.external_result }}
make enable-external
find external > ${{ steps.constants.outputs.debug_dir }}/${{ matrix.container }}_${{ matrix.shard }}_files_after_enable_external.log
make test-external
make test-external-health
if [ "$RUNNER_OS" == "Linux" ]; then
cmake -DTOIT_TEST_EXTERNAL=ON build/host32
make HOST=host32 BUILD_TYPE=Debug rebuild-cmake
cd build/host32
ninja check_external
cd ../..
fi
# If we reach here, all steps of this step succeeded.
echo success > ${{ steps.constants.outputs.external_result }}
- name: Store flaky test result
uses: actions/upload-artifact@v3
with:
name: ${{ steps.constants.outputs.flaky_result_name }}
path: ${{ steps.constants.outputs.flaky_result }}
- name: Store external test result
uses: actions/upload-artifact@v3
with:
name: ${{ steps.constants.outputs.external_result_name }}
path: ${{ steps.constants.outputs.external_result }}
- name: Toitdoc - Linux
if: runner.os == 'Linux' && matrix.shard == 1
env:
TOIT_VERSION: ${{ steps.constants.outputs.toit_version }}
TOITLSP: ${{ github.workspace }}/build/host/sdk/bin/toit.lsp
TOITC: ${{ github.workspace }}/build/host/sdk/bin/toit.compile
SDKDIR: ${{ github.workspace }}/
shell: bash
run: |
CPU_CORES=$(nproc)
JSON_OUT_PATH=${{ github.workspace }}/toitdoc_$TOIT_VERSION.json
cd "$SDKDIR"
echo "$TOITLSP" toitdoc -p $CPU_CORES --toitc=$TOITC "--sdk=$SDKDIR" "--out=$JSON_OUT_PATH" --version=$TOIT_VERSION lib
"$TOITLSP" toitdoc -p $CPU_CORES --toitc=$TOITC "--sdk=$SDKDIR" "--out=$JSON_OUT_PATH" --version=$TOIT_VERSION lib
- name: Pack artifacts
if: matrix.shard == 1
shell: bash
# Note that we use `cp -R` first, since that works on every platform.
run: |
cp -R ./build/host/sdk ./build/host/toit
tar -czf build/${{ steps.constants.outputs.artifact }} -C ./build/host --dereference toit
- name: Prepare debug repros
if: always()
continue-on-error: true
shell: bash
run: |
ls /tmp/lsp_repro-* || true
REPRO_DIR=${{ steps.constants.outputs.debug_dir }}/repros
mkdir -p $REPRO_DIR
find /tmp -maxdepth 1 -name 'lsp_repro-*' -exec cp -r {} $REPRO_DIR \;
ls $REPRO_DIR
- name: Upload debug artifacts
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: debug
path: ${{ steps.constants.outputs.debug_root_dir }}
retention-days: 5
if-no-files-found: ignore
- name: Upload toitdoc - Linux
if: runner.os == 'Linux' && matrix.shard == 1
uses: actions/upload-artifact@v3
with:
name: toitdoc
path: toitdoc_${{ steps.constants.outputs.toit_version }}.json
- name: Authenticate to Google cloud - Linux
if: |
runner.os == 'Linux' && matrix.shard == 1 &&
github.repository_owner == 'toitlang'
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.INFRASTRUCTURE_SERVICE_ACCOUNT_JSON_KEY }}
service_account: [email protected]
- name: Set up Cloud SDK
if: |
runner.os == 'Linux' && matrix.shard == 1 &&
github.repository_owner == 'toitlang'
uses: google-github-actions/setup-gcloud@v2
with:
project_id: infrastructure-220307
- name: Upload toitdoc to gcloud - Linux
if: |
runner.os == 'Linux' && matrix.shard == 1 &&
github.repository_owner == 'toitlang'
env:
TOIT_VERSION: ${{ steps.constants.outputs.toit_version }}
run: |
JSON_PATH=${{ github.workspace }}/toitdoc_$TOIT_VERSION.json
echo -n $TOIT_VERSION > LATEST.tmp
gsutil cp $JSON_PATH gs://toit-web/toitdoc-sdk/$TOIT_VERSION.json
gsutil cp LATEST.tmp gs://toit-web/toitdoc-sdk/LATEST
- name: Update RELEASE in gcloud - Linux
if: |
runner.os == 'Linux' && matrix.shard == 1 &&
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
env:
TOIT_VERSION: ${{ steps.constants.outputs.toit_version }}
run: |
echo -n $TOIT_VERSION > LATEST.tmp
gsutil cp LATEST.tmp gs://toit-web/toitdoc-sdk/RELEASED
gsutil cp LATEST.tmp gs://toit-web/toitdoc-sdk/RELEASED.$TOIT_VERSION
- name: Upload unsigned artifacts - Windows
if: runner.os == 'Windows' && matrix.shard == 1
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-build-unsigned
path: build/${{ steps.constants.outputs.artifact }}
- name: Upload artifacts - Linux/macOS
if: runner.os != 'Windows' && matrix.shard == 1
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-build
path: build/${{ steps.constants.outputs.artifact }}
# Really annoying that we need to duplicate so much.
esp32:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Initialize submodules
run: |
git submodule sync --recursive
git submodule update --init --recursive -j 16
# Use Go 1.20
- name: Switch to Go 1.20
shell: bash
run:
echo "$GOROOT_1_20_X64"/bin >> $GITHUB_PATH
# Get values for cache paths to be used in later steps.
- name: Get Go paths
id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
# Get values for sha hashes to be used in later steps.
- name: Get Sha hashes
id: sha-hashes
shell: bash
run: |
echo "espressif_sha=$(git submodule status third_party/esp-idf | awk '{print $1}')" >> $GITHUB_OUTPUT
# Cache go build cache, used to speedup go test.
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build-
# Cache go mod cache, used to speedup builds.
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-mod-
- name: Ccache cache
uses: actions/cache@v3
# Store and retrieve the cache with the given sha.
# The 'restore-keys' prefix finds the most recent cache in case there
# is no match (which should almost always be the case).
with:
path: ${{ github.workspace }}/.ccache
key: esp32-ccache-${{ github.sha }}
restore-keys: esp32-ccache-
- name: ESP32 tools cache
uses: actions/cache@v3
# Store and retrieve the cache with the given sha.
# The 'restore-keys' prefix finds the most recent cache in case there
# is no match (which should almost always be the case).
with:
path: /home/runner/.espressif
key: espressif-cache-${{ steps.sha-hashes.outputs.espressif_sha }}
restore-keys: espressif-cache-
- name: Install dependencies - Linux
run: |
sudo apt-get update
sudo apt-get install ninja-build ccache
ninja --version
cmake --version
gcc --version
- name: Install ESP32 tools
run: |
sh third_party/esp-idf/install.sh
# Build using make.
- name: make
env:
IDF_PATH: ${{ github.workspace }}/third_party/esp-idf
IDF_CCACHE_ENABLE: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: '6'
CCACHE_MAXSIZE: 400M
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@v3
with:
name: firmwares
path: |
build/firmware-esp32.gz
build/firmware-esp32c3.gz
build/firmware-esp32s2.gz
build/firmware-esp32s3.gz
- name: Upload ESP32 release firmware artifacts
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/firmware-esp32.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload ESP32-C3 release firmware artifacts
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/firmware-esp32c3.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload ESP32-S2 release firmware artifacts
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/firmware-esp32s2.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload ESP32-S3 release firmware artifacts
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/firmware-esp32s3.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
# Really annoying that we need to duplicate so much.
cross:
runs-on: ubuntu-latest
steps:
- name: Set up constants
id: constants
shell: bash
run: |
echo raspberry_pi_artifact=toit-rpi.tar.gz >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: 0
# We only need a subset of all submodules for building.
- name: Initialize submodules
run: |
cd third_party/esp-idf
git submodule update --init .
git submodule update --init components/mbedtls
# Use Go 1.20
- name: Switch to Go 1.20
shell: bash
run:
echo "$GOROOT_1_20_X64"/bin >> $GITHUB_PATH
# Get values for cache paths to be used in later steps
- name: Get Go paths
id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
# Cache go build cache, used to speedup go test
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build-
# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-mod-
- name: Ccache cache
uses: actions/cache@v3
# Store and retrieve the cache with the given sha.
# The 'restore-keys' prefix finds the most recent cache in case there
# is no match (which should almost always be the case).
with:
path: ${{ github.workspace }}/.ccache
key: esp32-ccache-${{ github.sha }}
restore-keys: esp32-ccache-
- name: Install dependencies - Linux
run: |
sudo apt-get update
sudo apt-get install ninja-build ccache mingw-w64
ninja --version
cmake --version
gcc --version
- name: Make
env:
IDF_PATH: ${{ github.workspace }}/third_party/esp-idf
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: '6'
CCACHE_MAXSIZE: 400M
run: |
make TARGET=win64 sdk
make raspbian
make aarch64
make arm-linux-gnueabi
- name: Test executables 32-bit
uses: pguyot/arm-runner-action@v2
with:
cpu: cortex-a7
base_image: "raspios_lite:2022-01-28"
bind_mount_repository: true
commands: |
uname -m > pi_uname
build/raspbian/sdk/bin/toit.pkg version
build/raspbian/sdk/bin/toit.run --version
build/raspbian/sdk/tools/firmware --help
- name: Test executables 64-bit
uses: pguyot/arm-runner-action@v2
with:
cpu: cortex-a7
base_image: "raspios_lite_arm64:2022-01-28"
bind_mount_repository: true
commands: |
uname -m > pi_uname
build/aarch64/sdk/bin/toit.pkg version
build/aarch64/sdk/bin/toit.run --version
build/aarch64/sdk/tools/firmware --help
- 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/${{ steps.constants.outputs.raspberry_pi_artifact }} -C ./build/raspbian --dereference toit
cp -R ./build/aarch64/sdk ./build/aarch64/toit
tar -czf build/toit-aarch64.tar.gz -C ./build/aarch64 --dereference toit
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-build
path: |
build/${{ steps.constants.outputs.raspberry_pi_artifact }}
build/toit-aarch64.tar.gz
combine:
needs: [build, cross]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: Windows-build-unsigned
- uses: actions/download-artifact@v3
with:
name: Linux-build
- uses: actions/download-artifact@v3
with:
name: macOS-build
- name: Unpack SDKs
run: |
for os in windows linux macos rpi aarch64; do
mkdir -p $os
tar x -zf toit-$os.tar.gz -C $os
done
- name: Copy vessels
run: |
mkdir -p vessels
for source in windows linux macos rpi aarch64; do
# Use same values as Go.
if [ "$source" == "windows" ]; then
CROSS_OS=windows
CROSS_ARCH=amd64
elif [ "$source" == "linux" ]; then
CROSS_OS=linux
CROSS_ARCH=amd64
elif [ "$source" == "macos" ]; then
CROSS_OS=darwin
CROSS_ARCH=amd64
elif [ "$source" == "rpi" ]; then
CROSS_OS=linux
CROSS_ARCH=arm
elif [ "$source" == "aarch64" ]; then
CROSS_OS=linux
CROSS_ARCH=arm64
else
echo "Unknown source: $source"
exit 1
fi
mkdir -p vessels/$CROSS_OS/$CROSS_ARCH
cp $source/toit/vessels/vessel* vessels/$CROSS_OS/$CROSS_ARCH
for target in windows linux macos rpi aarch64; do
if [ "$source" == "$target" ]; then
continue
fi
mkdir -p $target/toit/vessels/$CROSS_OS/$CROSS_ARCH
cp $source/toit/vessels/vessel* $target/toit/vessels/$CROSS_OS/$CROSS_ARCH
done
done
- name: Create vessels artifact
run: |
tar c -zf vessels.tar.gz vessels
- name: Download esptools
run: |
for arch in arm arm64 linux-amd64 macos win64; do
curl -O -L https://github.com/espressif/esptool/releases/download/$ESPTOOL_VERSION/esptool-$ESPTOOL_VERSION-$arch.zip
unzip esptool-$ESPTOOL_VERSION-$arch.zip
EXTENSION=""
if [[ "$arch" = "arm" ]]; then
TARGET=rpi
elif [[ "$arch" = "arm64" ]]; then
TARGET=aarch64
elif [[ "$arch" = "linux-amd64" ]]; then
TARGET=linux
elif [[ "$arch" = "macos" ]]; then
TARGET=macos
elif [[ "$arch" = "win64" ]]; then
TARGET=windows
EXTENSION=.exe
fi
cp esptool-$ESPTOOL_VERSION-$arch/esptool$EXTENSION $TARGET/toit/tools/esptool$EXTENSION
chmod +x $TARGET/toit/tools/esptool$EXTENSION
done
- name: Compress SDKs
run: |
for os in windows linux macos rpi aarch64; do
tar c -zf toit-$os.tar.gz -C $os toit
done
- name: Upload vessels
uses: actions/upload-artifact@v3
with:
name: vessels
path: vessels.tar.gz
- name: Upload Windows unsigned
uses: actions/upload-artifact@v3
with:
name: Windows-build-unsigned
path: toit-windows.tar.gz
- name: Upload Linux
uses: actions/upload-artifact@v3
with:
name: Linux-build
path: |
toit-linux.tar.gz
toit-rpi.tar.gz
toit-aarch64.tar.gz
- name: Upload macOS
uses: actions/upload-artifact@v3
with:
name: macOS-build
path: toit-macos.tar.gz
- name: Upload release vessels
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: vessels.tar.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload release Linux
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: toit-linux.tar.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload release macOS
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: toit-macos.tar.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload release Raspberry Pi 32-bit
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: toit-rpi.tar.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload release aarch64
if: |
github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: toit-aarch64.tar.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
sign_windows:
runs-on: windows-latest
needs: [combine]
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: Windows-build-unsigned
- name: Decompress
run: |
& "C:\Program Files\Git\bin\bash.exe" --noprofile --norc -e -o pipefail -c "tar -xzf toit-windows.tar.gz"
- name: Sign Windows binary
uses: toitlang/action-code-sign@a4adedba46f2630ed60a1d6e6aa828ac7038c945 # v1.0.0
with:
certificate: ${{ secrets.DIGICERT_CERTIFICATE }}
api-key: ${{ secrets.DIGICERT_API_KEY }}
certificate-password: ${{ secrets.DIGICERT_PASSWORD }}
certificate-fingerprint: ${{ secrets.DIGICERT_FINGERPRINT }}
keypair-alias: ${{ vars.DIGICERT_KEYPAIR_ALIAS }}
path: toit/bin
- name: Sign Windows tools
uses: toitlang/action-code-sign@a4adedba46f2630ed60a1d6e6aa828ac7038c945 # v1.0.0
with:
certificate: ${{ secrets.DIGICERT_CERTIFICATE }}
api-key: ${{ secrets.DIGICERT_API_KEY }}
certificate-password: ${{ secrets.DIGICERT_PASSWORD }}
certificate-fingerprint: ${{ secrets.DIGICERT_FINGERPRINT }}
keypair-alias: ${{ vars.DIGICERT_KEYPAIR_ALIAS }}
path: toit/tools
- name: Compress
run: |
& "C:\Program Files\Git\bin\bash.exe" --noprofile --norc -e -o pipefail -c "tar -czf toit-windows.tar.gz toit"
- name: Version number
id: version
shell: powershell
run: |
$versionV = "${{ github.event.release.tag_name }}"
$version = $versionV.Substring(1)
echo "version=$version" >> $env:GITHUB_OUTPUT
- name: Build installer
run: |
& tools\windows_installer\build.bat ${{ steps.version.outputs.version }} $PWD\toit $PWD\toit-windows-x64-installer.exe
- name: Sign Windows installer
uses: toitlang/action-code-sign@a4adedba46f2630ed60a1d6e6aa828ac7038c945 # v1.0.0
with:
certificate: ${{ secrets.DIGICERT_CERTIFICATE }}
api-key: ${{ secrets.DIGICERT_API_KEY }}
certificate-password: ${{ secrets.DIGICERT_PASSWORD }}
certificate-fingerprint: ${{ secrets.DIGICERT_FINGERPRINT }}
keypair-alias: ${{ vars.DIGICERT_KEYPAIR_ALIAS }}
path: toit-windows-x64-installer.exe
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Windows-build
path: |
toit-windows.tar.gz
toit-windows-x64-installer.exe
- name: Upload release artifacts
if: github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: toit-windows.tar.gz
tag: ${{ github.event.release.tag_name }}
overwrite: true
- name: Upload release installer
if: github.event_name == 'release' &&
github.repository_owner == 'toitlang'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: toit-windows-x64-installer.exe
tag: ${{ github.event.release.tag_name }}
overwrite: true
external-and-flaky:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up constants
id: constants
shell: bash
run: |
echo flaky_result_dir=flaky-result >> $GITHUB_OUTPUT
echo flaky_result_name=flaky-result-${{ github.run_id }}-${{ github.run_attempt }} >> $GITHUB_OUTPUT
echo external_result_dir=external-result >> $GITHUB_OUTPUT
echo external_result_name=external-result-${{ github.run_id }}-${{ github.run_attempt }} >> $GITHUB_OUTPUT
- name: Retrieve
uses: actions/download-artifact@v3
with:
name: ${{ steps.constants.outputs.flaky_result_name }}
path: flaky-result
- name: Retrieve
uses: actions/download-artifact@v3
with:
name: ${{ steps.constants.outputs.external_result_name }}
path: external-result
- name: List downloaded files
# This is mostly for debugging purposes.
shell: bash
run: |
find .
- name: Check external
shell: bash
run: |
cat external-result/*
grep "fail" external-result/* && exit 1
# If we get here, we didn't find any failures but
# the exit code of the grep is still 1 or 2. Echo
# something to make it clear and avoid letting the
# result of the action be non-zero.
echo "success: no failures found"
- name: Check flaky
# Even if the external result already failed we want to know whether flaky tests failed
# as well.
# Since the two steps aren't dependent always run this step.
if: always()
shell: bash
run: |
cat flaky-result/*
grep "fail" flaky-result/* && exit 1
# If we get here, we didn't find any failures but
# the exit code of the grep is still 1 or 2. Echo
# something to make it clear and avoid letting the
# result of the action be non-zero.
echo "success: no failures found"
AUR:
name: Update AUR package
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'release' &&
!github.event.release.prerelease &&
github.repository_owner == 'toitlang'
steps:
# This shouldn't be necessary, but the archlinux-package-action
# doesn't work without it.
- uses: actions/checkout@v4
- name: Version number
id: version
shell: bash
run: |
VERSION="${{ github.event.release.tag_name }}"
echo "version=$VERSION" >> $GITHUB_ENV
- name: Ssh
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
run: |
echo "$AUR_SSH_KEY" > ${{ github.workspace }}/aur_ssh_key
chmod 600 ${{ github.workspace }}/aur_ssh_key
mkdir -p $HOME/.ssh
echo "Host aur.archlinux.org" >> $HOME/.ssh/config
echo " IdentityFile ${{ github.workspace }}/aur_ssh_key" >> $HOME/.ssh/config
echo " User aur" >> $HOME/.ssh/config
ssh-keyscan -H aur.archlinux.org > $HOME/.ssh/known_hosts
- name: Fetch AUR package
run: |
git clone ssh://[email protected]/toit.git
- name: Git
run: |
cd toit
git config user.email "[email protected]"
git config user.name "Leon Gungadin Mogensen"
- name: Update AUR package
shell: bash
run: |
# Toit's PKGBUILD is a bit special in that we don't download
# a tarball (since those don't contain submodules), but instead
# use Git to get the source code.
# For security, we store the hash of the commit in the PKGBUILD,
# which is why we run a custom 'update_hash.sh' script.
# This is the reason we can't just use the 'archlinux-package-action'.
cd toit
sed -i "s/_tag=.*/_tag=\"${{ env.version }}\"/g" PKGBUILD
sed -i "s/pkgrel=.*/pkgrel=1/g" PKGBUILD
./update_hash.sh
- name: Update .SRCINFO
uses: hapakaien/archlinux-package-action@v2
with:
path: toit
flags: ''
namcap: false
srcinfo: true
- name: Upload
run: |
cat ${{ github.workspace }}/toit/PKGBUILD
cat ${{ github.workspace }}/toit/.SRCINFO
cd ${{ github.workspace }}/toit
git commit -am "Update to version ${{ env.version }}"
git push origin master