Test on main #725
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# moon: The build system and package manager for MoonBit. | |
# Copyright (C) 2024 International Digital Economy Academy | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU Affero General Public License for more details. | |
# | |
# You should have received a copy of the GNU Affero General Public License | |
# along with this program. If not, see <https://www.gnu.org/licenses/>. | |
# | |
# For inquiries, you can contact us via e-mail at [email protected]. | |
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: | | |
curl https://cli.moonbitlang.com/moon-ci/$(uname -s)-$(uname -m).tar.gz --output moonbit.tar.gz | |
mkdir -p ~/.moon/bin | |
mkdir -p ~/.moon/lib | |
tar xf moonbit.tar.gz --directory ~/.moon/bin/ | |
curl https://cli.moonbitlang.com/moon-ci/$(uname -s)-$(uname -m)/moonrun --output ~/.moon/bin/moonrun | |
curl https://cli.moonbitlang.com/moon-ci/$(uname -s)-$(uname -m)/mooncake --output ~/.moon/bin/mooncake | |
chmod +x ~/.moon/bin/moon* | |
chmod +x ~/.moon/bin/tcc | |
git clone --depth 1 https://github.com/moonbitlang/core.git ~/.moon/lib/core | |
echo "$HOME/.moon/bin" >> $GITHUB_PATH | |
echo "$GITHUB_WORKSPACE/target/debug" >> $GITHUB_PATH | |
- name: install MoonBit(Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: | | |
Invoke-WebRequest -Uri https://cli.moonbitlang.com/moon-ci/Windows-x86_64.zip -OutFile moonbit.zip | |
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE/.moon/bin" | |
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE/.moon/lib" | |
Expand-Archive -Path "moonbit.zip" -DestinationPath "$env:USERPROFILE/.moon/bin/" -Force | |
Invoke-WebRequest -Uri https://cli.moonbitlang.com/moon-ci/Windows-x86_64/moonrun.exe -OutFile "$env:USERPROFILE/.moon/bin/moonrun.exe" | |
Invoke-WebRequest -Uri https://cli.moonbitlang.com/moon-ci/Windows-x86_64/mooncake.exe -OutFile "$env:USERPROFILE/.moon/bin/mooncake.exe" | |
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 | |
"$env:GITHUB_WORKSPACE\target\debug" | Out-File -FilePath $env:GITHUB_PATH -Append | |
- name: Setup MSVC | |
if: ${{ matrix.os == 'windows-latest' }} | |
uses: ilammy/msvc-dev-cmd@v1 | |
- 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: Run tests | |
run: cargo test | |
- 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 coverage (Unix) | |
if: ${{ matrix.os != 'windows-latest' }} | |
run: | | |
cd ~/.moon/lib/core | |
moon test --enable-coverage | |
moon coverage report -f summary | |
moon coverage report -f coveralls -o codecov_report.json | |
- name: Coveralls GitHub Action | |
if: ${{ matrix.os != 'windows-latest' }} | |
uses: coverallsapp/[email protected] | |
with: | |
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
base-path: ~/.moon/lib/core/ | |
file: ~/.moon/lib/core/codecov_report.json | |
- 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: 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 |