-
Notifications
You must be signed in to change notification settings - Fork 76
219 lines (187 loc) · 6.07 KB
/
pull_request.yml
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: PR Checks
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
SCCACHE_GHA_ENABLED: "true"
CARGO_INCREMENTAL: 0 # CI will compile all crates from beginning. So disable incremental compile may reduce compile target size.
container:
image: ghcr.io/xline-kv/build-env:latest
volumes:
- /usr/local/lib/android/:/tmp/android/
- /usr/share/dotnet:/tmp/dotnet
- /opt/ghc:/tmp/ghc
- /usr/lib/firefox:/tmp/firefox
strategy:
fail-fast: true
matrix:
config:
- {
name: "Normal",
args: "",
rustflags: "",
test: "llvm-cov nextest --all-features --workspace --codecov --output-path codecov.info && cargo test --doc",
}
- {
name: "Madsim",
args: "--package=simulation",
rustflags: "--cfg madsim",
test: "nextest run --package=simulation && cargo test -p simulation --doc",
}
name: Tests ${{ matrix.config.name }}
steps:
- name: View free disk space
run: df -h /
- name: Setup sccache-cache
uses: mozilla-actions/[email protected]
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Free Disk Space
run: |
rm -rf /tmp/android/* || true
rm -rf /tmp/dotnet/* || true
rm -rf /tmp/ghc/* || true
rm -rf /tmp/firefox/* || true
- name: View free disk space
run: df -h /
- name: Trailing spaces check
run: ci/scripts/check-trailing-spaces.sh
- name: Audit
run: cargo audit
- name: Format
run: cargo fmt --all -- --check
- name: Sort crates
run: cargo sort --check --workspace
- name: Check dependencies
run: cargo machete crates/
- name: Workspace hack check
run: cargo hakari generate --diff && cargo hakari manage-deps --dry-run && cargo hakari verify
- run: ${SCCACHE_PATH} --zero-stats > /dev/null
- name: Clippy ${{ matrix.config.name }}
env:
RUSTFLAGS: ${{ matrix.config.rustflags }}
run: cargo clippy ${{ matrix.config.args }} --all-targets --all-features -- -D warnings
- name: Sccache stats ${{ matrix.config.name }}
run: ${SCCACHE_PATH} --show-stats && ${SCCACHE_PATH} --zero-stats > /dev/null
- name: Test ${{ matrix.config.name }}
env:
RUSTFLAGS: ${{ matrix.config.rustflags }}
run: cargo ${{ matrix.config.test }}
- name: Sccache stats ${{ matrix.config.name }}
run: ${SCCACHE_PATH} --show-stats
- name: Upload coverage to Codecov
if: matrix.config.name == 'Normal'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: codecov.info
verbose: true
commit:
name: Commit Message Validation
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git show-ref
- uses: actions-rs/[email protected]
with:
crate: git-cz
version: latest
- name: Validate commit messages
run: git-cz check ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
spell-check:
name: Spell Check
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Spelling
uses: crate-ci/[email protected]
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup sccache-cache
uses: mozilla-actions/[email protected]
- name: Build xline image
run: |
docker run -q --rm -v $(pwd):/xline \
-e SCCACHE_GHA_ENABLED=on \
-e ACTIONS_CACHE_URL=${ACTIONS_CACHE_URL} \
-e ACTIONS_RUNTIME_TOKEN=${ACTIONS_RUNTIME_TOKEN} \
ghcr.io/xline-kv/build-env:latest \
cargo build --release --bin xline --bin benchmark
sudo apt-get install -y --force-yes expect
cd scripts
cp ../target/release/{xline,benchmark} .
ldd ./xline
ldd ./benchmark
cp ../fixtures/{private,public}.pem .
docker build . -t ghcr.io/xline-kv/xline:master
cd ..
pwd
mkdir -p _output
docker save -o _output/xline.tar ghcr.io/xline-kv/xline:master
ls _output
- uses: actions/upload-artifact@v4
with:
name: xline
path: _output/xline.tar
e2e:
name: E2E kube
runs-on: ubuntu-latest
needs:
- build
strategy:
fail-fast: false
matrix:
k8s:
- v1.27.3
- v1.28.7
- v1.29.2
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: xline
- name: Build kind node image with xline
run: |
docker build . -f ci/artifacts/kind-node-xline.Dockerfile -t ghcr.io/xline-kv/kind-node-xline:${{ matrix.k8s }}-master --build-arg K8S_VERSION=${{ matrix.k8s }}
- name: Create kubernetes cluster with kind
env:
K8S_VERSION: ${{ matrix.k8s }}
run: |
./ci/scripts/kind.sh
- name: Get cluster status
run: |
kubectl run test --image httpd:2
kubectl wait --timeout=1m --for=condition=ready pods test
kubectl get pods -A -owide
- name: Export logs
if: failure()
run: |
mkdir -p _artifacts
docker ps
kind export logs --loglevel=debug ./_artifacts/logs
ls _artifacts
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: xline-kind-log-${{ matrix.k8s }}-${{ github.run_id }}
path: ./_artifacts/logs