image: ubuntu:18.04
tasks:
install_packages:
command: |
set -euxo pipefail
apt-get update
apt-get install --yes build-essential curl
install_tagref:
dependencies:
- install_packages
command: |
set -euxo pipefail
curl https://raw.githubusercontent.com/stepchowfun/tagref/master/install.sh -LSfs | VERSION=1.1.0 sh
create_user:
command: |
set -euxo pipefail
adduser --disabled-password --gecos '' user
install_rust:
dependencies:
- install_packages
- create_user
user: user
command: |
set -euxo pipefail
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable-2019-04-25-x86_64-unknown-linux-gnu
. $HOME/.cargo/env
rustup component add clippy
rustup component add rustfmt
rm -rf "$(dirname "$(rustup which rustc)")/../share"
install_tools:
dependencies:
- install_rust
- install_tagref
fetch_crates:
dependencies:
- install_tools
paths:
- Cargo.lock
- Cargo.toml
user: user
command: |
set -euxo 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 clippy
rm -rf src
build:
dependencies:
- fetch_crates
paths:
- src
user: user
command: |
set -euxo pipefail
. $HOME/.cargo/env
cargo build
test:
dependencies:
- build
user: user
command: |
set -euxo pipefail
. $HOME/.cargo/env
cargo test
lint:
dependencies:
- build
paths:
- .ignore - clippy.toml - rustfmt.toml user: user
command: |
set -euxo pipefail
. $HOME/.cargo/env
cargo fmt --all -- --check
cargo clippy -- --deny clippy::pedantic
tagref