-
Notifications
You must be signed in to change notification settings - Fork 58
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
1 parent
87ec789
commit 3186f34
Showing
1 changed file
with
98 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,98 @@ | ||
name: check document examples | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- next/sources | ||
schedule: | ||
- cron: '0 10 * * 2' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: | ||
- name: ubuntu-latest | ||
- name: macos-latest | ||
- name: macos-14 | ||
- name: windows-latest | ||
backend: [wasm, wasm-gc, js] | ||
runs-on: ${{ matrix.os.name }} | ||
continue-on-error: ${{ matrix.os.name == 'macos-14' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: install | ||
if: ${{ matrix.os.name != 'windows-latest' }} | ||
run: | | ||
/bin/bash -c "$(curl -fsSL https://cli.moonbitlang.com/install/unix.sh)" | ||
echo "$HOME/.moon/bin" >> $GITHUB_PATH | ||
- name: install on windows | ||
if: ${{ matrix.os.name == 'windows-latest' }} | ||
run: | | ||
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.cn/install/powershell.ps1 | iex | ||
"C:\Users\runneradmin\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append | ||
- name: moon version | ||
run: | | ||
moon version --all | ||
moonrun --version | ||
- name: moon check and test | ||
if: ${{ matrix.os.name != 'windows-latest' }} | ||
run: | | ||
moon update | ||
failed_directories=() | ||
for dir in next/sources/*; do | ||
if [ -d "$dir" ]; then | ||
echo "Processing $dir" | ||
if ! (cd "$dir" && moon install && moon check --target ${{ matrix.backend }} && moon test --target ${{ matrix.backend }}) --deny-warn; then | ||
echo "Failed in $dir" | ||
failed_directories+=("$dir") | ||
fi | ||
fi | ||
done | ||
if [ ${#failed_directories[@]} -ne 0 ]; then | ||
echo "Commands failed in the following directories:" | ||
for dir in "${failed_directories[@]}"; do | ||
echo "$dir" | ||
done | ||
exit 1 | ||
fi | ||
- name: check result size | ||
if: ${{ matrix.os.name != 'windows-latest' }} | ||
run: | | ||
find ./target -name '*.wasm' | xargs ls -lh | ||
find ./target -name '*.js' | xargs ls -lh | ||
- name: moon check and test on windows | ||
if: ${{ matrix.os.name == 'windows-latest' }} | ||
run: | | ||
moon update | ||
$failed_directories = @() | ||
Get-ChildItem -Path ".\legacy\examples" -Directory | ForEach-Object { | ||
Write-Output "Processing $($_.FullName)" | ||
Set-Location $_.FullName | ||
moon install && moon check --target ${{ matrix.backend }} && moon test --target ${{ matrix.backend }} --deny-warn | ||
if (!$?) { | ||
Write-Output "Failed in $($_.FullName)" | ||
$failed_directories += $_.FullName | ||
} | ||
Set-Location -Path $env:GITHUB_WORKSPACE | ||
} | ||
if ($failed_directories.Count -ne 0) { | ||
Write-Output "Commands failed in the following directories:" | ||
$failed_directories | ForEach-Object { Write-Output $_ } | ||
exit 1 | ||
} | ||
- name: check result size on windows | ||
if: ${{ matrix.os.name == 'windows-latest' }} | ||
run: | | ||
Get-ChildItem -Path ".\target" -Recurse -Filter "*.wasm" | ForEach-Object { "{0} ({1} bytes)" -f $_.FullName, $_.Length } | ||
Get-ChildItem -Path ".\target" -Recurse -Filter "*.js" | ForEach-Object { "{0} ({1} bytes)" -f $_.FullName, $_.Length } |