Skip to content

Commit 1ec9ce9

Browse files
Merge pull request #1426 from moonbitlang/zihang/fix-ci-cd
ci: add CD E2E smoke using release binaries
2 parents 9c984a0 + 21ad5a2 commit 1ec9ce9

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed

.github/workflows/cd-e2e.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# moon: The build system and package manager for MoonBit.
2+
# Copyright (C) 2024 International Digital Economy Academy
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Affero General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Affero General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Affero General Public License
15+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
# For inquiries, you can contact us via e-mail at jichuruanjian@idea.edu.cn.
18+
19+
name: CD E2E
20+
21+
on:
22+
workflow_run:
23+
workflows: ["CD"]
24+
types: [completed]
25+
26+
permissions:
27+
actions: read
28+
contents: read
29+
30+
jobs:
31+
e2e:
32+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
os:
37+
- ubuntu-latest
38+
- macos-latest
39+
- windows-latest
40+
runs-on: ${{ matrix.os }}
41+
env:
42+
RELEASE_SHA: ${{ github.event.workflow_run.head_sha }}
43+
steps:
44+
- name: Download release binaries (S3, Unix)
45+
if: ${{ matrix.os != 'windows-latest' }}
46+
env:
47+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
48+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
49+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
50+
run: |
51+
version=$(echo "$RELEASE_SHA" | cut -c 1-9)
52+
mkdir -p dist
53+
platform="$(uname -s)-$(uname -m)"
54+
aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/${platform}/moon" dist/moon
55+
aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$version/${platform}/moonrun" dist/moonrun
56+
57+
- name: Download release binaries (S3, Windows)
58+
if: ${{ matrix.os == 'windows-latest' }}
59+
env:
60+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
61+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
62+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
63+
run: |
64+
$version = $env:RELEASE_SHA.Substring(0, 9)
65+
New-Item -ItemType Directory -Force -Path dist | Out-Null
66+
aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/Windows-x86_64/moon.exe" dist/moon.exe
67+
aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$version/Windows-x86_64/moonrun.exe" dist/moonrun.exe
68+
69+
- name: Install MoonBit (Unix)
70+
if: ${{ matrix.os != 'windows-latest' }}
71+
run: |
72+
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s nightly
73+
echo "$HOME/.moon/bin" >> $GITHUB_PATH
74+
75+
- name: Install MoonBit (Windows)
76+
if: ${{ matrix.os == 'windows-latest' }}
77+
run: |
78+
$env:MOONBIT_INSTALL_VERSION="nightly"
79+
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
80+
"$env:USERPROFILE\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
81+
82+
- name: Make release binaries executable (Unix)
83+
if: ${{ matrix.os != 'windows-latest' }}
84+
run: chmod +x dist/moon dist/moonrun
85+
86+
- name: E2E smoke test release binary (Unix)
87+
if: ${{ matrix.os != 'windows-latest' }}
88+
run: |
89+
set -euo pipefail
90+
moon_bin="${GITHUB_WORKSPACE}/dist/moon"
91+
"${moon_bin}" update
92+
workdir="$(mktemp -d)"
93+
project="${workdir}/moon_e2e"
94+
"${moon_bin}" new "${project}"
95+
cat <<'EOF' >> "${project}/moon_e2e_test.mbt"
96+
///|
97+
test "e2e" {
98+
let array = [1, 2, 3]
99+
inspect(sum(data=array), content="6")
100+
}
101+
EOF
102+
cd "${project}"
103+
"${moon_bin}" check
104+
"${moon_bin}" test --target wasm-gc --no-parallelize
105+
"${moon_bin}" package --frozen
106+
107+
- name: E2E smoke test release binary (Windows)
108+
if: ${{ matrix.os == 'windows-latest' }}
109+
run: |
110+
$moon = Join-Path $env:GITHUB_WORKSPACE "dist\moon.exe"
111+
$project = Join-Path $env:RUNNER_TEMP "moon_e2e"
112+
& $moon update
113+
& $moon new $project
114+
$testFile = Join-Path $project "moon_e2e_test.mbt"
115+
@"
116+
///|
117+
test "e2e" {
118+
let array = [1, 2, 3]
119+
inspect(sum(data=array), content="6")
120+
}
121+
"@ | Add-Content -Path $testFile
122+
Set-Location $project
123+
& $moon check
124+
& $moon test --target wasm-gc --no-parallelize
125+
& $moon package --frozen

.github/workflows/cd.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
os: [macos-latest, windows-latest]
3232
runs-on: ${{ matrix.os }}
3333
steps:
34+
- name: Configure git
35+
run: git config --global core.autocrlf false
36+
3437
- uses: actions/checkout@v4
3538
with:
3639
submodules: true
@@ -74,6 +77,9 @@ jobs:
7477
run: |
7578
apt update && apt install -y software-properties-common curl unzip build-essential git sudo coreutils
7679
80+
- name: Configure git
81+
run: git config --global core.autocrlf false
82+
7783
- name: Checkout
7884
run: |
7985
git clone --depth 1 "https://${{ secrets.MOON_CLONE_PAT }}@github.com/moonbitlang/moon.git" "$GITHUB_WORKSPACE"

0 commit comments

Comments
 (0)