forked from deadpool-rs/deadpool
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathci.jsonnet
More file actions
240 lines (226 loc) · 6.02 KB
/
ci.jsonnet
File metadata and controls
240 lines (226 loc) · 6.02 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
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
local config = std.parseJson(std.extVar("config"));
local rust_version = std.extVar("rust_version");
local crate = std.extVar("crate");
local getPathOrDefault(obj, path, default) =
if std.length(path) == 0 then
obj
else if std.type(obj) != "object" then
default
else if std.objectHas(obj, path[0]) then
getPathOrDefault(obj[path[0]], path[1:], default)
else
default;
local getConfig(path, default) =
getPathOrDefault(config, std.split(path, "."), default);
local backend = getConfig("backend", null);
local features_own = getConfig("features.own", null);
// features.optional_dependencies is a list of features which are
// modelled by optional dependencies.
local features_optional_dependencies = getConfig("features.optional-dependencies", null);
local features_required = getConfig("features.required", null);
local features =
if features_own != null || features_required != null then
(if features_own != null then features_own else []) +
(if features_required != null then features_required else [])
else
null;
local check_features = getConfig("check.features", features);
local check_extra_steps = getConfig("check.extra_steps", []);
local test_features = getConfig("test.features", features);
local test_services = getConfig("test.services", {});
local test_env = getConfig("test.env", {});
local jobs = getConfig("jobs", {});
local genFeaturesFlag(features) =
if features != null then
if std.length(features) > 0 then
" --features " + std.join(",", features)
else
""
else
" --all-features";
{
name: crate,
on: {
push: {
branches: [ "main" ],
tags: [ std.format("%s-v*", crate) ],
paths: [ std.format("crates/%s/**", crate), std.format(".github/workflows/%s.yml", crate) ]
},
pull_request: {
branches: [ "main" ],
paths: [ std.format("crates/%s/**", crate), std.format(".github/workflows/%s.yml", crate) ]
}
},
env: {
RUST_BACKTRACE: 1
},
defaults: {
run: {
"working-directory": std.format("./crates/%s", crate),
}
},
jobs: {
##########################
# Linting and formatting #
##########################
clippy: {
name: "Clippy",
"runs-on": "ubuntu-latest",
steps: [
{
uses: "actions/checkout@v5"
},
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: "stable",
components: "rustc,rust-std,cargo,clippy",
}
},
{
run: "cargo clippy --no-deps" + genFeaturesFlag(features) + " -- -D warnings"
}
]
},
rustfmt: {
name: "rustfmt",
"runs-on": "ubuntu-latest",
steps: [
{
uses: "actions/checkout@v5",
},
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: "stable",
components: "rustc,rust-std,cargo,rustfmt",
}
},
{
run: "cargo fmt --check",
},
],
},
###########
# Testing #
###########
# FIXME The check integration job should be enabled for all crates with a backend
[if check_features != null then "check-integration"]: {
name: "Check integration",
strategy: {
"fail-fast": false,
matrix: {
feature: check_features,
os: ["ubuntu-latest", "windows-2025"],
}
},
"runs-on": "${{ matrix.os }}",
steps: [
{ uses: "actions/checkout@v5" },
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: "stable",
components: "rustc,rust-std,cargo",
}
},
] + check_extra_steps + [
# We don't use `--no-default-features` here as integration crates don't
# work with it at all.
{
run: "cargo check --features ${{ matrix.feature }}"
}
]
},
msrv: {
name: "MSRV",
"runs-on": "ubuntu-latest",
steps: [
{
uses: "actions/checkout@v5"
},
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: "nightly",
components: "rustc,rust-std,cargo",
}
},
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: rust_version,
components: "rustc,rust-std,cargo",
}
},
{
run: "../../tools/cargo-update-minimal-versions.sh " + rust_version,
},
{
run: "cargo check" + genFeaturesFlag(features)
},
],
},
test: {
name: "Test",
"runs-on": "ubuntu-latest",
services: test_services,
steps: [
{
uses: "actions/checkout@v5",
},
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: "stable",
components: "rustc,rust-std,cargo",
}
},
{
run: "cargo test" + genFeaturesFlag(test_features),
env: test_env,
},
],
},
[if backend != null then "check-reexported-features"]: {
name: "Check re-exported features",
"runs-on": "ubuntu-latest",
steps: [
{ uses: "actions/checkout@v5" },
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: "stable",
components: "rustc,rust-std,cargo",
}
},
{ uses: "dcarbone/install-jq-action@v3" },
{ uses: "dcarbone/install-yq-action@v1" },
{ run: "../../tools/check-reexported-features.sh" },
]
},
############
# Building #
############
rustdoc: {
name: "Doc",
"runs-on": "ubuntu-latest",
steps: [
{
uses: "actions/checkout@v5",
},
{
uses: "dtolnay/rust-toolchain@v1",
with: {
toolchain: "stable",
components: "rustc,rust-std,cargo",
}
},
{
run: "cargo doc --no-deps" + genFeaturesFlag(features),
}
],
},
}
+ jobs
}