test: Use the bash container and a matrix strategy for bash versions #1130
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: Cargo & Clippy Test | |
on: | |
push: | |
branches: [master] | |
paths: | |
- src/** | |
- test_files/** | |
- .cargo/** | |
- Cargo.toml | |
- Cargo.lock | |
- rust-toolchain.toml | |
- flake.nix | |
- flake.lock | |
pull_request: | |
paths: | |
- src/** | |
- test_files/** | |
- .cargo/** | |
- Cargo.toml | |
- Cargo.lock | |
- rust-toolchain.toml | |
- flake.nix | |
- flake.lock | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build_and_test: | |
name: Rust and clippy tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
bash_docker_image: | |
- "bash:5.2" | |
- "bash:5.1" | |
- "bash:5.0" | |
- "bash:4.4" | |
- "bash:4.3" | |
- "bash:4.2" | |
- "bash:4.1" | |
- "bash:4.0" | |
- "bash:3.2" | |
# - "bash:3.1" # https://github.com/amber-lang/amber/issues/621 | |
sed: | |
- GNU sed | |
# Uncomment the next matrix when https://github.com/amber-lang/amber/issues/617 is resolved | |
# include: | |
# - sed: BusyBox sed | |
# bash_version: "bash:latest" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: bc shfmt | |
version: 1.0 | |
- name: Install bshchk | |
run: | | |
sudo curl https://github.com/b1ek/bshchk/releases/download/1.1/bshchk.linux.amd64 -L -o /usr/bin/bshchk | |
sudo chmod +x /usr/bin/bshchk | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies installed with cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
./target/deps | |
~/.cargo | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: Build binary | |
# the binary will be used by the next cargo test step | |
run: cargo build | |
- name: Run cargo tests | |
env: | |
GITHUB_ACTIONS_BASH_CONTAINER: 1 | |
run: | | |
docker run --volume $PWD:/root --network host --detach --name test_container ${{ matrix.bash_docker_image }} sleep infinity | |
# coreutils includes mktemp | |
docker exec test_container apk add coreutils curl | |
if [ "${{ matrix.sed }}" == "GNU sed" ]; then | |
docker exec test_container apk add sed | |
fi | |
cargo test --all-targets --all-features | |
docker rm --force test_container | |
- name: Run clippy check | |
run: cargo clippy --all-targets --all-features -- -D warnings |