-
Notifications
You must be signed in to change notification settings - Fork 11
144 lines (142 loc) · 4.08 KB
/
ci.yml
File metadata and controls
144 lines (142 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: CI
on:
push:
pull_request:
env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: full
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
build:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dunused-crate-dependencies
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install krb5
run: |
sudo apt install -y libkrb5-dev
- name: Install cargo-all-features
run: cargo install cargo-all-features
- name: Build code
run: cargo build-all-features
features:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.compute-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: romnn/cargo-feature-combinations@main
- name: Compute feature matrix
id: compute-matrix
run: |-
MATRIX="$(cargo fc matrix)"
echo "matrix=${MATRIX}" >> "$GITHUB_OUTPUT"
test-matrix:
needs: [build, features]
runs-on: ubuntu-latest
name: "Test features: [${{ matrix.package.features }}]"
env:
RUST_LOG: debug
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.features.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install krb5
run: |
sudo apt install -y libkrb5-dev
- name: Test code
run: cargo test --features "${{ matrix.package.features }}" -- --nocapture
test:
needs: [test-matrix]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
coverage:
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master')
needs: [test]
runs-on: ubuntu-latest
env:
RUST_LOG: debug
RUSTFLAGS: -Cinstrument-coverage
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- run: cargo install grcov
- name: Install krb5
run: |
sudo apt install -y libkrb5-dev
- run: cargo build --all-features --verbose
- name: Run tests
run: LLVM_PROFILE_FILE="zookeeper-client-%p-%m.profraw" cargo test --all-features --verbose -- --nocapture
- name: Generate coverage report
run: grcov $(find . -name "zookeeper-*.profraw" -print) --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
verbose: true
lint:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- name: Install krb5
run: |
sudo apt install -y libkrb5-dev
- name: Lint code
run: cargo clippy --all-targets --all-features --no-deps -- -D clippy::all
release:
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: [build, test, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install krb5
run: |
sudo apt install -y libkrb5-dev
- name: publish crate
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish