image: ubuntu tasks: install_packages: description: Install system packages. command: | set -euo pipefail apt-get update apt-get install --yes build-essential curl libssl-dev libcurl4-openssl-dev zip unzip jq git create_user: description: Create a user without root privileges. command: | set -euo pipefail adduser --disabled-password --gecos '' user install_rust: description: Install Rust. dependencies: - install_packages - create_user user: user command: | set -euo pipefail curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly --component clippy --component rustfmt . $HOME/.cargo/env rustup component add clippy rm -rf "$(dirname "$(rustup which rustc)")/../share" install_tools: description: Install the tools needed. dependencies: - install_rust user: user command: | set -euo pipefail . $HOME/.cargo/env export OPENSSL_LIB_DIR="/usr/lib/x86_64-linux-gnu" export OPENSSL_INCLUDE_DIR="/usr/include/openssl" cargo install grcov configure_registry: description: Configure the Cratez registry dependencies: - install_rust user: user command: | echo '[net]' >> ~/.cargo/config echo 'git-fetch-with-cli = true' >> ~/.cargo/config echo '' echo '[registries]' >> ~/.cargo/config echo 'cratez = { index = "http://localhost:43110/1CRAteZVBUYrnx8jj9x87A1zCnptrWFhPH/index" }' >> ~/.cargo/config fetch_crates: description: Download and build Rust packages used by the program. dependencies: - install_tools - configure_registry - create_user user: user input_paths: - Cargo.toml - Cargo.lock command: | set -euo pipefail . $HOME/.cargo/env mv Cargo.lock Cargo.lock.og mv Cargo.toml Cargo.toml.og cargo init --vcs none mv Cargo.lock.og Cargo.lock mv Cargo.toml.og Cargo.toml cargo build cargo clean --package zerucrypt cargo clippy rm -rf src build: dependencies: - fetch_crates user: user input_paths: - src command: | set -euo pipefail . $HOME/.cargo/env cargo build test: dependencies: - build user: user command: | set -euo pipefail . $HOME/.cargo/env cargo test coverage: dependencies: - build user: user output_paths: - coverage command: | set -euo pipefail . $HOME/.cargo/env export CARGO_INCREMENTAL=0 export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" export RUSTDOCFLAGS="-Cpanic=abort" export CARGO_OPTIONS="" cargo build --verbose $CARGO_OPTIONS cargo test --verbose $CARGO_OPTIONS zip -0 ccov.zip `find . \( -name "zerucrypt*.gc*" \) -print` grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o lcov.info grcov ccov.zip -s . -t covdir --llvm --branch --ignore-not-existing --ignore "/*" -o covdir.json grcov ccov.zip -s . -t html --llvm --branch --ignore-not-existing --ignore "/*" -o html mkdir coverage echo "Total coverage: $(jq .coveragePercent covdir.json)%" mv covdir.json ./coverage mv lcov.info ./coverage mv html ./coverage doc: dependencies: - build user: user output_paths: - target/doc command: | set -euo pipefail . $HOME/.cargo/env cargo doc --no-deps