Skip to content

Commit 3ec95ed

Browse files
bors[bot]MikailBag
andauthored
Merge #8
8: svaluer: Finish tracing migration r=MikailBag a=MikailBag Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
2 parents f1992eb + ec307d8 commit 3ec95ed

11 files changed

Lines changed: 66 additions & 102 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
- name: Execute tests
5959
run: bash ci/e2e-run.sh
6060
- name: Upload logs
61+
if: always()
6162
uses: actions/upload-artifact@v2
6263
with:
6364
name: e2e-logs
@@ -129,13 +130,13 @@ jobs:
129130
name: Fetch prebuilt cargo-udeps
130131
uses: actions/cache@v2
131132
with:
132-
key: udeps-bin-${{ runner.os }}-v0.1.20
133+
key: udeps-bin-${{ runner.os }}-v0.1.21
133134
path: ~/udeps
134135
- name: Install cargo-udeps
135136
if: steps.cache_udeps.outputs.cache-hit != 'true'
136137
run: |2-
137138
138-
cargo install cargo-udeps --locked --version 0.1.20
139+
cargo install cargo-udeps --locked --version 0.1.21
139140
mkdir -p ~/udeps
140141
cp $( which cargo-udeps ) ~/udeps
141142
- name: Run cargo-udeps

.github/workflows/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install golang
1818
uses: actions/setup-go@v2
1919
with:
20-
go-version: 1.16.3
20+
go-version: 1.16.4
2121
- name: Fetch generator sources
2222
run: git clone https://github.com/jjs-dev/ci-config-gen ./gen
2323
- name: Install ci-config-gen

Cargo.lock

Lines changed: 5 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bors.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
delete-merged-branches = true
2-
status = ["check-ci-config", "e2e-build", "e2e-run", "rustfmt", "rust-unit-tests", "rust-unused-deps", "rust-cargo-deny", "rust-lint", "cpp-lint"]
2+
status = ["check-ci-config", "e2e-build", "e2e-run", "rustfmt", "rust-unit-tests", "rust-unused-deps", "rust-cargo-deny", "rust-lint", "cpp-lint", "publish"]
33
timeout-sec = 900

ci/publish-images.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ then
77
elif [ "$GITHUB_REF" = "refs/heads/trying" ]
88
then
99
TAG="dev"
10+
elif [ "$GITHUB_REF" = "refs/heads/staging" ]
11+
then
12+
exit 0
1013
else
1114
echo "unknown GITHUB_REF: $GITHUB_REF"
1215
exit 1

svaluer/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ crossbeam-channel = "0.5.1"
1212
serde_json = "1.0.64"
1313
serde = "1.0.125"
1414
serde_yaml = "0.8.17"
15-
log = "0.4.14"
1615
either = "1.6.1"
1716
tracing-subscriber = "0.2.17"
18-
19-
[dev-dependencies]
20-
simple_logger = "1.11.0"
17+
tracing = "0.1.26"

svaluer/src/fiber.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ mod group;
22

