Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
30 changes: 30 additions & 0 deletions scripts/test_validate_release.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib.util
from pathlib import Path
import re
import tempfile
import unittest

Expand Down Expand Up @@ -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()
Loading