Repository navigation
ci(desktop): replace the shell platform mapping gate with a structured matrix diff #8956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0306ee2
ci: tie the desktop platform matrix to the engine mapping with a stru…
lgray d975d66
ci: close the gaps deleting the old platform gate left open
lgray 399203b
ci(desktop): hold the platform file to release.yml's build-server matrix
lgray d47bd49
docs(ci): say what the platform checker actually refuses, and what it…
lgray 2a337f1
docs(ci): name preview-server.yml's build job, not build-server
lgray fde816c
ci(desktop): hold the preview publish list to the platform contract
lgray 9d4c9ed
test(ci): pin both directions the publish contract error promises
lgray 2eacbd8
ci(desktop): hold published release assets to the names desktops down…
lgray 6fa8c35
docs(ci): record why the preview publish job mixes two refs
lgray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Desktop platforms the shell release publishes: os arch triple. | ||
| # os/arch are spelled as std::env::consts::{OS, ARCH} spells them, which is also | ||
| # how shell-release.yml's build-shell matrix spells them. Held to that matrix by | ||
| # scripts/check_desktop_platform_matrix.py, and to native_engine.rs's | ||
| # ServerPlatform (whose triple each desktop downloads) by that module's own test. | ||
| # That script holds the triple column to preview-server.yml and release.yml too. | ||
| # preview-server.yml's publish job holds its own upload list to it at run time. | ||
| macos aarch64 aarch64-apple-darwin | ||
| windows x86_64 x86_64-pc-windows-msvc | ||
| linux x86_64 x86_64-unknown-linux-musl | ||
| linux aarch64 aarch64-unknown-linux-musl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/usr/bin/env python3 | ||
| """Hold the desktop build matrices to packaging/desktop-platforms.txt. | ||
|
|
||
| A platform shell-release.yml's build-shell matrix builds with no row there ships | ||
| a desktop whose ServerPlatform resolves no target triple, so it can never fetch | ||
| an engine; a triple preview-server.yml builds with no row there provisions a | ||
| preview no desktop asks for; a listed triple release.yml's build-server never | ||
| builds is a download URL that 404s. native_engine.rs's test cannot see any half. | ||
| """ | ||
|
|
||
| import os | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import yaml | ||
|
|
||
| ROOT = Path(os.environ.get("DESKTOP_PLATFORM_ROOT") or Path(__file__).resolve().parent.parent) | ||
| PLATFORMS = ROOT / "packaging" / "desktop-platforms.txt" | ||
| MATRIX = ROOT / ".github" / "workflows" / "shell-release.yml" | ||
| PREVIEW = ROOT / ".github" / "workflows" / "preview-server.yml" | ||
| RELEASE = ROOT / ".github" / "workflows" / "release.yml" | ||
| TRIPLE_SOURCES = [ | ||
|
lgray marked this conversation as resolved.
Resolved
|
||
| (PREVIEW, "build", "no desktop would ever ask for that preview", ""), | ||
| (RELEASE, "build-server", "no desktop downloads it", "; the desktop's download URL 404s"), | ||
| ] | ||
|
|
||
|
|
||
| def listed(): | ||
| # read_text raises by design: an empty list fails a populated matrix anyway, but blames it. | ||
| rows = [line.split("#")[0].split() for line in PLATFORMS.read_text().splitlines()] | ||
| rows = [row for row in rows if row] | ||
| if malformed := [row for row in rows if len(row) != 3]: | ||
| sys.exit(f"::error::desktop-platforms.txt rows are not `os arch triple`: {malformed}") | ||
| return {tuple(row) for row in rows} | ||
|
|
||
|
|
||
| def include(path, job): | ||
| # A matrix runs the product of its free axes too, so reading include alone | ||
| # would report those builds as not happening. | ||
| matrix = yaml.safe_load(path.read_text())["jobs"][job]["strategy"]["matrix"] | ||
| if free := sorted(set(matrix) - {"include", "exclude"}): | ||
| sys.exit(f"::error::{path.name} {job} matrix has free axes {free}, whose product builds " | ||
| "platforms this checker cannot see") | ||
| return matrix["include"] | ||
|
|
||
|
|
||
| def built(): | ||
| return {(entry["os"], entry["arch"]) for entry in include(MATRIX, "build-shell")} | ||
|
|
||
|
|
||
| def main(): | ||
| rows = listed() | ||
| want, have = {row[:2] for row in rows}, built() | ||
| print(f"desktop-platforms.txt: {sorted(want)}") | ||
| print(f"build-shell matrix: {sorted(have)}") | ||
| for pair in sorted(have - want): | ||
| print(f"::error::build-shell builds {pair}, which desktop-platforms.txt does not " | ||
| "list; that desktop would ship unable to fetch an engine", file=sys.stderr) | ||
| for pair in sorted(want - have): | ||
| print(f"::error::desktop-platforms.txt lists {pair}, which build-shell does not build", | ||
| file=sys.stderr) | ||
| triples, agree = {row[2] for row in rows}, want == have | ||
| print(f"desktop-platforms.txt triples: {sorted(triples)}") | ||
| for path, job, unlisted, missing in TRIPLE_SOURCES: | ||
| builds = {entry["triple"] for entry in include(path, job)} | ||
| print(f"{path.stem} {job} matrix:".ljust(30), sorted(builds)) | ||
| agree &= builds == triples | ||
| for triple in sorted(builds - triples): | ||
| print(f"::error::{path.stem} {job} has a row for {triple}, which " | ||
| f"desktop-platforms.txt does not list; {unlisted}", file=sys.stderr) | ||
| for triple in sorted(triples - builds): | ||
| print(f"::error::desktop-platforms.txt lists {triple}, which {path.stem} {job} " | ||
| f"does not build{missing}", file=sys.stderr) | ||
| return 0 if agree else 1 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/usr/bin/env python3 | ||
| """Legs for check_desktop_platform_matrix.py: agreement, a grown matrix, a | ||
| dropped platform, a missing list, a free matrix axis, a grown preview matrix, a | ||
| platform nothing releases, a malformed row. The direction that matters is | ||
| refusal: an unreadable list must raise, not read as an empty list. | ||
| """ | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
| from pathlib import Path | ||
|
|
||
| CHECKER = Path(__file__).resolve().parent / "check_desktop_platform_matrix.py" | ||
| MATRIX = """\ | ||
| jobs: | ||
| build-shell: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - {os: linux, arch: x86_64, runner: ubuntu-latest} | ||
| - {os: macos, arch: aarch64, runner: macos-latest} | ||
| """ | ||
| PREVIEW = """\ | ||
| jobs: | ||
| build: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - {triple: x86_64-unknown-linux-musl} | ||
| - {triple: aarch64-apple-darwin} | ||
| """ | ||
| RELEASE = """\ | ||
| jobs: | ||
| build-server: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - {triple: x86_64-unknown-linux-musl} | ||
| - {triple: aarch64-apple-darwin} | ||
| """ | ||
| LISTING = "# fields: os arch triple\nlinux x86_64 x86_64-unknown-linux-musl\nmacos aarch64 aarch64-apple-darwin\n" | ||
|
|
||
|
|
||
| def run(matrix, listing, preview=PREVIEW, release=RELEASE): | ||
| root = Path(tempfile.mkdtemp()) | ||
| (root / ".github" / "workflows").mkdir(parents=True) | ||
| (root / ".github" / "workflows" / "shell-release.yml").write_text(matrix) | ||
| (root / ".github" / "workflows" / "preview-server.yml").write_text(preview) | ||
| (root / ".github" / "workflows" / "release.yml").write_text(release) | ||
| if listing is not None: | ||
| (root / "packaging").mkdir() | ||
| (root / "packaging" / "desktop-platforms.txt").write_text(listing) | ||
| return subprocess.run( | ||
| [sys.executable, str(CHECKER)], capture_output=True, text=True, | ||
| env={**os.environ, "DESKTOP_PLATFORM_ROOT": str(root)}, | ||
| ) | ||
|
|
||
|
|
||
| agree = run(MATRIX, LISTING) | ||
| assert agree.returncode == 0, agree.stderr | ||
| assert "('linux', 'x86_64')" in agree.stdout, agree.stdout | ||
| assert "('macos', 'aarch64')" in agree.stdout, agree.stdout | ||
|
|
||
| grown = run(MATRIX + " - {os: windows, arch: x86_64, runner: windows-latest}\n", LISTING) | ||
| assert grown.returncode != 0, grown.stdout | ||
| assert "('windows', 'x86_64')" in grown.stderr, grown.stderr | ||
|
|
||
| dropped = run(MATRIX, LISTING + "freebsd x86_64 nope\n") | ||
| assert dropped.returncode != 0, dropped.stdout | ||
| assert "('freebsd', 'x86_64')" in dropped.stderr, dropped.stderr | ||
|
|
||
| absent = run(MATRIX, None) | ||
| assert absent.returncode != 0, absent.stdout | ||
| assert "desktop-platforms.txt" in absent.stderr, absent.stderr | ||
| assert "('linux', 'x86_64')" not in absent.stdout, absent.stdout | ||
|
|
||
| free = run(MATRIX + " arch: [riscv64]\n", LISTING) | ||
| assert free.returncode != 0, free.stdout | ||
| assert "free axes ['arch']" in free.stderr, free.stderr | ||
|
|
||
| previewed = run(MATRIX, LISTING, PREVIEW + " - {triple: riscv64-unknown-linux-musl}\n") | ||
| assert previewed.returncode != 0, previewed.stdout | ||
| assert "riscv64-unknown-linux-musl" in previewed.stderr, previewed.stderr | ||
|
|
||
| # The reviewer's reproduction: a platform every other matrix gained, which the | ||
| # release never builds, so its desktop resolves a download URL that 404s. | ||
| unreleased = run( | ||
| MATRIX + " - {os: linux, arch: riscv64, runner: ubuntu-latest}\n", | ||
| LISTING + "linux riscv64 riscv64-unknown-linux-musl\n", | ||
| PREVIEW + " - {triple: riscv64-unknown-linux-musl}\n", | ||
| ) | ||
| assert unreleased.returncode != 0, unreleased.stdout | ||
| assert "release build-server does not build" in unreleased.stderr, unreleased.stderr | ||
| assert "riscv64-unknown-linux-musl" in unreleased.stderr, unreleased.stderr | ||
|
|
||
| malformed = run(MATRIX, "linux x86_64\n") | ||
| assert malformed.returncode != 0, malformed.stdout | ||
| assert "['linux', 'x86_64']" in malformed.stderr, malformed.stderr | ||
|
|
||
| print("ok: agreement, grown matrix, dropped platform, missing list, free axis, " | ||
| "grown preview matrix, unreleased platform, malformed row") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.