GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — actions-test: test the release action with a fake gh, making no releases · openlogix/.github@0eade93

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • actions-test.yaml
  • CLAUDE.md
  • repos-janitor
    • janitor.py
  • tests/publish-pre-release
    • fake-gh
      • gh
    • org
      • README.md
      • repos/openlogix
        • .github/files
          • README.md
        • logix-ide/files/remote-config/logix-ide/001
          • dev.jsonc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/actions-test.yaml‎

Copy file name to clipboardExpand all lines: .github/workflows/actions-test.yaml
+39-69Lines changed: 39 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# the result with what's expected. Expected failures use continue-on-error
33
# plus the assert-step-failed action.
44
#
5-
# This repo has no releases of its own, so test-publish-pre-release tests
6-
# the release action with test releases it creates and deletes.
5+
# This repo has no releases (its type is "no releases"), and the tests make
6+
# none: test-publish-pre-release uses a fake gh that keeps releases in a file.
77

88
name: actions-test
99

@@ -241,47 +241,36 @@ jobs:
241241
echo "Scan outcome correct: $ACTUAL_OUTCOME (expected $EXPECTED_OUTCOME)."
242242
243243
# -- publish-pre-release: the release text, the files, replacing a
244-
# -- same-tag pre-release, protecting a stable one, and the cleanup.
244+
# -- same-tag pre-release, protecting a stable one, and the cleanup. With a
245+
# -- fake gh (tests/publish-pre-release/fake-gh) that keeps the releases in
246+
# -- a JSON file, so the tests make no real releases: this repo has none
247+
# -- (its type is "no releases"). The product repos' daily builds run the
248+
# -- action against GitHub every day, and repos-janitor checks the result.
245249
test-publish-pre-release:
246250
runs-on: ubuntu-latest
247-
# Skipped for pull requests from forks, whose token can't change releases.
248-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
249-
permissions:
250-
contents: write
251-
# One run at a time across all branches, since the cleanup acts on all
252-
# of this repo's pre-releases.
253-
concurrency:
254-
group: test-release-actions
255-
cancel-in-progress: false
256-
timeout-minutes: 15
251+
timeout-minutes: 10
257252
env:
258-
GH_TOKEN: ${{ github.token }}
259-
GH_REPO: ${{ github.repository }}
260-
# All test releases start with "test-". Unique per run.
261-
TAG: test-${{ github.run_id }}-${{ github.run_attempt }}
253+
FAKE_GH_STATE: ${{ github.workspace }}/_fake-releases.json
254+
# The cleanup's referenced tags: a fixture org where logix-ide's
255+
# dev.jsonc names this repo's test release p1.
256+
FAKE_GH_ORG: ${{ github.workspace }}/tests/publish-pre-release/org
257+
GH_TOKEN: unused
262258

263259
steps:
264260
- name: Checkout this repo
265261
uses: actions/checkout@v7
266262

267-
- name: Delete test releases left by earlier runs
268-
run: |
269-
gh release list --limit 1000 --json tagName \
270-
--jq '.[].tagName | select(startswith("test-"))' |
271-
while read -r tag; do
272-
echo "Deleting $tag"
273-
gh release delete "$tag" --yes
274-
gh api -X DELETE "repos/$GH_REPO/git/refs/tags/$tag" 2>/dev/null || true
275-
done
263+
- name: Use the fake gh in the next steps
264+
run: echo "$GITHUB_WORKSPACE/tests/publish-pre-release/fake-gh" >> "$GITHUB_PATH"
276265

277-
- name: Make the files of release A
266+
- name: Make the files of release a
278267
run: |
279-
jq -n --arg t "$TAG-a" --arg c "$GITHUB_SHA" \
280-
'{"package-name": "test", "description": "Test.", "release-tag": $t, "repo-commit": $c}' > BUILD-INFO.json
268+
jq -n --arg c "$GITHUB_SHA" \
269+
'{"package-name": "test", "description": "Test.", "release-tag": "a", "repo-commit": $c}' > BUILD-INFO.json
281270
echo "Asset one" > asset.txt
282271
echo "Our own content, first." > content.md
283272
284-
- name: Publish release A
273+
- name: Publish release a
285274
uses: ./actions/publish-pre-release
286275
with:
287276
title: "Test: A test release."
@@ -291,12 +280,14 @@ jobs:
291280
about-bullets: A repo-specific bullet.
292281
files: asset.txt
293282