33
use crate::cfg::Config;
44
use group::Group;
5-
use log::{debug, info};
65
use pom::TestId;
76
use std::{collections::HashSet, num::NonZeroU32};
87
use valuer_api::{
@@ -138,7 +137,7 @@ impl Fiber {
138137
}
139138

140139
fn emit_judgelog(&mut self) -> FiberReply {
141-
debug!("Emitting {:?} judge log", self.kind);
140+
tracing::info!("Emitting {:?} judge log", self.kind);
142141
let is_full = self.groups.iter().all(|g| g.is_passed());
143142
let mut judge_log = JudgeLog {
144143
kind: self.kind,
@@ -148,7 +147,7 @@ impl Fiber {
148147
score: 0,
149148
};
150149
for (i, g) in self.groups.iter().enumerate() {
151-
debug!("extending judge log with group {}", i);
150+
tracing::debug!("extending judge log with group {}", i);
152151
g.update_judge_log(&mut judge_log);
153152
}
154153

@@ -159,10 +158,10 @@ impl Fiber {
159158
for &i in &self.active_groups {
160159
let g = &mut self.groups[i];
161160
if let reply @ Some(_) = g.pop_test() {
162-
debug!("group {} returned {}", i, reply.unwrap());
161+
tracing::debug!("group {} returned {}", i, reply.unwrap());
163162
return reply;
164163
}
165-
debug!("group {} is not ready to run yet", i);
164+
tracing::debug!("group {} is not ready to run yet", i);
166165
}
167166
None
168167
}
@@ -180,17 +179,18 @@ impl Fiber {
180179
}
181180

182181
pub(crate) fn poll(&mut self) -> FiberReply {
183-
debug!("Fiber {:?}: poll iteration", self.kind);
182+
tracing::debug!("Fiber {:?}: poll iteration", self.kind);
184183
if self.finished {
185-
debug!("Returning none: already finished");
184+
tracing::debug!("Returning none: already finished");
186185
return FiberReply::None;
187186
}
188187
let cur_live_score = self.current_score();
189-
debug!("live score: {}", cur_live_score);
188+
tracing::debug!("live score: {}", cur_live_score);
190189
if cur_live_score != self.last_live_score {
191-
info!(
190+
tracing::debug!(
192191
"live score updated: old={}, cur={}",
193-
self.last_live_score, cur_live_score
192+
self.last_live_score,
193+
cur_live_score
194194
);
195195
self.last_live_score = cur_live_score;
196196
return FiberReply::LiveScore {
@@ -203,20 +203,20 @@ impl Fiber {
203203
let is_passed = g.is_passed();
204204
let is_failed = g.is_failed();
205205
if is_passed || is_failed {
206-
info!("group {} is finished", i);
206+
tracing::debug!("group {} is finished", i);
207207
} else {
208208
new_active_groups.push(i);
209209
}
210210
assert!(!(is_passed && is_failed));
211211
if g.is_passed() {
212-
debug!("group {} is passed", i);
212+
tracing::debug!("group {} is passed", i);
213213
for group in &mut self.groups {
214214
group.on_group_pass(i as u32);
215215
}
216216
} else if g.is_failed() {
217217
let mut queue = vec![i as u32];
218218
while let Some(k) = queue.pop() {
219-
debug!("group {} is failed", k);
219+
tracing::debug!("group {} is failed", k);
220220
for (j, group) in self.groups.iter_mut().enumerate() {
221221
if !group.is_waiting() {
222222
continue;
@@ -231,10 +231,10 @@ impl Fiber {
231231
}
232232
self.active_groups = new_active_groups;
233233
if let Some(test_id) = self.poll_groups_for_tests() {
234-
debug!("got test from groups: {}", test_id);
234+
tracing::debug!("got test from groups: {}", test_id);
235235
FiberReply::Test { test_id }
236236
} else if self.running_tests() == 0 {
237-
debug!(
237+
tracing::debug!(
238238
"this fiber is finished, emitting judge log of kind {:?}",
239239
self.kind
240240
);
@@ -248,7 +248,7 @@ impl Fiber {
248248
.flatten()
249249
.next()
250250
.expect("unreachable: running_tests() > 0, but no test found");
251-
debug!(
251+
tracing::debug!(
252252
"no updates yet, waiting for running tests, incl. {:?}",
253253
running_test
254254
);
@@ -259,9 +259,9 @@ impl Fiber {
259259
}
260260

261261
fn add_test(&mut self, test: TestId, status: &Status) {
262-
debug!("processing status {:?} for test {}", status, test);
262+
tracing::debug!("processing status {:?} for test {}", status, test);
263263
if !self.visible_tests.contains(&test) {
264-
debug!("skipping: test is not visible");
264+
tracing::debug!("skipping: test is not visible");
265265
return;
266266
}
267267
for g in &mut self.groups {
@@ -289,7 +289,7 @@ mod tests {
289289
}
290290
#[test]
291291
fn simple() {
292-
simple_logger::SimpleLogger::new().init().ok();
292+
crate::setup_log();
293293
let mut f = make_fiber(
294294
"
295295
groups:

svaluer/src/fiber/group.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use either::{Left, Right};
2-
use log::debug;
32
use pom::TestId;
43
use std::collections::BTreeSet;
54
use valuer_api::{
@@ -180,7 +179,7 @@ impl Group {
180179
_ => return,
181180
};
182181
if state.deps.remove(&other_group_id) {
183-
debug!("group {:?}: dep {} passed", self.id, other_group_id);
182+
tracing::debug!("group {:?}: dep {} passed", self.id, other_group_id);
184183
self.maybe_stop_waiting();
185184
}
186185
}
@@ -194,39 +193,39 @@ impl Group {
194193
// that group was not required, so we ignore this failure
195194
return;
196195
}
197-
debug!("group {:?}: dep {} failed", self.id, other_group_id);
196+
tracing::debug!("group {:?}: dep {} failed", self.id, other_group_id);
198197
self.state = State::Skipped(SkippedState {
199198
failed_dep: other_group_id,
200199
});
201200
}
202201

203202
/// Returns next test from this group that can be executed
204203
pub(crate) fn pop_test(&mut self) -> Option<TestId> {
205-
debug!("Group {:?}: searching for test", self.id);
204+
tracing::debug!("Group {:?}: searching for test", self.id);
206205
// we can't run if some deps are running or failed
207206
let state = match &mut self.state {
208207
State::Building => unreachable!(),
209208
State::Finished(_) | State::Skipped(_) => {
210-
debug!("Returning None: group has been done");
209+
tracing::debug!("Returning None: group has been done");
211210
return None;
212211
}
213212
State::Waiting(_) => {
214-
debug!("Returning None: some deps still not finished");
213+
tracing::debug!("Returning None: some deps still not finished");
215214
return None;
216215
}
217216
State::Running(state) => state,
218217
};
219218
if !state.running_tests.is_empty() && !self.run_all_tests {
220-
debug!("Returning None: run_all_tests=false, and a test is already running");
219+
tracing::debug!("Returning None: run_all_tests=false, and a test is already running");
221220
return None;
222221
}
223222
if let Some(t) = state.queued_tests.iter().next().copied() {
224-
debug!("found test: {}", t);
223+
tracing::debug!("found test: {}", t);
225224
state.queued_tests.remove(&t);
226225
state.running_tests.insert(t);
227226
Some(t)
228227
} else {
229-
debug!("Queue is empty");
228+
tracing::debug!("Queue is empty");
230229
None
231230
}
232231
}
@@ -243,7 +242,7 @@ impl Group {
243242
let must_run_all_tests = self.run_all_tests;
244243
let state = self.running_state();
245244
if state.failed_tests.is_empty() {
246-
debug!("group {:?} is now failed", id);
245+
tracing::debug!("group {:?} is now failed", id);
247246
}
248247
state.failed_tests.insert((test_id, status));
249248
if !must_run_all_tests {
@@ -281,7 +280,7 @@ impl Group {
281280
if !state.running_tests.remove(&test_id) {
282281
return;
283282
}
284-
debug!(
283+
tracing::debug!(
285284
"got test result: test={}, status={:?}",
286285
test_id.get(),
287286
status
@@ -340,7 +339,7 @@ mod tests {
340339
use valuer_api::StatusKind;
341340
#[test]
342341
fn simple() {
343-
simple_logger::SimpleLogger::new().init().ok();
342+
crate::setup_log();
344343
let st = || Status {
345344
kind: StatusKind::Accepted,
346345
code: "MOCK_OK".to_string(),

0 commit comments

Comments
 (0)