|
| 1 | +# moon: The build system and package manager for MoonBit. |
| 2 | +# Copyright (C) 2024 International Digital Economy Academy |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU Affero General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU Affero General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU Affero General Public License |
| 15 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | +# |
| 17 | +# For inquiries, you can contact us via e-mail at jichuruanjian@idea.edu.cn. |
| 18 | + |
| 19 | +name: CD E2E |
| 20 | + |
| 21 | +on: |
| 22 | + workflow_run: |
| 23 | + workflows: ["CD"] |
| 24 | + types: [completed] |
| 25 | + |
| 26 | +permissions: |
| 27 | + actions: read |
| 28 | + contents: read |
| 29 | + |
| 30 | +jobs: |
| 31 | + e2e: |
| 32 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + os: |
| 37 | + - ubuntu-latest |
| 38 | + - macos-latest |
| 39 | + - windows-latest |
| 40 | + runs-on: ${{ matrix.os }} |
| 41 | + env: |
| 42 | + RELEASE_SHA: ${{ github.event.workflow_run.head_sha }} |
| 43 | + steps: |
| 44 | + - name: Download release binaries (S3, Unix) |
| 45 | + if: ${{ matrix.os != 'windows-latest' }} |
| 46 | + env: |
| 47 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 48 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 49 | + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} |
| 50 | + run: | |
| 51 | + version=$(echo "$RELEASE_SHA" | cut -c 1-9) |
| 52 | + mkdir -p dist |
| 53 | + platform="$(uname -s)-$(uname -m)" |
| 54 | + aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/${platform}/moon" dist/moon |
| 55 | + aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$version/${platform}/moonrun" dist/moonrun |
| 56 | +
|
| 57 | + - name: Download release binaries (S3, Windows) |
| 58 | + if: ${{ matrix.os == 'windows-latest' }} |
| 59 | + env: |
| 60 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 61 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 62 | + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} |
| 63 | + run: | |
| 64 | + $version = $env:RELEASE_SHA.Substring(0, 9) |
| 65 | + New-Item -ItemType Directory -Force -Path dist | Out-Null |
| 66 | + aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/Windows-x86_64/moon.exe" dist/moon.exe |
| 67 | + aws s3 cp "s3://${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$version/Windows-x86_64/moonrun.exe" dist/moonrun.exe |
| 68 | +
|
| 69 | + - name: Install MoonBit (Unix) |
| 70 | + if: ${{ matrix.os != 'windows-latest' }} |
| 71 | + run: | |
| 72 | + curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s nightly |
| 73 | + echo "$HOME/.moon/bin" >> $GITHUB_PATH |
| 74 | +
|
| 75 | + - name: Install MoonBit (Windows) |
| 76 | + if: ${{ matrix.os == 'windows-latest' }} |
| 77 | + run: | |
| 78 | + $env:MOONBIT_INSTALL_VERSION="nightly" |
| 79 | + Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex |
| 80 | + "$env:USERPROFILE\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append |
| 81 | +
|
| 82 | + - name: Make release binaries executable (Unix) |
| 83 | + if: ${{ matrix.os != 'windows-latest' }} |
| 84 | + run: chmod +x dist/moon dist/moonrun |
| 85 | + |
| 86 | + - name: E2E smoke test release binary (Unix) |
| 87 | + if: ${{ matrix.os != 'windows-latest' }} |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + moon_bin="${GITHUB_WORKSPACE}/dist/moon" |
| 91 | + "${moon_bin}" update |
| 92 | + workdir="$(mktemp -d)" |
| 93 | + project="${workdir}/moon_e2e" |
| 94 | + "${moon_bin}" new "${project}" |
| 95 | + cat <<'EOF' >> "${project}/moon_e2e_test.mbt" |
| 96 | + ///| |
| 97 | + test "e2e" { |
| 98 | + let array = [1, 2, 3] |
| 99 | + inspect(sum(data=array), content="6") |
| 100 | + } |
| 101 | + EOF |
| 102 | + cd "${project}" |
| 103 | + "${moon_bin}" check |
| 104 | + "${moon_bin}" test --target wasm-gc --no-parallelize |
| 105 | + "${moon_bin}" package --frozen |
| 106 | +
|
| 107 | + - name: E2E smoke test release binary (Windows) |
| 108 | + if: ${{ matrix.os == 'windows-latest' }} |
| 109 | + run: | |
| 110 | + $moon = Join-Path $env:GITHUB_WORKSPACE "dist\moon.exe" |
| 111 | + $project = Join-Path $env:RUNNER_TEMP "moon_e2e" |
| 112 | + & $moon update |
| 113 | + & $moon new $project |
| 114 | + $testFile = Join-Path $project "moon_e2e_test.mbt" |
| 115 | + @" |
| 116 | +///| |
| 117 | +test "e2e" { |
| 118 | + let array = [1, 2, 3] |
| 119 | + inspect(sum(data=array), content="6") |
| 120 | +} |
| 121 | +"@ | Add-Content -Path $testFile |
| 122 | + Set-Location $project |
| 123 | + & $moon check |
| 124 | + & $moon test --target wasm-gc --no-parallelize |
| 125 | + & $moon package --frozen |
0 commit comments