| 1 |
name: Continuous Integration |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- master |
| 7 |
pull_request: |
| 8 |
|
| 9 |
jobs: |
| 10 |
|
| 11 |
lint: |
| 12 |
runs-on: ubuntu-latest |
| 13 |
|
| 14 |
steps: |
| 15 |
- name: Checkout sources |
| 16 |
uses: actions/checkout@v2 |
| 17 |
|
| 18 |
- name: Get date for registry cache |
| 19 |
id: date |
| 20 |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" |
| 21 |
|
| 22 |
- name: Cargo registry cache |
| 23 |
uses: actions/cache@v2 |
| 24 |
with: |
| 25 |
path: | |
| 26 |
~/.cargo/registry/index |
| 27 |
~/.cargo/registry/cache |
| 28 |
~/.cargo/git |
| 29 |
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }} |
| 30 |
restore-keys: ${{ runner.os }}-cargo-registry- |
| 31 |
|
| 32 |
- name: Rust toolchain |
| 33 |
uses: actions-rs/toolchain@v1 |
| 34 |
with: |
| 35 |
toolchain: stable |
| 36 |
override: true |
| 37 |
components: rustfmt, clippy |
| 38 |
|
| 39 |
- name: Get cargo-cache latest version |
| 40 |
id: cargocacheversion |
| 41 |
run: echo "::set-output name=version::$(cargo search 'cargo-cache' --limit 1 | head -n 1 | cut -d ' ' -f 3 | cut -d '"' -f 2)" |
| 42 |
|
| 43 |
- name: Cargo binaries cache |
| 44 |
uses: actions/cache@v2 |
| 45 |
with: |
| 46 |
path: | |
| 47 |
~/.cargo/bin/cargo-cache |
| 48 |
~/.cargo/.crates.toml |
| 49 |
~/.cargo/.crates2.json |
| 50 |
key: ${{ runner.os }}-cargo-binaries-${{ steps.cargocacheversion.outputs.version }} |
| 51 |
|
| 52 |
- name: Install cargo-cache |
| 53 |
uses: actions-rs/cargo@v1 |
| 54 |
with: |
| 55 |
command: install |
| 56 |
args: cargo-cache --version ${{ steps.cargocacheversion.outputs.version }} |
| 57 |
|
| 58 |
- name: Clean cargo cache of old items |
| 59 |
uses: actions-rs/cargo@v1 |
| 60 |
with: |
| 61 |
command: cache |
| 62 |
args: clean-unref |
| 63 |
|
| 64 |
- name: Get rustc version for caching |
| 65 |
id: rustcversion |
| 66 |
run: echo "::set-output name=version::$(rustc --version | cut -d ' ' -f 2)" |
| 67 |
|
| 68 |
- name: Build cache |
| 69 |
uses: actions/cache@v2 |
| 70 |
with: |
| 71 |
path: target |
| 72 |
key: ${{ runner.os }}-lint-${{ steps.rustcversion.outputs.version }}-${{ hashFiles('**/Cargo.toml') }} |
| 73 |
|
| 74 |
- name: Cargo fmt |
| 75 |
run: cargo fmt --all -- --check |
| 76 |
|
| 77 |
- name: Clippy |
| 78 |
run: cargo clippy --workspace --all-features --all-targets -- -D warnings |
| 79 |
|
| 80 |
ci-linux: |
| 81 |
name: CI |
| 82 |
|
| 83 |
needs: |
| 84 |
- lint |
| 85 |
|
| 86 |
strategy: |
| 87 |
fail-fast: false |
| 88 |
matrix: |
| 89 |
rust: ['1.53.0', 'stable', 'beta'] |
| 90 |
|
| 91 |
runs-on: 'ubuntu-latest' |
| 92 |
|
| 93 |
steps: |
| 94 |
- name: Checkout sources |
| 95 |
uses: actions/checkout@v2 |
| 96 |
|
| 97 |
- name: Get date for registry cache |
| 98 |
id: date |
| 99 |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" |
| 100 |
|
| 101 |
- name: Cargo registry cache |
| 102 |
uses: actions/cache@v2 |
| 103 |
with: |
| 104 |
path: | |
| 105 |
~/.cargo/registry/index |
| 106 |
~/.cargo/registry/cache |
| 107 |
~/.cargo/git |
| 108 |
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }} |
| 109 |
restore-keys: ${{ runner.os }}-cargo-registry- |
| 110 |
|
| 111 |
- name: Rust toolchain |
| 112 |
uses: actions-rs/toolchain@v1 |
| 113 |
with: |
| 114 |
toolchain: ${{ matrix.rust }} |
| 115 |
override: true |
| 116 |
|
| 117 |
- name: Get rustc version for caching |
| 118 |
id: rustcversion |
| 119 |
run: echo "::set-output name=version::$(rustc --version | cut -d ' ' -f 2)" |
| 120 |
|
| 121 |
- name: Build cache |
| 122 |
uses: actions/cache@v2 |
| 123 |
with: |
| 124 |
path: target |
| 125 |
key: ${{ runner.os }}-test-${{ steps.rustcversion.outputs.version }}-${{ hashFiles('**/Cargo.toml') }} |
| 126 |
|
| 127 |
- name: Run tests |
| 128 |
uses: actions-rs/cargo@v1 |
| 129 |
with: |
| 130 |
command: test |
| 131 |
args: --workspace --all-features |
| 132 |
|
| 133 |
coverage: |
| 134 |
name: Coverage |
| 135 |
|
| 136 |
needs: |
| 137 |
- ci-linux |
| 138 |
|
| 139 |
strategy: |
| 140 |
fail-fast: false |
| 141 |
matrix: |
| 142 |
os: ['ubuntu-latest', 'macos-latest'] |
| 143 |
|
| 144 |
runs-on: ${{ matrix.os }} |
| 145 |
|
| 146 |
env: |
| 147 |
GRCOV_VERSION: "0.8.10" |
| 148 |
|
| 149 |
steps: |
| 150 |
- name: Checkout sources |
| 151 |
uses: actions/checkout@v2 |
| 152 |
|
| 153 |
- name: Get date for registry cache |
| 154 |
id: date |
| 155 |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" |
| 156 |
|
| 157 |
- name: Cargo registry cache |
| 158 |
uses: actions/cache@v2 |
| 159 |
with: |
| 160 |
path: | |
| 161 |
~/.cargo/registry/index |
| 162 |
~/.cargo/registry/cache |
| 163 |
~/.cargo/git |
| 164 |
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }} |
| 165 |
restore-keys: ${{ runner.os }}-cargo-registry- |
| 166 |
|
| 167 |
- name: Rust toolchain |
| 168 |
uses: actions-rs/toolchain@v1 |
| 169 |
with: |
| 170 |
toolchain: nightly |
| 171 |
override: true |
| 172 |
components: llvm-tools-preview |
| 173 |
|
| 174 |
- name: Get grcov latest version |
| 175 |
id: grcovversion |
| 176 |
run: echo "::set-output name=version::$(cargo search 'grcov' --limit 1 | head -n 1 | cut -d ' ' -f 3 | cut -d '"' -f 2)" |
| 177 |
|
| 178 |
- name: grcov cache |
| 179 |
uses: actions/cache@v2 |
| 180 |
with: |
| 181 |
path: | |
| 182 |
~/.cargo/bin/grcov |
| 183 |
~/.cargo/.crates.toml |
| 184 |
~/.cargo/.crates2.json |
| 185 |
key: ${{ runner.os }}-grcov-${{ steps.grcovversion.outputs.version }} |
| 186 |
|
| 187 |
- name: Install grcov |
| 188 |
uses: actions-rs/cargo@v1 |
| 189 |
with: |
| 190 |
command: install |
| 191 |
args: grcov --version ${{ steps.grcovversion.outputs.version }} |
| 192 |
|
| 193 |
- name: Run tests |
| 194 |
uses: actions-rs/cargo@v1 |
| 195 |
with: |
| 196 |
command: test |
| 197 |
args: --all-features |
| 198 |
env: |
| 199 |
LLVM_PROFILE_FILE: "calloop-%p-%m.profraw" |
| 200 |
RUSTFLAGS: "-Cinstrument-coverage --cfg coverage" |
| 201 |
|
| 202 |
- name: Coverage |
| 203 |
run: grcov . --binary-path ./target/debug -s . -t lcov --branch --llvm --ignore-not-existing --ignore 'examples/*' --ignore 'tests/*' --ignore '*/.cargo/registry/*' --excl-br-start "mod tests \{" --excl-start "mod tests \{" --excl-br-line "#\[derive\(" --excl-line "#\[derive\(" -o lcov.info |
| 204 |
|
| 205 |
- name: Upload to codecov.io |
| 206 |
uses: codecov/codecov-action@v2 |
| 207 |
with: |
| 208 |
files: ./lcov.info |
| 209 |
flags: ${{ matrix.os }} |
| 210 |
|
| 211 |
doc: |
| 212 |
name: Documentation on Github Pages |
| 213 |
runs-on: ubuntu-latest |
| 214 |
|
| 215 |
needs: |
| 216 |
- ci-linux |
| 217 |
|
| 218 |
steps: |
| 219 |
- name: Checkout sources |
| 220 |
uses: actions/checkout@v2 |
| 221 |
|
| 222 |
- name: Get date for registry cache |
| 223 |
id: date |
| 224 |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" |
| 225 |
|
| 226 |
- name: Cargo registry cache |
| 227 |
uses: actions/cache@v2 |
| 228 |
with: |
| 229 |
path: | |
| 230 |
~/.cargo/registry/index |
| 231 |
~/.cargo/registry/cache |
| 232 |
~/.cargo/git |
| 233 |
key: ${{ runner.os }}-cargo-registry-${{ steps.date.outputs.date }} |
| 234 |
restore-keys: ${{ runner.os }}-cargo-registry- |
| 235 |
|
| 236 |
- name: Rust toolchain |
| 237 |
uses: actions-rs/toolchain@v1 |
| 238 |
with: |
| 239 |
toolchain: beta |
| 240 |
override: true |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
- name: Build Documentation |
| 247 |
uses: actions-rs/cargo@v1 |
| 248 |
with: |
| 249 |
command: doc |
| 250 |
args: --no-deps --all-features |
| 251 |
|
| 252 |
- run: rsync -r target/doc/ doc/src/api |
| 253 |
|
| 254 |
- name: Build mdBook |
| 255 |
uses: peaceiris/actions-mdbook@v1 |
| 256 |
with: |
| 257 |
mdbook-version: '0.4.8' |
| 258 |
|
| 259 |
- run: mdbook build doc |
| 260 |
|
| 261 |
- name: Deploy |
| 262 |
uses: peaceiris/actions-gh-pages@v3 |
| 263 |
if: ${{ github.event_name == 'push' }} |
| 264 |
with: |
| 265 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 266 |
publish_dir: ./doc/book |