294-
- name: Check release A
283+
- name: Check release a
295284
run: |
296285
set -euo pipefail
297-
gh release view "$TAG-a" --json isPrerelease,name,body,assets > release.json
286+
gh release view a --json isPrerelease,name,body,assets,target > release.json
298287
jq -e '.isPrerelease == true' release.json
299288
jq -e '[.assets[].name] | sort == ["BUILD-INFO.json", "SHA256SUMS", "asset.txt"]' release.json
289+
# The tag names the commit that was built.
290+
jq -e --arg c "$GITHUB_SHA" '.target == $c' release.json
300291
jq -r .body release.json > body.md
301292
cat body.md
302293
# The sections, in order.
@@ -308,30 +299,28 @@ jobs:
308299
grep -q "The $PRERELEASE_KEEP newest are kept, and older ones while an Open Logix remote config names them" body.md
309300
grep -q -- "- A repo-specific bullet." body.md
310301
grep -q "$(sha256sum asset.txt | cut -c1-64) asset.txt" body.md
311-
# The tag names the commit that was built.
312-
[ "$(git ls-remote --tags origin "refs/tags/$TAG-a" | cut -f1)" = "$GITHUB_SHA" ]
313302
314303
- name: Change the content
315304
run: echo "Our own content, second." > content.md
316305

317-
- name: Publish release A again, from scratch
306+
- name: Publish release a again, from scratch
318307
uses: ./actions/publish-pre-release
319308
with:
320309
title: "Test: A test release."
321310
content-file: content.md
322311
files: asset.txt
323312

