Skip to content

Commit 9c699ca

Browse files
committed
ci: pin MoonBit toolchain via cache + fix $|/#| mixed string lint
Second bleeding-edge toolchain break after the async [3002] one: the newest MoonBit compiler added syntax_lint [0063], which errors under `moon check --deny-warn` when a multi-line string literal mixes `$|` and `#|` prefixes. CI installs the toolchain via `curl ... | bash` (always latest), so this broke the `test` job on main and every PR. Two changes: 1. upload_pack_process.mbt: the partial-clone config template mixed `#|` (static) and `$|` (interpolated) lines in one literal. Converted all lines to `$|`; the static lines contain no backslash/`\{`, so the emitted config is byte-identical. Verified with `moon build --target native`. 2. Pin the toolchain. MoonBit's installer only fetches `latest`/`nightly` (cli.moonbitlang.com returns 403 for version strings — no real pinning), so a new composite action `.github/actions/setup-moon` caches ~/.moon (toolchain only; `moon update` still refreshes the registry) keyed by a `pin` marker. The toolchain is frozen to whatever was current when `pin` was last bumped; bump it to upgrade intentionally. Wired into every Unix install across ci/js-build/pages-demo/git-compat-random/copilot-setup/ release. The Windows install and nix-build (already overlay-pinned) are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WHFC6qxKjqjrixgjFtGihM
1 parent 69c1c11 commit 9c699ca

8 files changed

