Skip to content

Commit 3665c72

Browse files
committed
refactor: move STATUS.md generation to separate scripts
1 parent 73bd6e7 commit 3665c72

File tree

4 files changed

+129
-123
lines changed

4 files changed

+129
-123
lines changed

action.yml

Lines changed: 3 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -226,47 +226,7 @@ runs:
226226
REPO: ${{ github.repository }}
227227
RUN_ID: ${{ github.run_id }}
228228
run: |
229-
echo "Generating STATUS.md for test_fpm..."
230-
badge_line=""
231-
232-
mapfile -t job_lines < <(
233-
curl -s -H "Authorization: token $GH_TOKEN" \
234-
https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/jobs?per_page=100 \
235-
| jq -r '.jobs[] | select((.name | type == "string") and (.name | test(".*_fpm$"))) | [.name, .conclusion] | @tsv'
236-
)
237-
238-
for line in "${job_lines[@]}"; do
239-
name="${line%%$'\t'*}"
240-
conclusion="${line#*$'\t'}"
241-
242-
os="${name%%_*}"
243-
compiler="${name#*_}"
244-
key="${os}_${compiler}"
245-
246-
safe_key="${key//-/'--'}"
247-
248-
if [[ "$conclusion" == "success" ]]; then
249-
color="brightgreen"
250-
label="passing"
251-
elif [[ "$conclusion" == "failure" ]]; then
252-
color="red"
253-
label="failing"
254-
elif [[ "$conclusion" == "cancelled" ]]; then
255-
color="lightgrey"
256-
label="cancelled"
257-
else
258-
color="lightgrey"
259-
label="pending"
260-
fi
261-
262-
badge="![${key}](https://img.shields.io/badge/${safe_key}-${label}-${color})"
263-
badge_line="$badge_line $badge"
264-
done
265-
266-
echo "$badge_line" > STATUS.md
267-
mkdir -p status-fpm
268-
mv STATUS.md status-fpm/STATUS.md
269-
cat status-fpm/STATUS.md
229+
bash "${{ github.action_path }}/scripts/generate-status-fpm.sh"
270230
271231
- name: Deploy STATUS.md (test_fpm)
272232
if: ${{ inputs.generate-status-fpm == 'true' }}
@@ -285,47 +245,7 @@ runs:
285245
REPO: ${{ github.repository }}
286246
RUN_ID: ${{ github.run_id }}
287247
run: |
288-
echo "Generating STATUS.md for test_cmake..."
289-
badge_line=""
290-
291-
mapfile -t job_lines < <(
292-
curl -s -H "Authorization: token $GH_TOKEN" \
293-
https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/jobs?per_page=100 \
294-
| jq -r '.jobs[] | select((.name | type == "string") and (.name | test(".*_cmake$"))) | [.name, .conclusion] | @tsv'
295-
)
296-
297-
for line in "${job_lines[@]}"; do
298-
name="${line%%$'\t'*}"
299-
conclusion="${line#*$'\t'}"
300-
301-
os="${name%%_*}"
302-
compiler="${name#*_}"
303-
key="${os}_${compiler}"
304-
305-
safe_key="${key//-/'--'}"
306-
307-
if [[ "$conclusion" == "success" ]]; then
308-
color="brightgreen"
309-
label="passing"
310-
elif [[ "$conclusion" == "failure" ]]; then
311-
color="red"
312-
label="failing"
313-
elif [[ "$conclusion" == "cancelled" ]]; then
314-
color="lightgrey"
315-
label="cancelled"
316-
else
317-
color="lightgrey"
318-
label="pending"
319-
fi
320-
321-
badge="![${key}](https://img.shields.io/badge/${safe_key}-${label}-${color})"
322-
badge_line="$badge_line $badge"
323-
done
324-
325-
echo "$badge_line" > STATUS.md
326-
mkdir -p status-cmake
327-
mv STATUS.md status-cmake/STATUS.md
328-
cat status-cmake/STATUS.md
248+
bash "${{ github.action_path }}/scripts/generate-status-cmake.sh"
329249
330250
- name: Deploy STATUS.md (test_cmake)
331251
if: ${{ inputs.generate-status-cmake == 'true' }}
@@ -344,47 +264,7 @@ runs:
344264
REPO: ${{ github.repository }}
345265
RUN_ID: ${{ github.run_id }}
346266
run: |
347-
echo "Generating STATUS.md for test_meson..."
348-
badge_line=""
349-
350-
mapfile -t job_lines < <(
351-
curl -s -H "Authorization: token $GH_TOKEN" \
352-
https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/jobs?per_page=100 \
353-
| jq -r '.jobs[] | select((.name | type == "string") and (.name | test(".*_meson$"))) | [.name, .conclusion] | @tsv'
354-
)
355-
356-
for line in "${job_lines[@]}"; do
357-
name="${line%%$'\t'*}"
358-
conclusion="${line#*$'\t'}"
359-
360-
os="${name%%_*}"
361-
compiler="${name#*_}"
362-
key="${os}_${compiler}"
363-
364-
safe_key="${key//-/'--'}"
365-
366-
if [[ "$conclusion" == "success" ]]; then
367-
color="brightgreen"
368-
label="passing"
369-
elif [[ "$conclusion" == "failure" ]]; then
370-
color="red"
371-
label="failing"
372-
elif [[ "$conclusion" == "cancelled" ]]; then
373-
color="lightgrey"
374-
label="cancelled"
375-
else
376-
color="lightgrey"
377-
label="pending"
378-
fi
379-
380-
badge="![${key}](https://img.shields.io/badge/${safe_key}-${label}-${color})"
381-
badge_line="$badge_line $badge"
382-
done
383-
384-
echo "$badge_line" > STATUS.md
385-
mkdir -p status-meson
386-
mv STATUS.md status-meson/STATUS.md
387-
cat status-meson/STATUS.md
267+
bash "${{ github.action_path }}/scripts/generate-status-meson.sh"
388268
389269
- name: Deploy STATUS.md (test_meson)
390270
if: ${{ inputs.generate-status-meson == 'true' }}

