-
Notifications
You must be signed in to change notification settings - Fork 22
134 lines (121 loc) · 5.75 KB
/
test-on-main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Test on main
on:
workflow_dispatch:
jobs:
test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# - macos-latest
# - macos-13
- windows-latest
runs-on: ${{ matrix.os }}
env:
WECOM_ROBOT_KEY: ${{ secrets.WECOM_ROBOT_KEY }}
steps:
- uses: actions/checkout@v4
- name: Checkout moonc-version
uses: actions/checkout@v4
with:
ref: moonc-version-dont-delete
path: moonc-version-dont-delete
- name: Copy moonc-version file to workspace
run: |
cp moonc-version-dont-delete/moonc-version .
- uses: dtolnay/[email protected]
- name: Cargo cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
path: ~/.cargo/registry
- name: Setup Rclone
uses: AnimMouse/setup-rclone@v1
with:
rclone_config: ${{ secrets.RCLONE_CONFIG }}
- name: install MoonBit(Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
mkdir -p ~/.moon/bin
mkdir -p ~/.moon/lib
git clone --depth 1 https://github.com/moonbitlang/core.git ~/.moon/lib/core
mooncVersion=$(cat moonc-version | cut -c 1-9)
echo "$mooncVersion"
bins=('moonc' 'mooninfo' 'moonfmt')
for bin in "${bins[@]}"; do
rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/$(uname -s)-$(uname -m)/$bin" ~/.moon/bin/
chmod +x ~/.moon/bin/"$bin"
done
moonrunVersion=4bb74ba5f
rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/$(uname -s)-$(uname -m)/moonrun" ~/.moon/bin/
chmod +x ~/.moon/bin/moonrun
echo "$HOME/.moon/bin" >> $GITHUB_PATH
- name: install MoonBit(Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
New-Item -Path "$env:USERPROFILE" -Name ".moon" -ItemType "directory"
New-Item -Path "$env:USERPROFILE\.moon" -Name "lib" -ItemType "directory"
New-Item -Path "$env:USERPROFILE\.moon" -Name "bin" -ItemType "directory"
$mooncVersion = (Get-Content moonc-version -First 1).Substring(0, 9)
$bins = @("moonc.exe", "mooninfo.exe", "moonfmt.exe")
foreach ($bin in $bins) {
rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/Windows-x86_64/$bin" "$env:USERPROFILE\.moon\bin\"
}
$moonrunVersion = "4bb74ba5f"
rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/Windows-x86_64/moonrun.exe" "$env:USERPROFILE\.moon\bin\"
git clone --depth 1 https://github.com/moonbitlang/core.git "$env:USERPROFILE\.moon\lib\core"
"$env:USERPROFILE\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Build
run: cargo build
- name: Versions
run: cargo run --bin moon version --all
- name: Bundle core (Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: cargo run --bin moon bundle --source-dir ~/.moon/lib/core --all
- name: Bundle core (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: cargo run --bin moon bundle --source-dir "$env:USERPROFILE\.moon\lib\core" --all
- name: Test core (Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
cargo run --bin moon test --source-dir ~/.moon/lib/core --target wasm-gc
cargo run --bin moon test --source-dir ~/.moon/lib/core --target js
cargo run --bin moon test --source-dir ~/.moon/lib/core --target wasm
cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target wasm-gc
cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target js
cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target wasm
- name: Test core (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target wasm-gc
cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target js
cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target wasm
cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target wasm-gc
cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target js
cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target wasm
- name: Run tests
run: cargo test
- name: Notify on fail (windows)
if: ${{ failure() && matrix.os == 'windows-latest' }}
run: |
$body = @{
msgtype = "text"
text = @{
content = "🤣 moon ci on windows-latest failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{github.run_id}}"
}
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=$env:WECOM_ROBOT_KEY" -Method Post -ContentType "application/json" -Body $body
- name: notify on fail (unix)
if: ${{ failure() && matrix.os != 'windows-latest' }}
run: |
curl "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=$WECOM_ROBOT_KEY" \
-H 'Content-Type: application/json' \
-d @- <<REQUEST_BODY
{
"msgtype": "text",
"text": {
"content": "🤣 moon ci on ${{matrix.os}} failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
REQUEST_BODY