324-
- name: Check release A was replaced
313+
- name: Check release a was replaced
325314
run: |
326-
gh release view "$TAG-a" --json body --jq .body > body.md
315+
gh release view a --json body --jq .body > body.md
327316
grep -q "Our own content, second." body.md
328317
! grep -q "Our own content, first." body.md
329-
[ "$(gh release list --limit 1000 --json tagName --jq "[.[] | select(.tagName == \"$TAG-a\")] | length")" = 1 ]
318+
[ "$(gh release list --json tagName --jq '[.[] | select(.tagName == "a")] | length')" = 1 ]
330319
331-
- name: Make a stable release with tag S
320+
- name: Make a stable release, stable
332321
run: |
333-
gh release create "$TAG-stable" --title "$TAG-stable" --notes "Test" --latest=false
334-
jq --arg t "$TAG-stable" '."release-tag" = $t' BUILD-INFO.json > b.json && mv b.json BUILD-INFO.json
322+
gh release create stable --title stable --notes "Test" --latest=false
323+
jq '."release-tag" = "stable"' BUILD-INFO.json > b.json && mv b.json BUILD-INFO.json
335324
336325
- name: Publish over the stable release
337326
id: over-stable
@@ -348,48 +337,29 @@ jobs:
348337
error-message: "Publishing over a stable release did not fail as expected"
349338

350339
- name: Check the stable release is still stable
351-
run: gh release view "$TAG-stable" --json isPrerelease --jq '.isPrerelease == false' | grep -q true
340+
run: gh release view stable --json isPrerelease --jq '.isPrerelease == false' | grep -q true
352341

353342
# The cleanup keeps the newest pre-releases by the policy (this test
354-
# assumes 5) and leaves stable releases and drafts.
343+
# assumes 5), any a remote config names (p1, in the fixture org), and
344+
# leaves stable releases and drafts.
355345
- name: Make 6 more pre-releases and a draft
356346
run: |
357347
for i in 1 2 3 4 5 6; do
358-
sleep 2
359-
gh release create "$TAG-p$i" --title "$TAG-p$i" --notes "Test" --prerelease
348+
gh release create "p$i" --title "p$i" --notes "Test" --prerelease
360349
done
361-
gh release create "$TAG-draft" --title "$TAG-draft" --notes "Test" --prerelease --draft
362-
sleep 2
363-
jq --arg t "$TAG-b" '."release-tag" = $t' BUILD-INFO.json > b.json && mv b.json BUILD-INFO.json
350+
gh release create draft --title draft --notes "Test" --prerelease --draft
351+
jq '."release-tag" = "b"' BUILD-INFO.json > b.json && mv b.json BUILD-INFO.json
364352
365-
- name: Publish release B, the newest
353+
- name: Publish release b, the newest
366354
uses: ./actions/publish-pre-release
367355
with:
368356
title: "Test: A test release."
369357
files: asset.txt
370358

371359
- name: Check what the cleanup kept
372360
run: |
373-
gh release list --limit 1000 --json tagName \
374-
--jq '[.[].tagName | select(startswith(env.TAG))] | sort | .[]' > actual.txt
375-
printf '%s\n' "$TAG-b" "$TAG-draft" "$TAG-p3" "$TAG-p4" "$TAG-p5" "$TAG-p6" "$TAG-stable" | sort > expected.txt
361+
gh release list --json tagName --jq '[.[].tagName] | sort | .[]' > actual.txt
362+
printf '%s\n' b draft p1 p3 p4 p5 p6 stable | sort > expected.txt
376363
echo "Expected:"; cat expected.txt
377364
echo "Actual:"; cat actual.txt
378365
diff expected.txt actual.txt
379-
for t in a p1 p2; do
380-
if [ -n "$(git ls-remote --tags origin "refs/tags/$TAG-$t")" ]; then
381-
echo "Error: tag $TAG-$t still exists" >&2
382-
exit 1
383-
fi
384-
done
385-
386-
- name: Delete this run's test releases
387-
if: always()
388-
run: |
389-
gh release list --limit 1000 --json tagName \
390-
--jq '.[].tagName | select(startswith(env.TAG))' |
391-
while read -r tag; do
392-
echo "Deleting $tag"
393-
gh release delete "$tag" --yes
394-
gh api -X DELETE "repos/$GH_REPO/git/refs/tags/$tag" 2>/dev/null || true
395-
done
Collapse file

‎CLAUDE.md‎

Copy file name to clipboardExpand all lines: CLAUDE.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Guidance for Claude working in this repo, `openlogix/.github`. It is GitHub's sp
44

55
## What's here
66

7-
**Repo type: no releases** (topic `openlogix-no-releases`; the website repo's `CLAUDE.md`, Repo types, owns the policy). Its action tests make test releases here and delete them; they aren't date-tagged, so they don't count.
7+
**Repo type: no releases** (topic `openlogix-no-releases`; the website repo's `CLAUDE.md`, Repo types, owns the policy). Its tests make no releases (the release tests use a fake `gh`), so it has none.
88

99
- `actions/<name>/action.yaml`: composite GitHub Actions shared by the Open Logix repos' CI and release workflows. [README.md](README.md) lists them.
1010
- `.github/workflows/actions-test.yaml`: tests the actions.
@@ -69,7 +69,7 @@ Action details:
6969

7070
`actions-test.yaml` runs on every push and pull request, manually, and daily at 00:00 UTC. One job per action runs it and compares with expected output. Expected failures (a platform mismatch, an EICAR test file in the virus scan, publishing over a stable release) use `continue-on-error` plus `assert-step-failed`.
7171

72-
This repo has no releases of its own, so `test-publish-pre-release` tests the release action on test releases: the text's structure, the files, a same-tag replacement, stable-release protection and the cleanup. It works only on releases whose tags start with `test-`, runs one at a time, deletes its releases at the end, and deletes leftovers from earlier runs at the start. Add or update a test with every action change.
72+
`test-publish-pre-release` tests the release action without making real releases (the user's decision, 2026-11-12: this repo's type is "no releases"): `tests/publish-pre-release/fake-gh/gh`, a stateful stand-in for `gh` that keeps the releases in a JSON file (`$FAKE_GH_STATE`; `release view`, `create`, `delete` and `list`, with `--json` and `--jq` through the real `jq`; `gh api` goes to the `repos-janitor` fake, on `tests/publish-pre-release/org`, where logix-ide's `dev.jsonc` names the test release `p1`). It checks the text's structure, the files, the target commit, a same-tag replacement, stable-release protection and the cleanup (the newest 5 kept, plus `p1`, which a config names; stable releases and drafts left). The real `gh` calls are exercised every day by the product repos' builds, and `repos-janitor` checks their releases. Add or update a test with every action change.
7373

7474
## Versions
7575

Collapse file

‎repos-janitor/janitor.py‎

Copy file name to clipboardExpand all lines: repos-janitor/janitor.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,14 @@ def __init__(self, info: dict) -> None:
231231

232232
def latest(self) -> str | None:
233233
"""The tag GitHub marks Latest; None without a stable release, or
234-
when it isn't date-tagged (such as a test release actions-test makes
235-
in .github and deletes: not an Open Logix release)."""
234+
when it isn't date-tagged (not an Open Logix release)."""
236235
if self._latest == "unread":
237236
r = api(f"repos/{self.name}/releases/latest")
238237
self._latest = r["tag_name"] if r and DATE_TAG.match(r["tag_name"]) else None
239238
return self._latest
240239

241240
def releases(self) -> list[dict]:
242-
"""Date-tagged releases only: others, such as the test releases
243-
actions-test makes in .github and deletes, aren't Open Logix releases."""
241+
"""Date-tagged releases only: others aren't Open Logix releases."""
244242
if self._releases is None:
245243
self._releases = [r for r in api(f"repos/{self.name}/releases?per_page=100") or []
246244
if not r["draft"] and DATE_TAG.match(r["tag_name"])]
Collapse file

‎tests/publish-pre-release/fake-gh/gh‎

Copy file name to clipboard
+93Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python3
2+
"""A stand-in for the gh CLI in the publish-pre-release tests, so they make
3+
no real releases: the releases live in the JSON file $FAKE_GH_STATE (a list
4+
of {tagName, name, isPrerelease, isDraft, publishedAt, body, target,
5+
assets: [{name, sha256}]}). Answers the release calls the actions make
6+
(view, create, delete, list, with --json and --jq through the real jq), and
7+
passes `gh api` calls to the repos-janitor fake (its fixture org, for the
8+
cleanup's referenced tags)."""
9+
import hashlib, json, os, subprocess, sys
10+
from pathlib import Path
11+
12+
state_file = Path(os.environ["FAKE_GH_STATE"])
13+
args = sys.argv[1:]
14+
15+
16+
def load():
17+
return json.loads(state_file.read_text()) if state_file.is_file() else []
18+
19+
20+
def save(releases):
21+
state_file.write_text(json.dumps(releases, indent=1) + "\n")
22+
23+
24+
def opt(name, default=None):
25+
"""The value of --name VALUE or --name=VALUE."""
26+
for i, a in enumerate(args):
27+
if a == name and i + 1 < len(args):
28+
return args[i + 1]
29+
if a.startswith(name + "="):
30+
return a.split("=", 1)[1]
31+
return default
32+
33+
34+
def output(value):
35+
fields = opt("--json")
36+
if fields:
37+
keys = fields.split(",")
38+
value = [{k: r.get(k) for k in keys} for r in value] if isinstance(value, list) else {k: value.get(k) for k in keys}
39+
text = json.dumps(value)
40+
jq = opt("--jq")
41+
if jq:
42+
text = subprocess.run(["jq", "-r", jq], input=text, capture_output=True, text=True, check=True).stdout
43+
print(text, end="")
44+
else:
45+
print(text)
46+
sys.exit(0)
47+
48+
49+
if args[:1] == ["api"]:
50+
os.execv(str(Path(__file__).resolve().parents[2] / "repos-janitor" / "fake-gh" / "gh"), [sys.argv[0], *args])
51+
52+
if args[:1] != ["release"]:
53+
sys.exit(f"fake gh: unexpected call: {' '.join(args)}")
54+
55+
releases = load()
56+
verb = args[1]
57+
if verb == "view":
58+
r = next((r for r in releases if r["tagName"] == args[2]), None)
59+
if r is None:
60+
print("release not found", file=sys.stderr)
61+
sys.exit(1)
62+
output(r)
63+
if verb == "list":
64+
output(sorted(releases, key=lambda r: r["publishedAt"], reverse=True))
65+
if verb == "delete":
66+
if not any(r["tagName"] == args[2] for r in releases):
67+
sys.exit("release not found")
68+
save([r for r in releases if r["tagName"] != args[2]])
69+
sys.exit(0)
70+
if verb == "create":
71+
tag = args[2]
72+
if any(r["tagName"] == tag for r in releases):
73+
sys.exit(f"a release with the tag {tag} already exists")
74+
# Each create comes after every earlier one, deleted or not.
75+
seq_file = state_file.with_suffix(".seq")
76+
seq = (int(seq_file.read_text()) if seq_file.is_file() else 0) + 1
77+
seq_file.write_text(str(seq))
78+
files, i = [], 3
79+
while i < len(args) and not args[i].startswith("--"):
80+
files.append(args[i])
81+
i += 1
82+
notes = opt("--notes")
83+
if opt("--notes-file"):
84+
notes = Path(opt("--notes-file")).read_text()
85+
releases.append({
86+
"tagName": tag, "name": opt("--title", tag), "body": notes or "",
87+
"isPrerelease": "--prerelease" in args, "isDraft": "--draft" in args,
88+
"publishedAt": f"2026-01-01T00:{seq // 60:02d}:{seq % 60:02d}Z", "seq": seq, "target": opt("--target", "main"),
89+
"assets": [{"name": Path(f).name, "sha256": hashlib.sha256(Path(f).read_bytes()).hexdigest()} for f in files],
90+
})
91+
save(releases)
92+
sys.exit(0)
93+
sys.exit(f"fake gh: unexpected call: {' '.join(args)}")
Collapse file

‎tests/publish-pre-release/org/README.md‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A fixture org for the publish-pre-release tests: logix-ide's dev.jsonc names the
2+
test release p1 of openlogix/.github, so the cleanup must keep it.
Collapse file

‎tests/publish-pre-release/org/repos/openlogix/.github/files/README.md‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# .github
Collapse file

‎tests/publish-pre-release/org/repos/openlogix/logix-ide/files/remote-config/logix-ide/001/dev.jsonc‎

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://www.openlogix.org/schemas/logix-remote-config-v1.json",
3+
"test-thing": {
4+
"repo": "openlogix/.github",
5+
"release": "p1",
6+
"file": "asset.txt"
7+
}
8+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.