From 5594823391e4bb8fa1503723a961a9b5727b2140 Mon Sep 17 00:00:00 2001 From: CryptoKey98 Date: Wed, 14 Oct 2026 23:59:39 -0700 Subject: [PATCH] Fix all-platform manual release builds --- .github/workflows/release.yml | 8 ++++---- scripts/test_validate_release.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de07604..35b8c41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,7 +75,7 @@ jobs: exit 1 fi windows: - if: github.event_name != 'workflow_dispatch' || inputs.platform == 'windows' + if: github.event_name != 'workflow_dispatch' || inputs.platform == 'all' || inputs.platform == 'windows' needs: validate runs-on: windows-latest strategy: @@ -143,7 +143,7 @@ jobs: dist/windows-${{ matrix.arch }}/*.msi if-no-files-found: error linux: - if: github.event_name != 'workflow_dispatch' || inputs.platform == 'linux' + if: github.event_name != 'workflow_dispatch' || inputs.platform == 'all' || inputs.platform == 'linux' needs: validate runs-on: ubuntu-22.04 strategy: @@ -185,7 +185,7 @@ jobs: dist/linux/*.rpm if-no-files-found: error arch: - if: github.event_name != 'workflow_dispatch' || inputs.platform == 'linux' + if: github.event_name != 'workflow_dispatch' || inputs.platform == 'all' || inputs.platform == 'linux' needs: validate runs-on: ubuntu-latest container: archlinux:base-devel @@ -205,7 +205,7 @@ jobs: path: dist/linux/*.pkg.tar.zst if-no-files-found: error macos: - if: github.event_name != 'workflow_dispatch' || inputs.platform == 'macos' + if: github.event_name != 'workflow_dispatch' || inputs.platform == 'all' || inputs.platform == 'macos' needs: validate runs-on: macos-latest steps: diff --git a/scripts/test_validate_release.py b/scripts/test_validate_release.py index 672253a..c1cfd4c 100644 --- a/scripts/test_validate_release.py +++ b/scripts/test_validate_release.py @@ -1,5 +1,6 @@ import importlib.util from pathlib import Path +import re import tempfile import unittest @@ -50,5 +51,34 @@ def test_rejects_missing_notes_and_placeholders(self): validator.release_notes(self.root, "v0.8.2") +class ReleaseWorkflowTests(unittest.TestCase): + def test_build_jobs_cover_tag_releases_and_manual_platform_selection(self): + workflow = (Path(__file__).resolve().parent.parent / ".github/workflows/release.yml").read_text() + conditions = dict(re.findall(r"^ (windows|linux|arch|macos):\n if: (.+)$", workflow, re.MULTILINE)) + self.assertEqual(set(conditions), {"windows", "linux", "arch", "macos"}) + + def selected(condition, event, platform): + # Evaluate only the equality/disjunction grammar used by build jobs. + # Reject unexpected syntax rather than executing workflow text. + comparisons = [] + for clause in condition.split(" || "): + match = re.fullmatch(r"(github.event_name|inputs.platform) (==|!=) '([^']*)'", clause) + self.assertIsNotNone(match, f"Unsupported job condition: {clause}") + value = event if match[1] == "github.event_name" else platform + comparisons.append((value == match[3]) if match[2] == "==" else (value != match[3])) + return any(comparisons) + + for event, platform, expected in [ + ("push", "", {"windows", "linux", "arch", "macos"}), + ("workflow_dispatch", "all", {"windows", "linux", "arch", "macos"}), + ("workflow_dispatch", "windows", {"windows"}), + ("workflow_dispatch", "linux", {"linux", "arch"}), + ("workflow_dispatch", "macos", {"macos"}), + ]: + with self.subTest(event=event, platform=platform): + actual = {job for job, condition in conditions.items() if selected(condition, event, platform)} + self.assertEqual(actual, expected) + + if __name__ == "__main__": unittest.main()