From 77b6febddde7af354dead61ee072747ebc0e32a3 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 12:24:52 +0100 Subject: [PATCH 01/13] Add CI job to check auto-generated code is committed Added a job to verify that auto-generated code is committed after making changes to a corresponding source of truth. --- .github/workflows/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f88eacb8..9dbb3163 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,19 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + check-codegen-diff: + runs-on: ubuntu-latest + name: "Verify auto-generated code is committed" + container: + image: swift:6.2-noble + steps: + - uses: actions/checkout@v4 + - name: Run auto-generated code checks + run: | + swift run --package-path Utilities WasmKitDevUtils wasmgen + swift run --package-path Utilities WasmKitDevUtils vmgen + [ $(git diff | wc -l) == 0 ] || exit 1 + build-macos: strategy: matrix: From c11d7982ae6f3030878f07c0e06efcdbc18f9e5c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 12:28:42 +0100 Subject: [PATCH 02/13] Pass `fetch-depth: 2` to `actions/checkout` in `check-autogen-diff` --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9dbb3163..8fa58e26 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,13 +10,14 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - check-codegen-diff: + check-autogen-diff: runs-on: ubuntu-latest - name: "Verify auto-generated code is committed" container: image: swift:6.2-noble steps: - uses: actions/checkout@v4 + with: + fetch-depth: 2 - name: Run auto-generated code checks run: | swift run --package-path Utilities WasmKitDevUtils wasmgen From 291b75e22ea47bfb76c481e5df481cacdabe9221 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 12:40:17 +0100 Subject: [PATCH 03/13] Check command output directly in `check-autogen-diff` --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8fa58e26..c53f6082 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,9 +20,8 @@ jobs: fetch-depth: 2 - name: Run auto-generated code checks run: | - swift run --package-path Utilities WasmKitDevUtils wasmgen - swift run --package-path Utilities WasmKitDevUtils vmgen - [ $(git diff | wc -l) == 0 ] || exit 1 + [[ $(swift run -q --package-path Utilities WasmKitDevUtils wasmgen | wc -l) == 0 ]] || exit 1 + [[ $(swift run --package-path Utilities WasmKitDevUtils vmgen | wc -l) == 0 ]] || exit 1 build-macos: strategy: From 094bcd5ea330e56a4dc5010b6a8ddb907eb74cad Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 12:43:55 +0100 Subject: [PATCH 04/13] Use `test` command in `check-autogen-diff` --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c53f6082..a1f1f291 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,8 +20,8 @@ jobs: fetch-depth: 2 - name: Run auto-generated code checks run: | - [[ $(swift run -q --package-path Utilities WasmKitDevUtils wasmgen | wc -l) == 0 ]] || exit 1 - [[ $(swift run --package-path Utilities WasmKitDevUtils vmgen | wc -l) == 0 ]] || exit 1 + test $(swift run -q --package-path Utilities WasmKitDevUtils wasmgen | wc -l) = "0" + test $(swift run -q --package-path Utilities WasmKitDevUtils vmgen | wc -l) = "0" build-macos: strategy: From c01394783fb4f01a62c207bf7d882efdf950d41b Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 12:49:38 +0100 Subject: [PATCH 05/13] Use `shell: bash` in `check-autogen-diff` --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a1f1f291..e712e96f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,7 @@ jobs: with: fetch-depth: 2 - name: Run auto-generated code checks + shell: bash run: | test $(swift run -q --package-path Utilities WasmKitDevUtils wasmgen | wc -l) = "0" test $(swift run -q --package-path Utilities WasmKitDevUtils vmgen | wc -l) = "0" From 9b17de7eb231ce5a2dae143d66ce11802440a6cb Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 12:55:49 +0100 Subject: [PATCH 06/13] Capture output of autogen commands in files --- .github/workflows/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e712e96f..564b407c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,8 +21,12 @@ jobs: - name: Run auto-generated code checks shell: bash run: | - test $(swift run -q --package-path Utilities WasmKitDevUtils wasmgen | wc -l) = "0" - test $(swift run -q --package-path Utilities WasmKitDevUtils vmgen | wc -l) = "0" + swift run -q --package-path Utilities WasmKitDevUtils wasmgen >> wasmgen.txt + swift run -q --package-path Utilities WasmKitDevUtils vmgen >> vmgen.txt + cat wasmgen.txt + cat vmgen.txt + test -s wasmgen.txt && exit 1 + test -s vmgen.txt && exit 1 build-macos: strategy: From 1e454965a633e86063dd4f3e9f03b59f1794b556 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 13:00:55 +0100 Subject: [PATCH 07/13] Improve diagnostics for `check-autogen-diff` --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 564b407c..c74e295a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,8 +25,8 @@ jobs: swift run -q --package-path Utilities WasmKitDevUtils vmgen >> vmgen.txt cat wasmgen.txt cat vmgen.txt - test -s wasmgen.txt && exit 1 - test -s vmgen.txt && exit 1 + test -s wasmgen.txt && echo "Uncommitted changes made by `WasmKitDevUtils wasmgen`" && exit 1 + test -s vmgen.txt && echo "Uncommitted changes made by `WasmKitDevUtils vmgen`" && exit 1 build-macos: strategy: From 5ebb06c9324e17ab934f2f0dc34d1d01a6c92ed7 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 13:02:54 +0100 Subject: [PATCH 08/13] Fix diagnostic string interpolation in `check-autogen-diff` --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c74e295a..0d9cd060 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,8 +25,8 @@ jobs: swift run -q --package-path Utilities WasmKitDevUtils vmgen >> vmgen.txt cat wasmgen.txt cat vmgen.txt - test -s wasmgen.txt && echo "Uncommitted changes made by `WasmKitDevUtils wasmgen`" && exit 1 - test -s vmgen.txt && echo "Uncommitted changes made by `WasmKitDevUtils vmgen`" && exit 1 + test -s wasmgen.txt && echo 'Uncommitted changes made by `WasmKitDevUtils wasmgen`' && exit 1 + test -s vmgen.txt && echo 'Uncommitted changes made by `WasmKitDevUtils vmgen`' && exit 1 build-macos: strategy: From e3aa57f78761299fd6b6e456d834275e1d69200c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 13:05:50 +0100 Subject: [PATCH 09/13] Make diagnostics more prominent in `check-autogen-diff` --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d9cd060..6dfba3c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,8 +25,8 @@ jobs: swift run -q --package-path Utilities WasmKitDevUtils vmgen >> vmgen.txt cat wasmgen.txt cat vmgen.txt - test -s wasmgen.txt && echo 'Uncommitted changes made by `WasmKitDevUtils wasmgen`' && exit 1 - test -s vmgen.txt && echo 'Uncommitted changes made by `WasmKitDevUtils vmgen`' && exit 1 + test -s wasmgen.txt && echo '⚠️ Uncommitted changes made by `WasmKitDevUtils wasmgen`' && exit 1 + test -s vmgen.txt && echo '⚠️ Uncommitted changes made by `WasmKitDevUtils vmgen`' && exit 1 build-macos: strategy: From 190013be5866e916d44741ce1b9f23527d040f63 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 13:09:32 +0100 Subject: [PATCH 10/13] Remove `shell: bash` from `check-autogen-diff` --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6dfba3c6..e4c6623f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,6 @@ jobs: with: fetch-depth: 2 - name: Run auto-generated code checks - shell: bash run: | swift run -q --package-path Utilities WasmKitDevUtils wasmgen >> wasmgen.txt swift run -q --package-path Utilities WasmKitDevUtils vmgen >> vmgen.txt From 71eb063c3a35796a7541af5192fc40107794df77 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 13:14:39 +0100 Subject: [PATCH 11/13] Make use of `git diff` and `::error::` formatting in `check-autogen-diff` --- .github/workflows/main.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e4c6623f..01344e72 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,17 +16,16 @@ jobs: image: swift:6.2-noble steps: - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - name: Run auto-generated code checks + - name: Re-generate auto-generated code checks run: | - swift run -q --package-path Utilities WasmKitDevUtils wasmgen >> wasmgen.txt - swift run -q --package-path Utilities WasmKitDevUtils vmgen >> vmgen.txt - cat wasmgen.txt - cat vmgen.txt - test -s wasmgen.txt && echo '⚠️ Uncommitted changes made by `WasmKitDevUtils wasmgen`' && exit 1 - test -s vmgen.txt && echo '⚠️ Uncommitted changes made by `WasmKitDevUtils vmgen`' && exit 1 - + swift run -q --package-path Utilities WasmKitDevUtils + - name: Check for changes + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git diff --exit-code || { + echo "::error::The auto-generated code utilities changed some files. Please see \`Utilities/README.md\`, re-run the tools, and commit the changes." + exit 1 + } build-macos: strategy: matrix: From 4f6c49545de5ad95c7e1d90ec9a3e8b43cd627e1 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 13:17:27 +0100 Subject: [PATCH 12/13] Modify `Instructions.json` to verify the check works --- Utilities/Instructions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Utilities/Instructions.json b/Utilities/Instructions.json index 9b90389d..793bf35c 100644 --- a/Utilities/Instructions.json +++ b/Utilities/Instructions.json @@ -216,5 +216,6 @@ ["threads" , "i32.atomic.store16" , ["0xFE", "0x1A"], [["memarg", "MemArg"]] , "store" ], ["threads" , "i64.atomic.store8" , ["0xFE", "0x1B"], [["memarg", "MemArg"]] , "store" ], ["threads" , "i64.atomic.store16" , ["0xFE", "0x1C"], [["memarg", "MemArg"]] , "store" ], - ["threads" , "i64.atomic.store32" , ["0xFE", "0x1D"], [["memarg", "MemArg"]] , "store" ] + ["threads" , "i64.atomic.store32" , ["0xFE", "0x1D"], [["memarg", "MemArg"]] , "store" ], + ["threads" , "i32.atomic.rmw.add" , ["0xFE", "0x1E"], [] , "binary" ] ] From b6559eb420c0debc802e2f41527285a06f520ab6 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 21 Oct 2025 13:20:53 +0100 Subject: [PATCH 13/13] Revert "Modify `Instructions.json` to verify the check works" This reverts commit 4f6c49545de5ad95c7e1d90ec9a3e8b43cd627e1. --- Utilities/Instructions.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Utilities/Instructions.json b/Utilities/Instructions.json index 793bf35c..9b90389d 100644 --- a/Utilities/Instructions.json +++ b/Utilities/Instructions.json @@ -216,6 +216,5 @@ ["threads" , "i32.atomic.store16" , ["0xFE", "0x1A"], [["memarg", "MemArg"]] , "store" ], ["threads" , "i64.atomic.store8" , ["0xFE", "0x1B"], [["memarg", "MemArg"]] , "store" ], ["threads" , "i64.atomic.store16" , ["0xFE", "0x1C"], [["memarg", "MemArg"]] , "store" ], - ["threads" , "i64.atomic.store32" , ["0xFE", "0x1D"], [["memarg", "MemArg"]] , "store" ], - ["threads" , "i32.atomic.rmw.add" , ["0xFE", "0x1E"], [] , "binary" ] + ["threads" , "i64.atomic.store32" , ["0xFE", "0x1D"], [["memarg", "MemArg"]] , "store" ] ]