2023-12-09 17:17:47 +00:00
# SPDX-License-Identifier: EUPL-1.2
name : Run Tests
2023-07-19 14:12:15 +00:00
env :
2023-07-19 20:23:05 +00:00
CARGO_INCREMENTAL : 0
CARGO_NET_RETRY : 10
2023-07-19 14:12:15 +00:00
CARGO_REGISTRIES_CRATES_IO_PROTOCOL : sparse
2023-07-19 20:23:05 +00:00
RUSTFLAGS : "-D warnings -W unreachable-pub -W rust-2021-compatibility"
RUSTUP_MAX_RETRIES : 10
RUST_BACKTRACE : short
2023-07-19 14:12:15 +00:00
on :
workflow_dispatch :
2023-08-24 08:37:35 +00:00
pull_request :
paths :
- '.gitea/**'
- 'melib/src/**'
- 'melib/Cargo.toml'
- 'meli/src/**'
- 'meli/Cargo.toml'
- 'Cargo.toml'
- 'Cargo.lock'
2023-07-19 14:12:15 +00:00
jobs :
test :
name : Test on ${{ matrix.build }}
runs-on : ${{ matrix.os }}
strategy :
fail-fast : false
matrix :
build : [ linux-amd64, ]
include :
- build : linux-amd64
os : ubuntu-latest
rust : stable
target : x86_64-unknown-linux-gnu
steps :
2023-12-10 13:56:22 +00:00
- uses : actions/checkout@v3
2023-07-19 14:12:15 +00:00
- id : os-deps
name : install OS dependencies
run : |
apt-get update
2023-12-09 17:17:47 +00:00
apt-get install -y libdbus-1-dev pkg-config mandoc libssl-dev make
2023-07-19 20:23:05 +00:00
#- id: cache-rustup
# name: Cache Rust toolchain
# uses: https://github.com/actions/cache@v3
# with:
# path: ~/.rustup
# key: toolchain-${{ matrix.os }}-${{ matrix.rust }}
#- if: ${{ steps.cache-rustup.outputs.cache-hit != 'true' }}
2023-12-09 17:17:47 +00:00
- id : rustup-setup
name : Install rustup and toolchains
shell : bash
run : |
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
source "${HOME}/.cargo/env"
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
rustup toolchain install --profile minimal ${{ matrix.rust }} --target ${{ matrix.target }}
fi
2023-07-19 14:12:15 +00:00
- name : Configure cargo data directory
# After this point, all cargo registry and crate data is stored in
# $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files
# that are needed during the build process. Additionally, this works
# around a bug in the 'cache' action that causes directories outside of
# the workspace dir to be saved/restored incorrectly.
run : echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV
2023-07-19 20:23:05 +00:00
#- id: cache-cargo
# name: Cache cargo configuration and installations
# uses: https://github.com/actions/cache@v3
# with:
# path: ${{ env.CARGO_HOME }}
# key: cargo-${{ matrix.os }}-${{ matrix.rust }}
#- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
- name : Setup Rust target
2023-07-19 14:12:15 +00:00
run : |
mkdir -p "${{ env.CARGO_HOME }}"
cat << EOF > "${{ env.CARGO_HOME }}"/config.toml
[ build]
target = "${{ matrix.target }}"
EOF
- if : ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} && matrix.target
2023-12-09 17:17:47 +00:00
name : Add test dependencies
2023-07-19 14:12:15 +00:00
run : |
2023-07-24 11:11:00 +00:00
cargo install --quiet --version 0.9.54 --target "${{ matrix.target }}" cargo-nextest
2023-07-19 14:12:15 +00:00
- name : cargo-check
run : |
cargo check --all-features --all --tests --examples --benches --bins
2023-07-19 20:23:05 +00:00
- name : Compile
if : success() || failure()
run : cargo test --all --no-fail-fast --all-features --no-run --locked
2023-07-19 14:12:15 +00:00
- name : cargo test
if : success() || failure() # always run even if other steps fail, except when cancelled <https://stackoverflow.com/questions/58858429/how-to-run-a-github-actions-step-even-if-the-previous-step-fails-while-still-f>
run : |
2023-08-16 17:34:33 +00:00
cargo nextest run --all --no-fail-fast --all-features --future-incompat-report -E 'not (test(smtp::test::test_smtp))'
2023-07-24 11:11:00 +00:00
#cargo test --all --no-fail-fast --all-features -- --nocapture --quiet
2023-12-09 17:17:47 +00:00
- name : rustdoc build
2023-07-19 14:12:15 +00:00
if : success() || failure()
run : |
2023-12-09 17:17:47 +00:00
make build-rustdoc