-
Notifications
You must be signed in to change notification settings - Fork 15
219 lines (196 loc) · 8.29 KB
/
ci.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: CI
on:
push:
branches: main
pull_request:
branches: main
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 0
CARGO_TARPAULIN_VERSION: 0.30.0
jobs:
license-header-check:
name: license header check
runs-on: ubuntu-latest
env:
HAWKEYE_VERSION: v5.6.0
steps:
- uses: actions/checkout@v4
- name: Download HawkEye
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/korandoru/hawkeye/releases/download/$HAWKEYE_VERSION/hawkeye-installer.sh | sh
- name: License Header Check
run: hawkeye check
typo-check:
name: typo-check
runs-on: ubuntu-latest
timeout-minutes: 10
env:
FORCE_COLOR: 1
TYPOS_VERSION: v1.18.0
steps:
- name: download typos
run: curl -LsSf https://github.com/crate-ci/typos/releases/download/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: check for typos
run: typos
code-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/[email protected]
with:
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
needs: [code-style, typo-check, license-header-check]
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# - macos-latest
# - macos-13
- windows-latest
runs-on: ${{ matrix.os }}
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: moon update
run: moon update
- name: Run tests
run: cargo test
coverage:
needs: test
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: dtolnay/[email protected]
- 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 .
- name: Setup Rclone
uses: AnimMouse/setup-rclone@v1
with:
rclone_config: ${{ secrets.RCLONE_CONFIG }}
- name: install MoonBit(Unix)
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 cargo-tarpaulin ${{ env.CARGO_TARPAULIN_VERSION }}
run: |
cd "${CARGO_HOME}/bin"
curl -sL https://github.com/xd009642/tarpaulin/releases/download/${CARGO_TARPAULIN_VERSION}/cargo-tarpaulin-aarch64-apple-darwin.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Build
run: cargo build
- name: Versions
run: cargo run --bin moon version --all
- name: Bundle core (Unix)
run: cargo run --bin moon bundle --source-dir ~/.moon/lib/core --all
- name: Generate code coverage
run: cargo tarpaulin --ignore-tests --out Xml
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: true