Skip to content

Commit a516c78

Browse files
authored
Merge pull request #5 from jtgeibel/ci/github-actions
Enable Github Actions
2 parents 83cc0dd + d8e66f8 commit a516c78

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

.github/workflows/ci.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
backend:
9+
name: Backend
10+
runs-on: ubuntu-18.04
11+
strategy:
12+
# TODO: [ci] should be true if GitHub Actions supports ""allow failures" on matrix
13+
fail-fast: false
14+
matrix:
15+
rust:
16+
- stable
17+
- beta
18+
- nightly
19+
20+
env:
21+
CARGO_INCREMENTAL: 0
22+
RUSTFLAGS: "-C debuginfo=0 -D warnings"
23+
24+
steps:
25+
- uses: actions/checkout@v2-beta
26+
27+
- name: Cleanup pre-installed Rust toolchains
28+
# The pre-installed toolchain is under root permission, and this would
29+
# make tarball fail to extract. Here we remove the symlink and install
30+
# our own Rust toolchain if necessary.
31+
run: |
32+
which rustup
33+
which cargo
34+
if [[ -L "$HOME/.cargo" && -L "$HOME/.rustup" ]]; then
35+
rm -v "$HOME/.rustup"
36+
rm -v "$HOME/.cargo"
37+
fi
38+
echo "::add-path::$HOME/.cargo/bin"
39+
40+
- name: Cache rustup
41+
uses: actions/cache@v1
42+
with:
43+
path: ~/.rustup
44+
key: ${{ runner.os }}-rustup2-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
45+
restore-key: |
46+
${{ runner.os }}-rustup2-${{ matrix.rust }}-
47+
48+
- name: Cache cargo binaries
49+
uses: actions/cache@v1
50+
with:
51+
path: ~/.cargo/bin
52+
key: ${{ runner.os }}-cargo-bin-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
53+
restore-key: |
54+
${{ runner.os }}-cargo-bin-${{ matrix.rust }}-
55+
56+
- name: Cache cargo registry cache
57+
uses: actions/cache@v1
58+
with:
59+
path: ~/.cargo/registry/cache
60+
key: ${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
61+
restore-key: |
62+
${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}-
63+
${{ runner.os }}-cargo-registry-cache-
64+
65+
- name: Cache cargo registry index
66+
uses: actions/cache@v1
67+
with:
68+
path: ~/.cargo/registry/index
69+
key: ${{ runner.os }}-cargo-registry-index-${{ github.ref }}-${{ github.sha }}
70+
restore-key: |
71+
${{ runner.os }}-cargo-registry-index-${{ github.ref }}-
72+
${{ runner.os }}-cargo-registry-index-ref/heads/master-
73+
74+
- name: Cache cargo git db
75+
uses: actions/cache@v1
76+
with:
77+
path: ~/.cargo/git/db
78+
key: ${{ runner.os }}-cargo-git-db-${{ github.ref }}-${{ hashFiles('**/Cargo.toml') }}
79+
restore-key: |
80+
${{ runner.os }}-cargo-git-db-${{ github.ref }}-
81+
${{ runner.os }}-cargo-git-db-ref/heads/master-
82+
83+
- name: Cache cargo build
84+
uses: actions/cache@v1
85+
with:
86+
path: target
87+
key: ${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-${{ github.ref }}-${{ hashFiles('**/Cargo.toml') }}
88+
restore-key: |
89+
${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-${{ github.ref }}-
90+
${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-ref/heads/master-
91+
92+
- name: Install ${{ matrix.rust }} Rust
93+
run: |
94+
if [[ ! -d "$HOME/.cargo" || ! -d "$HOME/.rustup" ]]; then
95+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
96+
sh rustup-init.sh -y --default-toolchain none
97+
fi
98+
rustup set profile minimal
99+
rustup update ${{ matrix.rust }}
100+
rustup default ${{ matrix.rust }}
101+
102+
- name: Install lint tools
103+
if: matrix.rust == 'stable'
104+
run: |
105+
rustup component add rustfmt
106+
rustup component add clippy
107+
108+
- name: Cargo clean on new rustc version
109+
run: script/ci/cargo-clean-on-new-rustc-version.sh
110+
111+
- name: Lint
112+
if: matrix.rust == 'stable'
113+
run: |
114+
cargo fmt -- --check
115+
cargo clippy --all-targets --all-features --all
116+
117+
- name: Test
118+
run: cargo test

0 commit comments

Comments
 (0)