CI #907
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 | |
permissions: | |
contents: read | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- dev | |
schedule: | |
- cron: '0 2 * * *' | |
workflow_dispatch: | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_GIT_FETCH_WITH_CLI: true | |
CARGO_NET_RETRY: 10 | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
RUSTDOCFLAGS: -D warnings | |
RUSTFLAGS: -D warnings | |
RUSTUP_MAX_RETRIES: 10 | |
SEMIHOSTING_DENY_WARNINGS: 1 | |
# NB: sync with miri/msrv/tidy jobs' --features option and package.metadata.docs.rs.features field in Cargo.toml | |
TEST_FEATURES: alloc,stdio,fs,args,time | |
defaults: | |
run: | |
shell: bash --noprofile --norc -CeEuxo pipefail {0} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
check-external-types: | |
uses: taiki-e/github-actions/.github/workflows/check-external-types.yml@main | |
deny: | |
uses: taiki-e/github-actions/.github/workflows/deny.yml@main | |
docs: | |
uses: taiki-e/github-actions/.github/workflows/docs.yml@main | |
miri: | |
uses: taiki-e/github-actions/.github/workflows/miri.yml@main | |
with: | |
# We don't support x86_64, so use aarch64-unknown-linux-gnu instead. | |
target: aarch64-unknown-linux-gnu | |
# NB: sync with env.TEST_FEATURES | |
args: --features alloc,stdio,fs,args,time | |
msrv: | |
uses: taiki-e/github-actions/.github/workflows/msrv.yml@main | |
with: | |
event_name: ${{ github.event_name }} | |
# We don't support x86_64, so use aarch64-unknown-linux-gnu instead. | |
target: aarch64-unknown-linux-gnu | |
# NB: sync with env.TEST_FEATURES | |
args: --features alloc,stdio,fs,args,time | |
tidy: | |
uses: taiki-e/github-actions/.github/workflows/tidy.yml@main | |
permissions: | |
contents: read | |
pull-requests: write # for gh pr edit --add-assignee | |
repository-projects: read # for gh pr edit --add-assignee | |
secrets: inherit | |
with: | |
# We don't support x86_64, so use aarch64-unknown-linux-gnu instead. | |
target: aarch64-unknown-linux-gnu,armv7-unknown-linux-gnueabihf,riscv64gc-unknown-linux-gnu,mips64-unknown-linux-gnuabi64 | |
# NB: sync with env.TEST_FEATURES | |
args: --features alloc,stdio,fs,args,time | |
# We have some platform-independent code, so test them. | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# We don't support x86_64, so use aarch64-unknown-linux-gnu instead. | |
- rust: nightly | |
target: aarch64-unknown-linux-gnu | |
- rust: nightly | |
target: mips64-unknown-linux-gnuabi64 | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- uses: taiki-e/github-actions/install-rust@main | |
with: | |
toolchain: ${{ matrix.rust }} | |
- uses: taiki-e/install-action@cargo-hack | |
- uses: taiki-e/install-action@cargo-minimal-versions | |
- uses: taiki-e/install-action@cargo-careful | |
if: startsWith(matrix.rust, 'nightly') | |
- uses: taiki-e/setup-cross-toolchain-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
- run: cargo test --workspace --features "${TEST_FEATURES}" --target "${{ matrix.target }}" ${DOCTEST_XCOMPILE:-} ${BUILD_STD:-} | |
- run: cargo test --workspace --features "${TEST_FEATURES}" --release --target "${{ matrix.target }}" ${DOCTEST_XCOMPILE:-} ${BUILD_STD:-} | |
- run: cargo careful test --workspace --features "${TEST_FEATURES}" --target "${{ matrix.target }}" ${DOCTEST_XCOMPILE:-} ${BUILD_STD:-} | |
if: startsWith(matrix.rust, 'nightly') | |
- run: cargo hack build --workspace --no-private --feature-powerset --depth 2 --optional-deps=portable-atomic --exclude-features panic-unwind,backtrace,trap-hlt,openocd-semihosting --target "${{ matrix.target }}" ${BUILD_STD:-} | |
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --features "${TEST_FEATURES}" --target "${{ matrix.target }}" ${BUILD_STD:-} | |
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --features "${TEST_FEATURES}" --target "${{ matrix.target }}" ${BUILD_STD:-} --direct | |
no-std: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- rust: '1.64' | |
- rust: stable | |
- rust: beta | |
# Test pre-8.0 QEMU for mips | |
- rust: nightly | |
os: ubuntu-22.04 # QEMU 6.2 | |
- rust: nightly | |
os: ubuntu-24.04 # QEMU 8.2 | |
# The behavior of semihosting somewhat depends on the behavior of the host system. | |
- rust: nightly | |
os: macos-latest | |
- rust: nightly | |
os: windows-latest | |
runs-on: ${{ matrix.os || 'ubuntu-latest' }} | |
timeout-minutes: 60 | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- uses: taiki-e/github-actions/install-rust@main | |
with: | |
toolchain: ${{ matrix.rust }} | |
- uses: taiki-e/install-action@espup | |
if: matrix.rust == 'stable' && (startsWith(matrix.os, 'ubuntu') || matrix.os == '') | |
- run: | | |
retry() { | |
for i in {1..10}; do | |
if "$@"; then | |
return 0 | |
else | |
sleep "${i}" | |
fi | |
done | |
"$@" | |
} | |
apt_packages=( | |
qemu-system-arm | |
qemu-system-misc | |
) | |
if [[ "${{ matrix.rust }}" == "nightly"* ]]; then | |
apt_packages+=( | |
qemu-system-mips | |
) | |
fi | |
if [[ "${{ matrix.rust }}" == "1.64" ]]; then | |
# pre-17 LLD doesn't support big-endian arm | |
apt_packages+=( | |
binutils-arm-none-eabi | |
) | |
fi | |
retry sudo apt-get -o Acquire::Retries=10 -qq update | |
retry sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends "${apt_packages[@]}" | |
# APT's qemu package doesn't provide firmware for riscv32 and mips: | |
# https://packages.ubuntu.com/en/jammy/all/qemu-system-data/filelist | |
opensbi_version=1.5.1 # https://github.com/riscv-software-src/opensbi/releases | |
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://github.com/riscv-software-src/opensbi/releases/download/v${opensbi_version}/opensbi-${opensbi_version}-rv-bin.tar.xz" \ | |
| tar xJf - | |
sudo mv -- "opensbi-${opensbi_version}-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.bin" /usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.bin | |
sudo mv -- "opensbi-${opensbi_version}-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.elf" /usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.elf | |
rm -rf -- "opensbi-${opensbi_version}-rv-bin" | |
retry git clone --depth 1 --filter=tree:0 --no-checkout https://github.com/qemu/qemu.git | |
cd -- qemu | |
git sparse-checkout init | |
printf '!/*\n' >>.git/info/sparse-checkout | |
printf '/pc-bios/\n' >>.git/info/sparse-checkout | |
git checkout | |
sudo mv -- pc-bios/{efi-pcnet.rom,vgabios-cirrus.bin} /usr/share/qemu/ | |
cd -- .. | |
rm -rf -- qemu | |
# https://github.com/taiki-e/dockerfiles/pkgs/container/qemu-user | |
retry docker create --name qemu-user ghcr.io/taiki-e/qemu-user:8.1 # TODO: "qemu-armeb: Error mapping file: Operation not permitted" error in 8.2-9.1 | |
mkdir -p -- qemu-user | |
docker cp -- qemu-user:/usr/bin qemu-user/bin | |
docker rm -f -- qemu-user >/dev/null | |
sudo mv -- qemu-user/bin/qemu-* /usr/bin/ | |
rm -rf -- ./qemu-user | |
if [[ "${{ matrix.rust }}" == "stable" ]]; then | |
retry espup install --targets esp32 | |
fi | |
qemu-system-arm --version | |
qemu-arm --version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: startsWith(matrix.os, 'ubuntu') || matrix.os == '' | |
- run: | | |
brew install qemu | |
qemu-system-arm --version | |
if: startsWith(matrix.os, 'macos') | |
- run: | | |
C:/msys64/usr/bin/pacman -S --noconfirm mingw-w64-ucrt-x86_64-qemu | |
printf '%s\n' 'C:\msys64\ucrt64\bin' >>"${GITHUB_PATH}" | |
C:/msys64/ucrt64/bin/qemu-system-arm --version | |
if: startsWith(matrix.os, 'windows') | |
- run: tools/no-std.sh | |
- run: TEST_RUNNER=qemu-user tools/no-std.sh | |
if: startsWith(matrix.os, 'ubuntu') || matrix.os == '' | |
- run: cargo +esp build --target xtensa-esp32-none-elf -Z build-std=core,alloc --features "${TEST_FEATURES},openocd-semihosting" | |
if: matrix.rust == 'stable' && (startsWith(matrix.os, 'ubuntu') || matrix.os == '') |