-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bao Zhiyuan
committed
Jul 5, 2024
1 parent
dbd93cd
commit 0e8c10e
Showing
3 changed files
with
512 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# Copyright 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 <http://www.gnu.org/licenses/>. | ||
|
||
name: CD | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [macos-latest, macos-13, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/[email protected] | ||
- name: Cargo cache | ||
uses: actions/cache@v4 | ||
with: | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | ||
path: ~/.cargo/registry | ||
- name: Build | ||
run: cargo build --release | ||
|
||
- name: Setup Rclone | ||
uses: AnimMouse/setup-rclone@v1 | ||
with: | ||
rclone_config: ${{ secrets.RCLONE_CONFIG }} | ||
|
||
- name: Upload(Unix) | ||
if: ${{ matrix.os != 'windows-latest' }} | ||
run: | | ||
version=$(echo "$GITHUB_SHA" | cut -c 1-9) | ||
rclone copy target/release/moon "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/$(uname -s)-$(uname -m)/" | ||
- name: Upload(Windows) | ||
if: ${{ matrix.os == 'windows-latest' }} | ||
run: | | ||
$version = "$env:GITHUB_SHA".Substring(0, 9) | ||
rclone copyto -L .\target\release\moon.exe "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/Windows-x86_64/moon.exe" | ||
- name: Checkout moonc-version (macos-latest) | ||
if: ${{ matrix.os == 'macos-latest' }} | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: moonc-version-dont-delete | ||
path: moonc-version-dont-delete | ||
|
||
- name: Copy moonc-version file to workspace (macos-latest) | ||
if: ${{ matrix.os == 'macos-latest' }} | ||
run: | | ||
cp moonc-version-dont-delete/moonc-version . | ||
- name: Bleeding Release (macos-latest) | ||
if: ${{ matrix.os == 'macos-latest' }} | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | ||
run: | | ||
rm -rf tmp-bins | ||
mkdir tmp-bins | ||
mooncVersion=$(cat moonc-version | cut -c 1-9) | ||
rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/$(uname -s)-$(uname -m)/" ./tmp-bins/ | ||
moonrunVersion=33bbc3ed9 | ||
rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/$(uname -s)-$(uname -m)/moonrun" ./tmp-bins/ | ||
cp -L ./target/release/moon ./tmp-bins/ | ||
pushd tmp-bins && shasum -a 256 -- * >../moonbit-darwin-aarch64.sha256 && popd | ||
tar czf ./moonbit-darwin-aarch64.tar.gz --directory=./tmp-bins . | ||
aws s3 cp ./moonbit-darwin-aarch64.tar.gz s3://cli.moonbitlang.com/binaries/bleeding/moonbit-darwin-aarch64.tar.gz | ||
aws s3 cp ./moonbit-darwin-aarch64.sha256 s3://cli.moonbitlang.com/binaries/bleeding/moonbit-darwin-aarch64.sha256 | ||
aws cloudfront create-invalidation --distribution-id E1KQYZEVEB0TAY --paths "/*" | ||
ubuntu-build: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ubuntu:16.04 | ||
steps: | ||
- name: Install dependencies | ||
run: | | ||
apt update && apt install -y software-properties-common curl unzip build-essential git | ||
- name: Checkout | ||
run: | | ||
git clone --depth 1 "https://${{ secrets.MOON_CLONE_PAT }}@github.com/moonbitlang/moon.git" "$GITHUB_WORKSPACE" | ||
- name: Install Rust | ||
run: | | ||
curl --proto '=https' --tlsv1.2 -sSf "https://sh.rustup.rs" | sh -s -- -y | ||
echo ~/.cargo/bin >> $GITHUB_PATH | ||
- name: Rust Version | ||
run: | | ||
cargo version | ||
rustc --version | ||
- run: | | ||
git config --global --add safe.directory "$(pwd)" | ||
git status | ||
- name: Build | ||
run: cargo build --release | ||
|
||
- name: Setup Rclone | ||
env: | ||
RCLONE_CONFIG_PLAIN: ${{ secrets.RCLONE_CONFIG_PLAIN }} | ||
run: | | ||
curl https://rclone.org/install.sh | bash | ||
mkdir -p ~/.config/rclone | ||
echo "$RCLONE_CONFIG_PLAIN" > ~/.config/rclone/rclone.conf | ||
- name: Upload | ||
run: | | ||
version="$(echo "$GITHUB_SHA" | cut -c 1-9)" | ||
echo "$version" | ||
rclone copy target/release/moon "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/$(uname -s)-$(uname -m)/" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
# Copyright 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 <http://www.gnu.org/licenses/>. | ||
|
||
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=33bbc3ed9 | ||
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 = "33bbc3ed9" | ||
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 | ||
|
||
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=33bbc3ed9 | ||
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 |
Oops, something went wrong.