Skip to content

Commit 1deca16

Browse files
0x46616c6bclaude
andcommitted
refactor: extract inline bash into testable scripts with CI pipeline
Extract all inline bash logic from action.yml into separate script files under scripts/, add 64 bats-core tests, shellcheck linting, and a CI workflow. Replace curl-based GitHub Deployment creation with actions/github-script using Octokit for type safety and automatic retry/rate-limiting. Key changes: - Extract tag generation, architecture verification, image retagging, and GitOps update logic into individual scripts - Add shared utility library (logging, retry with backoff, validation) - Deduplicate 4x identical file-update loops into process_file_updates() - Replace manual curl+jq deployment creation with actions/github-script - Improve git push retry: exponential backoff (5 attempts) instead of simple chaining (3 attempts) - Fix shellcheck warnings (SC2206: array=($line) -> read -r) - Add CI pipeline: shellcheck, bats tests, action structure validation All inputs (29), outputs (3), and step IDs remain unchanged. Consumers do not need to modify their workflows. Co-Authored-By: Claude <claude@anthropic.com>
1 parent 2f0c038 commit 1deca16

18 files changed

Lines changed: 1425 additions & 272 deletions

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
shellcheck:
14+
name: Shellcheck
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
20+
- name: Run shellcheck on all scripts
21+
run: find scripts/ -name '*.sh' -exec shellcheck --severity=warning {} +
22+
23+
test:
24+
name: Bash Tests
25+
runs-on: ubuntu-24.04
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
30+
- name: Install bats and helpers
31+
run: |
32+
sudo npm install -g bats
33+
git clone --depth 1 https://github.com/bats-core/bats-support.git tests/test_helper/bats-support
34+
git clone --depth 1 https://github.com/bats-core/bats-assert.git tests/test_helper/bats-assert
35+
36+
- name: Run tests
37+
run: bats tests/*.bats
38+
39+
validate-action:
40+
name: Validate Action Structure
41+
runs-on: ubuntu-24.04
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45+
46+
- name: Verify all referenced scripts exist
47+
run: |
48+
grep -oP 'github\.action_path \}\}/\K[^ "]+' action.yml | while read -r script; do
49+
if [[ ! -f "$script" ]]; then
50+
echo "::error::Script referenced in action.yml does not exist: $script"
51+
exit 1
52+
fi
53+
done
54+
55+
- name: Verify scripts are executable
56+
run: |
57+
find scripts/ -name '*.sh' | while read -r script; do
58+
if [[ ! -x "$script" ]]; then
59+
echo "::error::Script is not executable: $script"
60+
exit 1
61+
fi
62+
done

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# Intellij
22
.idea/*
3+
4+
# Node
5+
node_modules/
6+
package.json
7+
package-lock.json
8+
9+
# Test helper libraries (installed during CI/local setup)
10+
tests/test_helper/bats-support/
11+
tests/test_helper/bats-assert/
12+
13+
# Test artifacts
14+
headers.txt

.shellcheckrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shell=bash
2+
external-sources=true

0 commit comments

Comments
 (0)