scripts/generate-status-cmake.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
echo "Generating STATUS.md for test_cmake..."
3+
badge_line=""
4+
5+
mapfile -t job_lines < <(
6+
curl -s -H "Authorization: token $GH_TOKEN" \
7+
https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/jobs?per_page=100 \
8+
| jq -r '.jobs[] | select((.name | type == "string") and (.name | test(".*_cmake$"))) | [.name, .conclusion] | @tsv'
9+
)
10+
11+
for line in "${job_lines[@]}"; do
12+
name="${line%%$'\t'*}"
13+
conclusion="${line#*$'\t'}"
14+
15+
os="${name%%_*}"
16+
compiler="${name#*_}"
17+
key="${os}_${compiler}"
18+
19+
safe_key="${key//-/'--'}"
20+
21+
if [[ "$conclusion" == "success" ]]; then
22+
color="brightgreen"
23+
label="passing"
24+
elif [[ "$conclusion" == "failure" ]]; then
25+
color="red"
26+
label="failing"
27+
elif [[ "$conclusion" == "cancelled" ]]; then
28+
color="lightgrey"
29+
label="cancelled"
30+
else
31+
color="lightgrey"
32+
label="pending"
33+
fi
34+
35+
badge="![${key}](https://img.shields.io/badge/${safe_key}-${label}-${color})"
36+
badge_line="$badge_line $badge"
37+
done
38+
39+
echo "$badge_line" > STATUS.md
40+
mkdir -p status-cmake
41+
mv STATUS.md status-cmake/STATUS.md
42+
cat status-cmake/STATUS.md

scripts/generate-status-fpm.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
echo "Generating STATUS.md for test_fpm..."
3+
badge_line=""
4+
5+
mapfile -t job_lines < <(
6+
curl -s -H "Authorization: token $GH_TOKEN" \
7+
https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/jobs?per_page=100 \
8+
| jq -r '.jobs[] | select((.name | type == "string") and (.name | test(".*_fpm$"))) | [.name, .conclusion] | @tsv'
9+
)
10+
11+
for line in "${job_lines[@]}"; do
12+
name="${line%%$'\t'*}"
13+
conclusion="${line#*$'\t'}"
14+
15+
os="${name%%_*}"
16+
compiler="${name#*_}"
17+
key="${os}_${compiler}"
18+
19+
safe_key="${key//-/'--'}"
20+
21+
if [[ "$conclusion" == "success" ]]; then
22+
color="brightgreen"
23+
label="passing"
24+
elif [[ "$conclusion" == "failure" ]]; then
25+
color="red"
26+
label="failing"
27+
elif [[ "$conclusion" == "cancelled" ]]; then
28+
color="lightgrey"
29+
label="cancelled"
30+
else
31+
color="lightgrey"
32+
label="pending"
33+
fi
34+
35+
badge="![${key}](https://img.shields.io/badge/${safe_key}-${label}-${color})"
36+
badge_line="$badge_line $badge"
37+
done
38+
39+
echo "$badge_line" > STATUS.md
40+
mkdir -p status-fpm
41+
mv STATUS.md status-fpm/STATUS.md
42+
cat status-fpm/STATUS.md

scripts/generate-status-meson.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
echo "Generating STATUS.md for test_meson..."
3+
badge_line=""
4+
5+
mapfile -t job_lines < <(
6+
curl -s -H "Authorization: token $GH_TOKEN" \
7+
https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/jobs?per_page=100 \
8+
| jq -r '.jobs[] | select((.name | type == "string") and (.name | test(".*_meson$"))) | [.name, .conclusion] | @tsv'
9+
)
10+
11+
for line in "${job_lines[@]}"; do
12+
name="${line%%$'\t'*}"
13+
conclusion="${line#*$'\t'}"
14+
15+
os="${name%%_*}"
16+
compiler="${name#*_}"
17+
key="${os}_${compiler}"
18+
19+
safe_key="${key//-/'--'}"
20+
21+
if [[ "$conclusion" == "success" ]]; then
22+
color="brightgreen"
23+
label="passing"
24+
elif [[ "$conclusion" == "failure" ]]; then
25+
color="red"
26+
label="failing"
27+
elif [[ "$conclusion" == "cancelled" ]]; then
28+
color="lightgrey"
29+
label="cancelled"
30+
else
31+
color="lightgrey"
32+
label="pending"
33+
fi
34+
35+
badge="![${key}](https://img.shields.io/badge/${safe_key}-${label}-${color})"
36+
badge_line="$badge_line $badge"
37+
done
38+
39+
echo "$badge_line" > STATUS.md
40+
mkdir -p status-meson
41+
mv STATUS.md status-meson/STATUS.md
42+
cat status-meson/STATUS.md

0 commit comments

Comments
 (0)