/
flakeup-logs
executable file
·57 lines (51 loc) · 1.64 KB
/
flakeup-logs
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
#!/usr/bin/env fish
# Retrieve the logs of the last CI run against the flake update branch.
# Useful for quickly seeing what packages in each system's closure were updated.
set _dir (dirname (status filename))
source $_dir/_lib.fish
log_step "Contacting Cirrus CI..."
set cirrus_json \
(curlie --silent POST \
"https://api.cirrus-ci.com/graphql" \
query='{
ownerRepository(owner: "i077", name: "system", platform: "github") {
builds(last: 1, branch: "update_flake_lock_action") {
edges {
node {
id
status
changeIdInRepo
tasks { name status commandLogsTail(name: "print_diff") }
}
}
}
}
}' | jq .data.ownerRepository.builds.edges[0].node)
set cirrus_status (echo $cirrus_json | jq -r .status)
if test -n "$cirrus_status"; and test $cirrus_status != COMPLETED
log_warn "Build status is currently '$cirrus_status'."
log_warn "See https://cirrus-ci.com/build/"(echo $cirrus_json | jq -r .id)" for build logs."
if not ask_yesno "Continue?"
exit 0
end
end
set ci_lines (echo $cirrus_json | jq -r .tasks[].commandLogsTail[]\?)
# Only capture output between nvd delimiters
set IS_DIFF 0
for line in $ci_lines
if string match -q "===== *" $line
set IS_DIFF 1
set -a difflines "" ""
else if string match -q "=====" $line
set IS_DIFF 0
end
if test "$IS_DIFF" -gt 0
if string match -q "===== *" $line
set -a difflines $bold$line$resf
else
set -a difflines $line
end
end
tput sgr0
end
string join \n $difflines | less -FR