mirror of
https://github.com/storytold/craft-common-actions.git
synced 2026-11-26 20:45:11 +01:00
nightly: exact-case stable ref check; Windows exe name bound includes .exe (CodeRabbit)
- release.yml: the refusal step runs on every real run and compares GITHUB_REF to refs/heads/release in the shell, because expression == ignores case (refs/heads/Release slipped past). Every job that binds the release environment needs version directly and runs only if it succeeded, so a failed check keeps all six away from the keys; a test pins that. - nightly_app: the Windows binary name, .exe included, is at most 128 characters (windows_unpack's member bound).
This commit is contained in:
1 parent
2eef4e01a8
commit
96c61f69f1
4 files changed
+36
-6
No files matched your search
@@ -225,12 +225,15 @@ jobs:
|
||||
# nightly signer's branch). A stable build binds it only on refs/heads/release (see each job's
|
||||
# `environment:`), and a real (non-dry) stable run anywhere else stops here, before any build.
|
||||
- name: Stable releases run only on refs/heads/release
|
||||
if: ${{ !inputs.dry-run && github.ref != 'refs/heads/release' }}
|
||||
# Expression `==` ignores case, so the exact ref check is done in the shell, for every real run.
|
||||
if: ${{ !inputs.dry-run }}
|
||||
env:
|
||||
REF: ${{ github.ref }}
|
||||
run: |
|
||||
echo "::error::stable releases run only on refs/heads/release, not $REF; use dry-run elsewhere"
|
||||
exit 1
|
||||
if [ "$REF" != "refs/heads/release" ]; then
|
||||
echo "::error::stable releases run only on refs/heads/release, not $REF; use dry-run elsewhere"
|
||||
exit 1
|
||||
fi
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
@@ -40,7 +40,8 @@ PLATFORMS = {"linux-x86_64": ("linux", "x86_64"), "macos-aarch64": ("macos", "aa
|
||||
EXTENSIONS = {"linux-x86_64": ".tar.gz", "macos-aarch64": ".zip", "windows-x86_64": ".zip"}
|
||||
# The only target format each release-ref plug-in signs (nightly_release_platforms / nightly_release_linux).
|
||||
FORMATS = {"linux-x86_64": "tar_gz", "macos-aarch64": "portable_zip", "windows-x86_64": "portable_zip"}
|
||||
WINDOWS_EXE = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]{0,127}[.]exe")
|
||||
# The whole ZIP member name, ".exe" included, must fit windows_unpack's 128-character limit.
|
||||
WINDOWS_EXE = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]{0,123}[.]exe")
|
||||
CHANNEL = "nightly-v1"
|
||||
|
||||
|
||||
|
||||
@@ -505,6 +505,10 @@ class SecondAppTests(unittest.TestCase):
|
||||
# 7: Windows signs only a flat exe.
|
||||
refused(set_entry(win, 'bin/designcraft.exe', 'bin/designcraft.exe'), 'nested windows exe')
|
||||
refused(set_entry(win, 'designcraft', 'designcraft'), 'windows without .exe')
|
||||
# The whole member name, .exe included, fits windows_unpack's 128 characters.
|
||||
refused(set_entry(win, 'a' * 125 + '.exe', 'a' * 125 + '.exe'), '129-character exe')
|
||||
registry = second_app_registry(); registry['apps']['designcraft']['entrypoints'][win] = {'entrypoint': 'a' * 124 + '.exe', 'binary': 'a' * 124 + '.exe'}
|
||||
self.assertTrue(names_tool.admit('designcraft', 'storytold/designcraft', 'refs/heads/main', registry)[0], '128-character exe')
|
||||
# Valid shapes still pass.
|
||||
for label, mutate in (('sibling GUI', set_entry(lin, 'bin/start', 'bin/start-bin')),
|
||||
('libexec GUI', set_entry(lin, 'bin/start', 'bin/libexec/gui'))):
|
||||
|
||||
@@ -62,8 +62,15 @@ class StableReleaseGuardTests(unittest.TestCase):
|
||||
steps = self.RELEASE['jobs']['version']['steps']
|
||||
names = [step.get('name') or step.get('uses') or step.get('id') for step in steps]
|
||||
guard = next(step for step in steps if step.get('name') == 'Stable releases run only on refs/heads/release')
|
||||
self.assertEqual(guard['if'], "${{ !inputs.dry-run && github.ref != 'refs/heads/release' }}")
|
||||
self.assertIn('exit 1', guard['run'])
|
||||
self.assertEqual(guard['if'], "${{ !inputs.dry-run }}") # every real run; the ref check is in the shell
|
||||
self.assertEqual(guard['env']['REF'], '${{ github.ref }}')
|
||||
import subprocess
|
||||
for ref, code in (('refs/heads/release', 0), ('refs/heads/Release', 1), ('refs/heads/RELEASE', 1),
|
||||
('refs/heads/nightly-signer', 1), ('refs/heads/main', 1), ('refs/tags/release', 1), ('', 1)):
|
||||
with self.subTest(ref=ref):
|
||||
result = subprocess.run(['bash', '--noprofile', '--norc', '-eo', 'pipefail', '-c', guard['run']],
|
||||
env={'PATH': os.environ['PATH'], 'REF': ref}, capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, code, result.stdout)
|
||||
self.assertLess(names.index('Stable releases run only on refs/heads/release'), names.index('Resolve version'))
|
||||
# Every other job waits for version (directly or through a job that does).
|
||||
jobs = self.RELEASE['jobs']
|
||||
@@ -76,6 +83,21 @@ class StableReleaseGuardTests(unittest.TestCase):
|
||||
with self.subTest(job=name):
|
||||
self.assertTrue(reaches(name))
|
||||
|
||||
def test_failed_ref_check_keeps_every_environment_job_from_running(self):
|
||||
# Expression `==` ignores case, so the environment expressions alone would pick `release` on
|
||||
# refs/heads/Release. Every job that binds the environment needs `version` directly and runs only if
|
||||
# it succeeded: either its `if` has no status function (implicit success()) or it refuses any failed need.
|
||||
for name, job in self.RELEASE['jobs'].items():
|
||||
if 'environment' not in job:
|
||||
continue
|
||||
with self.subTest(job=name):
|
||||
needs = job['needs'] if isinstance(job['needs'], list) else [job['needs']]
|
||||
self.assertIn('version', needs)
|
||||
condition = job.get('if', '')
|
||||
if any(word in condition for word in ('always()', 'cancelled()', 'failure()', 'success()')):
|
||||
self.assertIn("!contains(needs.*.result, 'failure')", condition)
|
||||
self.assertNotIn('always()', condition)
|
||||
|
||||
def test_only_the_two_shared_signing_workflows_name_the_release_environment(self):
|
||||
named = set()
|
||||
for path in WORKFLOWS.glob('*.yml'):
|
||||
|
||||
Reference in new issue
Block a user