diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5bbeb79..2da9142 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/scripts/nightly_app.py b/scripts/nightly_app.py index 62b66ef..292c9ad 100644 --- a/scripts/nightly_app.py +++ b/scripts/nightly_app.py @@ -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" diff --git a/tests/test_nightly_app.py b/tests/test_nightly_app.py index 7ae9d08..5f20393 100644 --- a/tests/test_nightly_app.py +++ b/tests/test_nightly_app.py @@ -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'))): diff --git a/tests/test_nightly_signer_branch.py b/tests/test_nightly_signer_branch.py index 48b31db..181dfa0 100644 --- a/tests/test_nightly_signer_branch.py +++ b/tests/test_nightly_signer_branch.py @@ -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'):