Skip to content

Commit bba85c6

Browse files
committed
ci(all-green): print per-upload timing summary
The three uploads run as backgrounded subshells so their log lines interleave, making it impossible to tell which one is slow from the raw log. Wrap each in run_timed to record its own wall-clock time to a shared file, printed as a summary once they've all finished. Generated by Claude Code.
1 parent 59ea729 commit bba85c6

1 file changed

Lines changed: 36 additions & 18 deletions

File tree

.github/workflows/all-green.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,44 @@ jobs:
5353
# independent of each other, and each takes roughly the same few seconds, so they run as
5454
# backgrounded subshells in one step instead of as sequential steps. `wait` on every pid
5555
# collects each exit code so a failure in any of them still fails the step; their log lines
56-
# can interleave, but that's an acceptable trade for running them concurrently.
56+
# can interleave, so each is wrapped in `run_timed` to record its own wall-clock time to a
57+
# shared file instead, printed as an unambiguous summary once they've all finished.
5758
- if: "!cancelled()"
5859
run: |
60+
run_timed () {
61+
local label="$1"; shift
62+
local start=$SECONDS
63+
"$@"
64+
local code=$?
65+
echo "$label: $((SECONDS - start))s" >> "$TIMING_FILE"
66+
return $code
67+
}
68+
69+
upload_to_codecov () {
70+
commit_args=(--sha "$HEAD_SHA" --branch "$HEAD_BRANCH")
71+
upload_args=(--sha "$HEAD_SHA" --dir coverage-upload/lcov -F coverage)
72+
if [ -n "$PR_NUMBER" ]; then
73+
commit_args+=(--pr "$PR_NUMBER")
74+
upload_args+=(--pr "$PR_NUMBER")
75+
fi
76+
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && [ "$BASE_REF" = "master" ]; then
77+
upload_args+=(-F master-coverage)
78+
fi
79+
pip install --quiet codecov-cli
80+
codecovcli create-commit "${commit_args[@]}"
81+
codecovcli create-report --sha "$HEAD_SHA"
82+
codecovcli do-upload "${upload_args[@]}"
83+
}
84+
85+
TIMING_FILE=$(mktemp)
5986
pids=()
6087
61-
datadog-ci junit upload --service dd-trace-js-tests --auto-discovery junit-results &
88+
run_timed "junit upload" datadog-ci junit upload --service dd-trace-js-tests --auto-discovery junit-results &
6289
pids+=($!)
6390
6491
# A single Datadog upload for every cell's coverage, flagged `coverage`.
6592
if [ -d coverage-upload/lcov ]; then
66-
datadog-ci coverage upload coverage-upload/lcov --flags coverage &
93+
run_timed "datadog coverage upload" datadog-ci coverage upload coverage-upload/lcov --flags coverage &
6794
pids+=($!)
6895
fi
6996
@@ -78,28 +105,19 @@ jobs:
78105
# workflows reported coverage for. No token: the repo uploads tokenless (a Codecov token
79106
# would have to be an org secret, which forks can't read).
80107
if [ -d coverage-upload/lcov ]; then
81-
(
82-
commit_args=(--sha "$HEAD_SHA" --branch "$HEAD_BRANCH")
83-
upload_args=(--sha "$HEAD_SHA" --dir coverage-upload/lcov -F coverage)
84-
if [ -n "$PR_NUMBER" ]; then
85-
commit_args+=(--pr "$PR_NUMBER")
86-
upload_args+=(--pr "$PR_NUMBER")
87-
fi
88-
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && [ "$BASE_REF" = "master" ]; then
89-
upload_args+=(-F master-coverage)
90-
fi
91-
pip install --quiet codecov-cli
92-
codecovcli create-commit "${commit_args[@]}"
93-
codecovcli create-report --sha "$HEAD_SHA"
94-
codecovcli do-upload "${upload_args[@]}"
95-
) &
108+
run_timed "codecov upload" upload_to_codecov &
96109
pids+=($!)
97110
fi
98111
99112
exit_code=0
100113
for pid in "${pids[@]}"; do
101114
wait "$pid" || exit_code=1
102115
done
116+
117+
echo "Upload timings:"
118+
cat "$TIMING_FILE"
119+
rm -f "$TIMING_FILE"
120+
103121
exit $exit_code
104122
env:
105123
DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }}

0 commit comments

Comments
 (0)