chore: fix deployment #118
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: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Cleanup pre-installed Rust toolchains | |
# The pre-installed toolchain is under root permission, and this would | |
# make tarball fail to extract. Here we remove the symlink and install | |
# our own Rust toolchain if necessary. | |
run: | | |
which rustup | |
which cargo | |
if [[ -L "$HOME/.cargo" && -L "$HOME/.rustup" ]]; then | |
rm -v "$HOME/.rustup" | |
rm -v "$HOME/.cargo" | |
fi | |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
- name: Cache rustup | |
uses: actions/cache@v1 | |
with: | |
path: ~/.rustup | |
key: ${{ runner.os }}-rustup-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-rustup- | |
- name: Cache cargo binaries | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/bin | |
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-bin- | |
- name: Cache cargo registry cache | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/registry/cache | |
key: ${{ runner.os }}-cargo-registry-cache-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry-cache- | |
- name: Cache cargo registry index | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/registry/index | |
key: ${{ runner.os }}-cargo-registry-index-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry-index- | |
- name: Cache cargo git db | |
uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/git/db | |
key: ${{ runner.os }}-cargo-git-db-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-git-db- | |
- name: Cache cargo build | |
uses: actions/cache@v1 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build-target- | |
- name: Install stable Rust | |
run: | | |
if [[ ! -d "$HOME/.cargo" || ! -d "$HOME/.rustup" ]]; then | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh | |
sh rustup-init.sh -y --default-toolchain none | |
fi | |
rustup update stable | |
rustup default stable | |
- name: Test and build | |
run: | | |
cargo test --verbose | |
cargo build --verbose | |
- name: Lint | |
run: cargo fmt -- --check # TODO: add clippy |