Lines changed: 61 additions & 46 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Setup MoonBit (pinned)
2+
description: >
3+
Install the MoonBit toolchain, pinned via an actions/cache key. MoonBit's
4+
installer can only fetch `latest`/`nightly` (it has no version-pinning), so a
5+
bleeding-edge release can break CI at any time (see #83: async [3002] and the
6+
$|/#| syntax_lint [0063]). Caching ~/.moon freezes the toolchain to whatever
7+
was current when `pin` was last bumped; bump `pin` to intentionally upgrade.
8+
inputs:
9+
pin:
10+
description: Toolchain pin marker. Bump this string to pull a newer toolchain.
11+
required: false
12+
default: "2026-06-22"
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Restore MoonBit toolchain cache
17+
id: moon-cache
18+
uses: actions/cache@v4
19+
with:
20+
# Cache the toolchain only (binaries + bundled core), not the registry
21+
# index — `moon update` still refreshes ~/.moon/registry every run.
22+
path: |
23+
~/.moon/bin
24+
~/.moon/lib
25+
~/.moon/include
26+
key: moon-toolchain-${{ runner.os }}-${{ inputs.pin }}
27+
- name: Install MoonBit CLI
28+
if: steps.moon-cache.outputs.cache-hit != 'true'
29+
shell: bash
30+
run: curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
31+
- name: Add MoonBit to PATH
32+
shell: bash
33+
run: echo "$HOME/.moon/bin" >> "$GITHUB_PATH"

.github/workflows/ci.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ jobs:
2121
uses: mizchi/pkspec@v0.2.1
2222
with:
2323
pkl-version: none
24-
- name: Install MoonBit CLI
25-
run: |
26-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
27-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
24+
- name: Setup MoonBit (pinned toolchain)
25+
uses: ./.github/actions/setup-moon
2826
- name: Moon update
2927
run: moon update
3028
- name: pkf run check
@@ -88,10 +86,8 @@ jobs:
8886
uses: mizchi/pkspec@v0.2.1
8987
with:
9088
pkl-version: none
91-
- name: Install MoonBit CLI
92-
run: |
93-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
94-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
89+
- name: Setup MoonBit (pinned toolchain)
90+
uses: ./.github/actions/setup-moon
9591
- name: Moon update
9692
run: moon update
9793
- name: Build native binary for wbtests
@@ -127,10 +123,8 @@ jobs:
127123
uses: actions/checkout@v4
128124
with:
129125
submodules: true
130-
- name: Install MoonBit CLI
131-
run: |
132-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
133-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
126+
- name: Setup MoonBit (pinned toolchain)
127+
uses: ./.github/actions/setup-moon
134128
- name: Moon update
135129
run: moon update
136130
- name: Distributed tests
@@ -180,10 +174,8 @@ jobs:
180174
cd third_party/git
181175
make -j$(nproc)
182176
183-
- name: Install MoonBit CLI
184-
run: |
185-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
186-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
177+
- name: Setup MoonBit (pinned toolchain)
178+
uses: ./.github/actions/setup-moon
187179

188180
- name: Moon update
189181
run: moon update

.github/workflows/copilot-setup-steps.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ jobs:
2929
- name: Checkout code
3030
uses: actions/checkout@v5
3131

32-
- name: Set up MoonBit
33-
run: |
34-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
35-
echo "$HOME/.moon/bin" >> $GITHUB_PATH
32+
- name: Set up MoonBit (pinned toolchain)
33+
uses: ./.github/actions/setup-moon
3634

3735
- name: Update MoonBit dependencies
3836
run: |

.github/workflows/git-compat-random.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,9 @@ jobs:
7474
if: ${{ steps.shard_guard.outputs.should_run == 'true' }}
7575
uses: mizchi/pkfire@v0
7676

77-
- name: Install MoonBit CLI
77+
- name: Setup MoonBit (pinned toolchain)
7878
if: ${{ steps.shard_guard.outputs.should_run == 'true' }}
79-
run: |
80-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
81-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
79+
uses: ./.github/actions/setup-moon
8280

8381
- name: Build git from source
8482
if: ${{ steps.shard_guard.outputs.should_run == 'true' }}

.github/workflows/js-build.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ jobs:
3434
with:
3535
bun-version: 1.3.5
3636

37-
- name: Install MoonBit CLI
38-
run: |
39-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
40-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
37+
- name: Setup MoonBit (pinned toolchain)
38+
uses: ./.github/actions/setup-moon
4139

4240
- name: Moon update
4341
run: moon update

.github/workflows/pages-demo.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ jobs:
5656
with:
5757
bun-version: 1.3.5
5858

59-
- name: Install MoonBit CLI
60-
run: |
61-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
62-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
59+
- name: Setup MoonBit (pinned toolchain)
60+
uses: ./.github/actions/setup-moon
6361

6462
- name: Moon update
6563
run: moon update

.github/workflows/release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ jobs:
2727
with:
2828
submodules: true
2929

30-
- name: Install MoonBit CLI (Unix)
30+
- name: Setup MoonBit (pinned toolchain, Unix)
3131
if: runner.os != 'Windows'
32-
run: |
33-
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
34-
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
32+
uses: ./.github/actions/setup-moon
3533

3634
- name: Install MoonBit CLI (Windows)
3735
if: runner.os == 'Windows'

modules/bit_io/src/native/upload_pack_process.mbt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,19 +1325,19 @@ fn write_partial_clone_metadata(
13251325
let filter_value = filter.to_string()
13261326
let config_path = @bit.join_path(git_dir, "config")
13271327
let config =
1328-
#|[core]
1329-
#| repositoryformatversion = 1
1330-
#| filemode = true
1331-
#| bare = false
1332-
#| logallrefupdates = true
1333-
#|[extensions]
1334-
#| partialclone = origin
1328+
$|[core]
1329+
$| repositoryformatversion = 1
1330+
$| filemode = true
1331+
$| bare = false
1332+
$| logallrefupdates = true
1333+
$|[extensions]
1334+
$| partialclone = origin
13351335
$|[remote "origin"]
13361336
$| url = \{remote}
1337-
#| fetch = +refs/heads/*:refs/remotes/origin/*
1338-
#| promisor = true
1337+
$| fetch = +refs/heads/*:refs/remotes/origin/*
1338+
$| promisor = true
13391339
$| partialclonefilter = \{filter_value}
1340-
#|
1340+
$|
13411341
fs.write_string(config_path, config)
13421342
let packed_refs_path = @bit.join_path(git_dir, "packed-refs")
13431343
fs.write_string(packed_refs_path, "# pack-refs with: peeled fully-peeled\n")

0 commit comments

Comments
 (0)