Repository navigation
Expand file tree
/
Copy pathgithub-actions-queue-collector.yml
More file actions
206 lines (190 loc) · 7.61 KB
/
Copy pathgithub-actions-queue-collector.yml
File metadata and controls
206 lines (190 loc) · 7.61 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
name: Collect GitHub Actions queue data
on:
schedule:
- cron: "17 * * * *"
workflow_dispatch:
inputs:
max_windows:
description: Maximum live and backfill windows to collect (1-20).
required: false
default: 20
type: number
permissions: {}
concurrency:
group: github-actions-queue-collector
cancel-in-progress: false
env:
DATA_BRANCH: otelbot/github-actions-queue-data
BACKFILL_START: "2026-09-17T02:00:00Z"
BACKFILL_TARGET: "2026-01-01T00:00:00Z"
jobs:
collect:
if: github.repository == 'open-telemetry/shared-workflows'
runs-on: ubuntu-latest
environment: protected
timeout-minutes: 50
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: List public repositories
id: repositories
env:
GH_TOKEN: ${{ github.token }}
run: |
{
echo 'names<<EOF'
gh api --paginate --method GET /orgs/open-telemetry/repos \
-f type=public -f per_page=100 --jq '.[].name'
echo EOF
} >> "$GITHUB_OUTPUT"
- uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
id: collector-token
with:
client-id: ${{ vars.ACTIONS_TELEMETRY_CLIENT_ID }}
private-key: ${{ secrets.ACTIONS_TELEMETRY_PRIVATE_KEY }}
owner: open-telemetry
repositories: ${{ steps.repositories.outputs.names }}
permission-actions: read
- name: Check out data branch
id: data
env:
DATA_BRANCH_README: .github/scripts/github-actions-queue/DATA_BRANCH_README.md
run: |
set -euo pipefail
data_dir="$RUNNER_TEMP/github-actions-queue-data"
expected_sha=
if git ls-remote --exit-code --heads origin "refs/heads/$DATA_BRANCH" >/dev/null; then
git fetch --no-tags --depth=1 origin "$DATA_BRANCH"
# A head without a snapshot trailer needs its full history so commit-data can reject appended history.
if ! git log -1 --format=%B FETCH_HEAD | grep -q '^Data-snapshot-generation:'; then
git fetch --no-tags --depth=2147483647 origin "$DATA_BRANCH"
fi
git worktree add --detach "$data_dir" FETCH_HEAD
expected_sha=$(git -C "$data_dir" rev-parse HEAD)
else
status=$?
if [[ "$status" != 2 ]]; then
echo "::error::Could not check the data branch"
exit "$status"
fi
git worktree add --detach "$data_dir" HEAD
git -C "$data_dir" switch --orphan "$DATA_BRANCH"
fi
cp "$DATA_BRANCH_README" "$data_dir/README.md"
echo "directory=$data_dir" >> "$GITHUB_OUTPUT"
echo "expected_sha=$expected_sha" >> "$GITHUB_OUTPUT"
- name: Collect completed jobs
id: collect
env:
GH_TOKEN: ${{ steps.collector-token.outputs.token }}
DATA_DIRECTORY: ${{ steps.data.outputs.directory }}
MAX_WINDOWS: ${{ inputs.max_windows }}
run: |
set -euo pipefail
max_windows="${MAX_WINDOWS:-20}"
if (( max_windows < 1 || max_windows > 20 )); then
echo "::error::max_windows must be between 1 and 20"
exit 1
fi
summary=$(
python3 .github/scripts/github-actions-queue/collect.py \
--state "$DATA_DIRECTORY/state.json" \
--backfill-state "$DATA_DIRECTORY/backfill-state.json" \
--backfill-start "$BACKFILL_START" \
--backfill-target "$BACKFILL_TARGET" \
--output-dir "$DATA_DIRECTORY/jobs" \
--collection-id "${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \
--max-windows "$max_windows" \
--max-workers 4 \
--max-requests 12000 \
--max-runtime-seconds 2400
)
echo "$summary" | jq .
{
echo "### GitHub Actions queue collection"
echo
echo '```json'
echo "$summary" | jq .
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
echo "cursor=$(jq -r .cursor <<< "$summary")" >> "$GITHUB_OUTPUT"
echo "paused=$(jq -r .paused <<< "$summary")" >> "$GITHUB_OUTPUT"
echo "pause_reason=$(jq -r .pause_reason <<< "$summary")" >> "$GITHUB_OUTPUT"
echo "pending_run_failures=$(jq -r .pending_run_failures <<< "$summary")" >> "$GITHUB_OUTPUT"
- name: Build queue report
env:
DATA_DIRECTORY: ${{ steps.data.outputs.directory }}
run: |
set -euo pipefail
summary=$(
python3 .github/scripts/github-actions-queue/report.py \
--jobs-dir "$DATA_DIRECTORY/jobs" \
--state "$DATA_DIRECTORY/report-state.json.gz" \
--output-dir "$DATA_DIRECTORY/report-data"
)
echo "$summary" | jq .
{
echo "### GitHub Actions queue report"
echo
echo '```json'
echo "$summary" | jq .
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Commit collected data
env:
CURSOR: ${{ steps.collect.outputs.cursor }}
DATA_DIRECTORY: ${{ steps.data.outputs.directory }}
EXPECTED_SHA: ${{ steps.data.outputs.expected_sha }}
GITHUB_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
git -C "$DATA_DIRECTORY" config user.name "github-actions[bot]"
git -C "$DATA_DIRECTORY" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
python3 .github/scripts/pull-request-dashboard/state_branch.py commit-data \
--state-dir "$DATA_DIRECTORY" \
--state-branch "$DATA_BRANCH" \
--expected-sha "$EXPECTED_SHA" \
--message "Collect queue data through $CURSOR"
- name: Prepare Pages site
id: site
env:
DATA_DIRECTORY: ${{ steps.data.outputs.directory }}
run: |
set -euo pipefail
site_dir="$RUNNER_TEMP/github-actions-queue-site"
dashboard_dir="$site_dir/github-actions-queue"
mkdir -p "$dashboard_dir/data"
cp -R github-actions-queue/dashboard/. "$dashboard_dir/"
cp -R "$DATA_DIRECTORY/report-data/." "$dashboard_dir/data/"
echo "directory=$site_dir" >> "$GITHUB_OUTPUT"
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: ${{ steps.site.outputs.directory }}
- name: Report collection pause
if: steps.collect.outputs.paused == 'true'
env:
PAUSE_REASON: ${{ steps.collect.outputs.pause_reason }}
run: |
echo "::notice::Collection paused at $PAUSE_REASON; the next run will resume from the saved checkpoint"
- name: Report failed run retries
if: steps.collect.outputs.pending_run_failures != '0'
env:
FAILED_RUNS: ${{ steps.collect.outputs.pending_run_failures }}
run: |
echo "::warning::$FAILED_RUNS workflow runs have job API failures recorded in collector state and will be retried"
deploy:
if: github.repository == 'open-telemetry/shared-workflows'
needs: collect
runs-on: ubuntu-latest
permissions:
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
id: deployment