Skip to content

CI

CI #1928

Workflow file for this run

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
RUST_TEST_THREADS: 1
RUSTDOCFLAGS: -D warnings
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
ATOMIC_MAYBE_UNINIT_DENY_WARNINGS: 1
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
msrv:
needs: tidy
uses: taiki-e/github-actions/.github/workflows/msrv.yml@main
with:
event_name: ${{ github.event_name }}
tidy:
uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
test:
needs: tidy
strategy:
fail-fast: false
matrix:
include:
- rust: '1.59'
- rust: stable
- rust: beta
- rust: nightly
- rust: nightly
flags: -C panic=abort -Z panic_abort_tests
- rust: nightly
flags: -Z codegen-backend=cranelift
- rust: nightly
# target: x86_64-apple-darwin
os: macos-13
- rust: nightly
target: aarch64-apple-darwin
os: macos-14
- rust: '1.59'
target: aarch64-unknown-linux-gnu
- rust: stable
target: aarch64-unknown-linux-gnu
- rust: nightly-2024-07-31 # LLVM 19 bug: https://github.com/rust-lang/rust/issues/129585
target: aarch64-unknown-linux-gnu
- rust: nightly
target: aarch64-unknown-linux-gnu
flags: -Z codegen-backend=cranelift
- rust: nightly-2024-07-31 # LLVM 19 bug: https://github.com/rust-lang/rust/issues/129585
target: aarch64_be-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use stable asm on this target)
target: aarch64_be-unknown-linux-gnu
- rust: '1.59'
target: armv5te-unknown-linux-gnueabi
- rust: stable
target: armv5te-unknown-linux-gnueabi
- rust: nightly
target: armv5te-unknown-linux-gnueabi
- rust: '1.59'
target: arm-unknown-linux-gnueabi
- rust: stable
target: arm-unknown-linux-gnueabi
- rust: nightly
target: arm-unknown-linux-gnueabi
- rust: '1.59'
target: armv7-unknown-linux-gnueabi
- rust: stable
target: armv7-unknown-linux-gnueabi
- rust: nightly
target: armv7-unknown-linux-gnueabi
- rust: '1.59'
target: armv7-unknown-linux-gnueabihf
- rust: stable
target: armv7-unknown-linux-gnueabihf
- rust: nightly
target: armv7-unknown-linux-gnueabihf
- rust: nightly
target: armeb-unknown-linux-gnueabi
- rust: nightly-2022-09-16 # Rust 1.65, LLVM 15 (version that this target was added)
target: armeb-unknown-linux-gnueabi
- rust: '1.59'
target: i586-unknown-linux-gnu
- rust: stable
target: i586-unknown-linux-gnu
- rust: nightly
target: i586-unknown-linux-gnu
- rust: '1.59'
target: i686-unknown-linux-gnu
- rust: stable
target: i686-unknown-linux-gnu
- rust: nightly
target: i686-unknown-linux-gnu
- rust: nightly
target: hexagon-unknown-linux-musl
- rust: nightly-2023-08-23 # The last nightly version that doesn't support MaybeUninit registers.
target: hexagon-unknown-linux-musl
- rust: '1.72' # inline asm for loongarch has been stabilized in Rust 1.72
target: loongarch64-unknown-linux-gnu
- rust: stable
target: loongarch64-unknown-linux-gnu
- rust: nightly
target: loongarch64-unknown-linux-gnu
- rust: nightly
target: mips-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mips-unknown-linux-gnu
- rust: nightly
target: mipsel-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mipsel-unknown-linux-gnu
- rust: nightly
target: mips64-unknown-linux-gnuabi64
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mips64-unknown-linux-gnuabi64
- rust: nightly
target: mips64el-unknown-linux-gnuabi64
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mips64el-unknown-linux-gnuabi64
- rust: nightly
target: mipsisa32r6-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mipsisa32r6-unknown-linux-gnu
- rust: nightly
target: mipsisa32r6el-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mipsisa32r6el-unknown-linux-gnu
- rust: nightly
target: mipsisa64r6-unknown-linux-gnuabi64
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mipsisa64r6-unknown-linux-gnuabi64
- rust: nightly
target: mipsisa64r6el-unknown-linux-gnuabi64
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: mipsisa64r6el-unknown-linux-gnuabi64
- rust: nightly
target: powerpc-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: powerpc-unknown-linux-gnu
- rust: nightly
target: powerpc64-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: powerpc64-unknown-linux-gnu
- rust: nightly
target: powerpc64le-unknown-linux-gnu
- rust: nightly-2021-12-16 # Rust 1.59, LLVM 13 (oldest version we can use asm_experimental_arch on this target)
target: powerpc64le-unknown-linux-gnu
- rust: nightly
target: riscv32gc-unknown-linux-gnu
- rust: nightly-2023-08-23 # The last nightly version that doesn't support MaybeUninit registers.
target: riscv32gc-unknown-linux-gnu
- rust: '1.59'
target: riscv64gc-unknown-linux-gnu
- rust: stable
target: riscv64gc-unknown-linux-gnu
- rust: nightly-2024-07-31 # LLVM 19 bug: https://github.com/rust-lang/rust/issues/129585
target: riscv64gc-unknown-linux-gnu
# TODO: cranelift doesn't support cfg(target_feature): https://github.com/rust-lang/rustc_codegen_cranelift/issues/1400
# - rust: nightly
# target: riscv64gc-unknown-linux-gnu
# flags: -Z codegen-backend=cranelift
- rust: nightly
target: s390x-unknown-linux-gnu
- rust: nightly-2024-01-04 # Rust 1.77, LLVM 17 (newest version that does not support reg_addr register class)
target: s390x-unknown-linux-gnu
- rust: nightly-2023-05-09 # Rust 1.71, LLVM 16 (oldest version we can implement atomic RMWs on this target)
target: s390x-unknown-linux-gnu
- rust: '1.59'
target: thumbv7neon-unknown-linux-gnueabihf
- rust: stable
target: thumbv7neon-unknown-linux-gnueabihf
- rust: nightly
target: thumbv7neon-unknown-linux-gnueabihf
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
timeout-minutes: 60
steps:
- uses: taiki-e/checkout-action@v1
- run: |
lscpu
# sudo apt-get -o Acquire::Retries=10 -qq update && sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends moreutils
if: startsWith(matrix.os, 'ubuntu') || matrix.os == ''
- run: |
sysctl hw.optional machdep.cpu
# brew install moreutils
if: startsWith(matrix.os, 'macos')
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: ${{ matrix.rust }}
- run: rustup toolchain add nightly --no-self-update
if: startsWith(matrix.rust, '1.5') || startsWith(matrix.rust, '1.6') || startsWith(matrix.rust, 'nightly-2021') || startsWith(matrix.rust, 'nightly-2022') || startsWith(matrix.rust, 'nightly-2023')
- 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 }}
if: matrix.target != ''
- run: printf '%s\n' "RUSTFLAGS=${RUSTFLAGS} --cfg qemu" >>"${GITHUB_ENV}"
if: matrix.target != '' && !startsWith(matrix.target, 'i686') && !startsWith(matrix.target, 'x86_64') && !startsWith(matrix.os, 'macos')
- run: |
printf '%s\n' "RUSTFLAGS=${RUSTFLAGS} ${{ matrix.flags }}" >>"${GITHUB_ENV}"
printf '%s\n' "RUSTDOCFLAGS=${RUSTDOCFLAGS} ${{ matrix.flags }}" >>"${GITHUB_ENV}"
if: matrix.flags != ''
- run: printf '%s\n' "TARGET=--target=${{ matrix.target }}" >>"${GITHUB_ENV}"
if: matrix.target != '' && !contains(matrix.target, '-darwin')
# TODO: LLVM bug: Undefined temporary symbol error when building std.
- run: printf 'RELEASE=--release\n' >>"${GITHUB_ENV}"
if: startsWith(matrix.target, 'mips-') || startsWith(matrix.target, 'mipsel-')
- run: tools/test.sh -vv ${TARGET:-} ${DOCTEST_XCOMPILE:-} ${BUILD_STD:-} ${RELEASE:-}
# We test doctest only once with the default build conditions because doctest is slow.
# src/tests has extended copies of doctest, so this will not reduce test coverage.
# x86_64 +cmpxchg16b
# macOS is skipped because it is +cmpxchg16b by default
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=+cmpxchg16b
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=+cmpxchg16b
if: (matrix.target == '' || startsWith(matrix.target, 'x86_64')) && !startsWith(matrix.os, 'macos')
# x86 -sse2
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=-sse2
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=-sse2
if: startsWith(matrix.target, 'i686')
# x86 -x87
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=+soft-float,-x87,-mmx
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=+soft-float,-x87,-mmx
if: startsWith(matrix.target, 'i586')
# aarch64 +lse
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=+lse
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=+lse
# macOS is skipped because it is +rcpc,+lse,+lse2 by default
if: startsWith(matrix.target, 'aarch64') && !contains(matrix.target, '-darwin')
# aarch64 +rcpc,+lse,+lse2
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=+rcpc,+lse,+lse2
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=+rcpc,+lse,+lse2
# macOS is skipped because it is +rcpc,+lse,+lse2 by default
if: startsWith(matrix.target, 'aarch64') && !contains(matrix.target, '-darwin')
# arm v8 little endian
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=+v8
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=+v8
if: matrix.target == 'armv7-unknown-linux-gnueabi'
# arm v6 with legacy cp15_barrier
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg atomic_maybe_uninit_use_cp15_barrier
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} --cfg atomic_maybe_uninit_use_cp15_barrier
if: matrix.target == 'arm-unknown-linux-gnueabi'
# arm v7 big endian
# armeb-unknown-linux-gnueabi is v8 by default, use custom target instead
- run: tools/test.sh -vv --tests --target armebv7-unknown-linux-gnueabi -Z build-std ${RELEASE:-}
env:
CARGO_TARGET_ARMEBV7_UNKNOWN_LINUX_GNUEABI_LINKER: armeb-unknown-linux-gnueabi-gcc
CARGO_TARGET_ARMEBV7_UNKNOWN_LINUX_GNUEABI_RUNNER: qemu-armeb
if: startsWith(matrix.rust, 'nightly') && matrix.target == 'armeb-unknown-linux-gnueabi'
# arm v4t
- run: tools/test.sh -vv --tests --target armv4t-unknown-linux-gnueabi -Z build-std ${RELEASE:-}
env:
CARGO_TARGET_ARMV4T_UNKNOWN_LINUX_GNUEABI_LINKER: arm-linux-gnueabi-gcc
CARGO_TARGET_ARMV4T_UNKNOWN_LINUX_GNUEABI_RUNNER: qemu-arm
if: startsWith(matrix.rust, 'nightly') && matrix.target == 'armv5te-unknown-linux-gnueabi'
# powerpc64 pwr7
# powerpc64- (big-endian) is skipped because it is pre-pwr8 by default
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-cpu=pwr7
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-cpu=pwr7
if: startsWith(matrix.target, 'powerpc64le-')
# powerpc64 pwr8
# powerpc64le- (little-endian) is skipped because it is pwr8 by default
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-cpu=pwr8
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-cpu=pwr8
if: startsWith(matrix.target, 'powerpc64-')
# s390x z196 (arch9)
- run: tools/test.sh -vv --tests ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
env:
# TODO: disable high-word LLVM target-feature to avoid LLVM codegen bug.
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-cpu=z196 -C target-feature=-high-word
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-cpu=z196 -C target-feature=-high-word
if: startsWith(matrix.target, 's390x')
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-}
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features ${TARGET:-} ${BUILD_STD:-} ${RELEASE:-} --direct
# Old nightly compilers do not support -Z direct-minimal-versions
if: matrix.rust == 'nightly'
build:
needs: tidy
strategy:
fail-fast: false
matrix:
rust:
- '1.59'
- stable
- beta
- nightly-2023-08-23 # The last nightly version that doesn't support MaybeUninit registers.
- nightly-2023-08-24 # The oldest nightly version that supports MaybeUninit registers: https://github.com/rust-lang/rust/pull/114790
- nightly
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
- run: tools/build.sh
no-std:
needs: tidy
strategy:
fail-fast: false
matrix:
rust:
- '1.64'
- stable
- nightly-2023-08-23 # The last nightly version that doesn't support MaybeUninit registers.
- nightly
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: taiki-e/checkout-action@v1
- run: |
sudo apt-get -o Acquire::Retries=10 -qq update && sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends \
avr-libc \
gcc-avr \
qemu-system-arm \
qemu-system-misc \
simavr
# APT's qemu package doesn't provide firmware for riscv32: https://packages.ubuntu.com/en/jammy/all/qemu-system-data/filelist
OPENSBI_VERSION=1.5.1 # https://github.com/riscv-software-src/opensbi/releases
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"
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: ${{ matrix.rust }}
- run: rm -- tests/avr/rust-toolchain.toml
if: startsWith(matrix.rust, 'nightly-')
- run: tools/no-std.sh
valgrind:
needs: tidy
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: taiki-e/checkout-action@v1
- uses: taiki-e/github-actions/install-rust@nightly
# - run: sudo apt-get -o Acquire::Retries=10 -qq update && sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends moreutils
- uses: taiki-e/install-action@valgrind
- run: tools/test.sh valgrind -vv
# +cmpxchg16b
- run: tools/test.sh valgrind -vv
env:
RUSTDOCFLAGS: ${{ env.RUSTDOCFLAGS }} -C target-feature=+cmpxchg16b
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C target-feature=+cmpxchg16b
codegen:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
pull-requests: write # for gh pr edit --add-assignee
repository-projects: read # for gh pr edit --add-assignee
steps:
- uses: taiki-e/checkout-action@v1
- uses: taiki-e/github-actions/install-rust@nightly
- run: tools/target_spec.sh
- id: diff
run: tools/ci/gen.sh
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main')
- id: create-pull-request
uses: peter-evans/create-pull-request@v7
with:
title: Update generated code
body: |
Auto-generated by CI using [create-pull-request](https://github.com/peter-evans/create-pull-request).
branch: update-generated-code
token: ${{ secrets.CREATE_PR_TOKEN }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false'
- name: Notify PR author by assigning PR
run: gh pr edit --add-assignee taiki-e "${PR_NUMBER:?}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false'
- run: git add -N . && git diff --exit-code