Skip to content

Commit 5396a12

Browse files
Copilotphlax
andauthored
Fix publish pipeline: fail loudly for non-dev releases, add workflow_dispatch, improve status table
Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
1 parent 8c9772d commit 5396a12

16 files changed

Lines changed: 397 additions & 1 deletion

File tree

.github/workflows/actions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
pull_request:
8+
workflow_dispatch:
89

910
permissions:
1011
contents: read

.github/workflows/bazel.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
push:
99
branches:
1010
- main
11+
workflow_dispatch:
1112

1213
concurrency:
1314
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches:
99
- main
10+
workflow_dispatch:
1011

1112
permissions:
1213
contents: read

.github/workflows/py.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches:
99
- "main"
10+
workflow_dispatch:
1011

1112
permissions:
1213
contents: read

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches:
99
- main
10+
workflow_dispatch:
1011

1112
permissions:
1213
contents: read
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
uses: ./actions/github/afterall
2+
id: afterall
3+
with:
4+
sha: abc1234
5+
repo: owner/repo
6+
workflows: |
7+
Workflow A
8+
Workflow B
9+
10+
before:
11+
- shell: bash
12+
run: |
13+
cat > "${ACTION_TEST_PATH}/mock_runs.json" <<'EOF'
14+
{
15+
"workflow_runs": [
16+
{"name": "Workflow A", "id": 1, "status": "completed",
17+
"conclusion": "success", "created_at": "2024-01-01T00:00:00Z"},
18+
{"name": "Workflow B", "id": 2, "status": "completed",
19+
"conclusion": "success", "created_at": "2024-01-01T00:00:00Z"}
20+
]
21+
}
22+
EOF
23+
24+
after:
25+
- shell: bash
26+
run: |
27+
. "${ACTION_TEST_PATH}/test_fun.sh"
28+
OUTPUT='%{{ steps.afterall.outputs.status }}'
29+
test_continue "$OUTPUT" "true"
30+
test_status_has "$OUTPUT" "Workflow A" "conclusion" "success"
31+
test_status_has "$OUTPUT" "Workflow B" "conclusion" "success"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
uses: ./actions/github/afterall
2+
id: afterall
3+
with:
4+
sha: abc1234
5+
repo: owner/repo
6+
workflows: |
7+
Workflow A
8+
Workflow B
9+
10+
before:
11+
- shell: bash
12+
run: |
13+
cat > "${ACTION_TEST_PATH}/mock_runs.json" <<'EOF'
14+
{
15+
"workflow_runs": [
16+
{"name": "Workflow A", "id": 1, "status": "completed",
17+
"conclusion": "success", "created_at": "2024-01-01T00:00:00Z"},
18+
{"name": "Workflow B", "id": 2, "status": "completed",
19+
"conclusion": "failure", "created_at": "2024-01-01T00:00:00Z"}
20+
]
21+
}
22+
EOF
23+
24+
after:
25+
- shell: bash
26+
run: |
27+
. "${ACTION_TEST_PATH}/test_fun.sh"
28+
OUTPUT='%{{ steps.afterall.outputs.status }}'
29+
test_continue "$OUTPUT" "false"
30+
test_status_has "$OUTPUT" "Workflow A" "conclusion" "success"
31+
test_status_has "$OUTPUT" "Workflow B" "conclusion" "failure"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
uses: ./actions/github/afterall
2+
id: afterall
3+
with:
4+
sha: abc1234
5+
repo: owner/repo
6+
workflows: |
7+
Workflow A
8+
Workflow B
9+
10+
before:
11+
- shell: bash
12+
run: |
13+
cat > "${ACTION_TEST_PATH}/mock_runs.json" <<'EOF'
14+
{
15+
"workflow_runs": [
16+
{"name": "Workflow A", "id": 1, "status": "completed",
17+
"conclusion": "success", "created_at": "2024-01-01T00:00:00Z"},
18+
{"name": "Workflow B", "id": 2, "status": "in_progress",
19+
"conclusion": null, "created_at": "2024-01-01T00:00:00Z"}
20+
]
21+
}
22+
EOF
23+
24+
after:
25+
- shell: bash
26+
run: |
27+
. "${ACTION_TEST_PATH}/test_fun.sh"
28+
OUTPUT='%{{ steps.afterall.outputs.status }}'
29+
test_continue "$OUTPUT" "false"
30+
test_status_has "$OUTPUT" "Workflow A" "conclusion" "success"
31+
test_status_has "$OUTPUT" "Workflow B" "status" "in_progress"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
uses: ./actions/github/afterall
2+
id: afterall
3+
with:
4+
sha: abc1234
5+
repo: owner/repo
6+
workflows: |
7+
Workflow A
8+
Workflow B
9+
10+
before:
11+
- shell: bash
12+
run: |
13+
cat > "${ACTION_TEST_PATH}/mock_runs.json" <<'EOF'
14+
{
15+
"workflow_runs": [
16+
{"name": "Workflow A", "id": 1, "status": "completed",
17+
"conclusion": "success", "created_at": "2024-01-01T00:00:00Z"}
18+
]
19+
}
20+
EOF
21+
22+
after:
23+
- shell: bash
24+
run: |
25+
. "${ACTION_TEST_PATH}/test_fun.sh"
26+
OUTPUT='%{{ steps.afterall.outputs.status }}'
27+
test_continue "$OUTPUT" "false"
28+
test_status_has "$OUTPUT" "Workflow A" "conclusion" "success"
29+
test_status_missing "$OUTPUT" "Workflow B"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
# Mock gh command for testing github/afterall action
4+
# Returns configured mock workflow run data for API calls
5+
6+
set -e
7+
8+
MOCK_LOG="${MOCK_LOG:-/tmp/gh-mock.log}"
9+
MOCK_RUNS="${ACTION_TEST_PATH}/mock_runs.json"
10+
11+
print_cmd() {
12+
local arg
13+
for arg in "$@"; do
14+
if [[ "$arg" =~ [[:space:]] ]]; then
15+
printf '"%s" ' "$arg"
16+
else
17+
printf '%s ' "$arg"
18+
fi
19+
done | sed 's/ $//'
20+
echo
21+
}
22+
23+
print_cmd gh "$@" >> "$MOCK_LOG"
24+
25+
command="$1"
26+
case "$command" in
27+
api)
28+
shift
29+
JQ_FILTER=""
30+
while [[ $# -gt 0 ]]; do
31+
case "$1" in
32+
--jq) JQ_FILTER="$2"; shift 2 ;;
33+
*) shift ;;
34+
esac
35+
done
36+
if [[ -n "$JQ_FILTER" ]]; then
37+
jq -c "$JQ_FILTER" "$MOCK_RUNS"
38+
else
39+
cat "$MOCK_RUNS"
40+
fi
41+
;;
42+
workflow)
43+
# Swallow workflow dispatch calls silently in tests
44+
exit 0
45+
;;
46+
*)
47+
echo "Unknown gh command: $command" >&2
48+
exit 1
49+
;;
50+
esac

0 commit comments

Comments
 (0)