Commit ebacf96
authored
feat: drop python dependency; make gha-timer opt-out (#62)
* feat: drop python dependency; make gha-timer opt-out
Port src/scripts/git_ungraft.py to a bash equivalent
(src/scripts/git_ungraft.sh) and drop the actions/setup-python step
from action.yml. The composite action now has no interpreter-setup
prerequisites beyond bash itself.
The port uses `git cat-file -p` to discover parent commits, not
shallow-aware commands such as `git show --format=%P` (which returns
an empty parent list for commits listed in .git/shallow — exactly
the subset the ungraft logic needs to re-evaluate). The awk parser
reads only the header block (up to the first blank line), so
commit-message body contents cannot be misparsed as "parent <sha>"
lines.
Add an `enable-timing` input (default: true) that controls whether
fulcrumgenomics/gha-timer is installed. A shared shell wrapper
(src/scripts/gha_timer_wrapper.sh) transparently falls back to
emitting `::group::` / `::endgroup::` workflow commands when
gha-timer is absent, so the action log remains collapsible in the
GH Actions UI for users who opt out.
Add a matrix test case exercising the enable-timing=false path.
* fix: git_fetch_parents was a no-op on shallow-boundary commits; add shellcheck
Extract `git_fetch_parents` from `src/scripts/fetch_through_merge_base.sh`
into its own sourceable helper `src/scripts/git_fetch_parents.sh`, add
a regression test (`tests/test_git_fetch_parents.sh`), and fix the
shallow-aware-parent bug it surfaced.
Before this change the function used `git show --no-patch --format='%P'`
to discover parents. That command (like every other shallow-aware git
porcelain: `git log --pretty=%P`, `git rev-list --parents`, etc.) returns
an EMPTY parent list for commits listed in `.git/shallow` — which is
exactly the subset for which the function is meant to do useful work
(pre-deepen parent fetching on PR merge commits that sit at the shallow
boundary). Consequence: the optimization was a silent no-op whenever
it mattered; the deepen loop masked the miss, so CI stayed green.
The fix reads parent SHAs from the raw commit object via
`git cat-file -p`, parsed by an awk filter that emits only header-block
`parent <sha>` lines (up to the first blank line), so commit-message
body contents cannot be misparsed — preserving the protection added in
e4d95ef for the parent-in-body regression test.
CI changes:
- Add a `shellcheck` job that runs `shellcheck -x --severity=style
--source-path=SCRIPTDIR` on every shell script in the repo. Severity
is the strictest setting; no rules are excluded.
- Add a `shell-tests` matrix job (ubuntu/macos) that runs the new unit
test. The step installs `fulcrumgenomics/gha-timer` and sources
`src/scripts/gha_timer_wrapper.sh` so it dogfoods the action's own
default-on timing path.
Cleanup surfaced by shellcheck:
- Switch `fetch_through_merge_base.sh` shebang from `/bin/sh` to
`/usr/bin/env bash` (the script has always used `[[`, `BASH_SOURCE`,
arrays, etc.).
- Quote variables in `git rev-parse --verify` arguments and in
`bash ${SCRIPT_DIR}/...` invocations.
- Replace `let FAIL_AFTER="FAIL_AFTER-1"` (which trips `set -e` when
the result is zero, hence the surrounding `set +e`/`set -e` dance)
with `FAIL_AFTER=$((FAIL_AFTER - 1))`.
* docs: flesh out enable-timing description in the testing wrapper
Match the convention of the other inputs in .github/actions/testing/
action.yml, which carry the same description as the corresponding
input on the action under test instead of pointing at external docs.
* refactor: apply review feedback
- fetch_through_merge_base.sh: normalize `set -eou pipefail` to the
idiomatic `set -euo pipefail`; fix `Deepend` typo.
- git_ungraft.sh: use `git rev-parse --absolute-git-dir` instead of
the cd/cd/pwd dance so a GIT_DIR pointing outside the work tree is
handled correctly; add an arity check for -C/--git-dir so `set -u`
doesn't produce an unhelpful "$2: unbound variable"; add a comment
noting that the rewrite predicate is equivalent to the Python
original's `set(grafted) != set(remaining)`.
- gha_timer_wrapper.sh: document that the fallback is best-effort
log grouping only — it emits no timing data and silently drops
`gha_timer stop`.
- action.yml (both): quote `default: 'true'` for enable-timing to
make the string contract explicit and document accepted values;
fix a double-space in the description.
* test: add unit tests for git_ungraft.sh and gha_timer_wrapper.sh
test_git_ungraft.sh builds a hermetic shallow clone from a local
bare repo (no network) and asserts:
- No-candidate case leaves .git/shallow untouched (mtime preserved).
- --dry-run prints "Would ungraft <sha>" without rewriting the file.
- Default run rewrites .git/shallow, removing the ungraftable entry.
test_gha_timer_wrapper.sh exercises both branches of the wrapper:
- When gha-timer is on PATH, argv is forwarded verbatim to a shim
binary and no ::group::/::endgroup:: markers are emitted.
- When gha-timer is absent, the fallback emits the expected
::group::/::endgroup:: workflow commands and drops `stop`.
Both tests are picked up by the existing `tests/test_*.sh` loop in
the shell-tests job, so the wrapper fallback is now covered in CI
without needing a separate matrix entry.
* test: pin bare-repo default branch to main in test_git_ungraft
On ubuntu-22.04 runners, `git init --bare` without an explicit
initial-branch flag creates a repo whose HEAD points to `master`.
The test then pushes `main`, so the subsequent shallow clone hits
an unborn HEAD and lands as an empty clone — no `.git/shallow`
file — failing the first assertion. Pass `-b main` to the bare
init so HEAD tracks the branch we actually push.
* test: use inode identity instead of mtime to detect shallow rewrite
The test's case 1 and case 2 want to verify that git_ungraft.sh does
not rewrite `.git/shallow` when there are no candidates (case 1) or
when run with `--dry-run` (case 2). The previous implementation
compared `stat %Y` (seconds-precision mtime) before and after, which
proved flaky on CI: git's shallow-handling appears to touch the file
in place during read-only sub-commands run by the script, leaving
the inode unchanged but bumping mtime into a new second.
Switch to inode identity. The script's rewrite path is a tempfile
+ `mv`, which atomically replaces the file and therefore changes
its inode. The inode check precisely targets that rewrite and
ignores incidental in-place touches by unrelated git machinery.1 parent bad50f4 commit ebacf96
12 files changed
Lines changed: 780 additions & 253 deletions
File tree
- .github
- actions/testing
- workflows
- src/scripts
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
54 | 63 | | |
55 | 64 | | |
56 | 65 | | |
| |||
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
| 91 | + | |
82 | 92 | | |
83 | 93 | | |
84 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 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 | + | |
41 | 84 | | |
42 | 85 | | |
43 | 86 | | |
| |||
115 | 158 | | |
116 | 159 | | |
117 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
59 | 68 | | |
60 | 69 | | |
61 | 70 | | |
| |||
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
90 | 102 | | |
| 103 | + | |
91 | 104 | | |
92 | 105 | | |
93 | 106 | | |
| |||
104 | 117 | | |
105 | 118 | | |
106 | 119 | | |
107 | | - | |
| 120 | + | |
| 121 | + | |
108 | 122 | | |
109 | 123 | | |
110 | 124 | | |
| |||
124 | 138 | | |
125 | 139 | | |
126 | 140 | | |
127 | | - | |
| 141 | + | |
128 | 142 | | |
129 | | - | |
| 143 | + | |
130 | 144 | | |
131 | 145 | | |
132 | 146 | | |
| |||
146 | 160 | | |
147 | 161 | | |
148 | 162 | | |
149 | | - | |
| 163 | + | |
| 164 | + | |
150 | 165 | | |
151 | 166 | | |
152 | | - | |
| 167 | + | |
153 | 168 | | |
154 | | - | |
| 169 | + | |
155 | 170 | | |
156 | 171 | | |
157 | 172 | | |
| |||
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
164 | | - | |
| 179 | + | |
| 180 | + | |
165 | 181 | | |
166 | 182 | | |
167 | 183 | | |
168 | | - | |
169 | | - | |
| 184 | + | |
| 185 | + | |
170 | 186 | | |
171 | 187 | | |
172 | 188 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
15 | | - | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 34 | | |
39 | | - | |
| 35 | + | |
40 | 36 | | |
41 | 37 | | |
42 | | - | |
| 38 | + | |
43 | 39 | | |
44 | 40 | | |
45 | 41 | | |
| |||
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
55 | | - | |
| 51 | + | |
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
59 | 55 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 56 | + | |
63 | 57 | | |
64 | | - | |
| 58 | + | |
65 | 59 | | |
66 | 60 | | |
67 | 61 | | |
68 | 62 | | |
69 | 63 | | |
70 | 64 | | |
71 | 65 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
76 | 70 | | |
77 | 71 | | |
78 | 72 | | |
79 | 73 | | |
80 | 74 | | |
81 | | - | |
| 75 | + | |
82 | 76 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments