diff --git a/.github/workflows/selftest.macos-13.yml b/.github/workflows/selftest.macos-13.yml new file mode 100644 index 0000000..871d21f --- /dev/null +++ b/.github/workflows/selftest.macos-13.yml @@ -0,0 +1,79 @@ +name: selftest macos-13 +on: + workflow_dispatch: null + schedule: + - cron: 0 0 1 * * + push: + branches: + - selftest +jobs: + build: + name: ${{ matrix.os }} / GHC ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: setup-haskell + uses: ./ + with: + ghc-version: ${{ matrix.ghc }} + - run: ghc --version + - run: cabal update + - run: cabal install alex + - run: alex --version + strategy: + fail-fast: false + matrix: + os: + - macos-13 + ghc: + - 7.10.3 + - 8.0.2 + - 8.2.2 + - 8.4.1 + - 8.4.2 + - 8.4.3 + - 8.4.4 + - 8.6.1 + - 8.6.2 + - 8.6.3 + - 8.6.4 + - 8.6.5 + - 8.8.1 + - 8.8.2 + - 8.8.3 + - 8.8.4 + - 8.10.1 + - 8.10.2 + - 8.10.3 + - 8.10.4 + - 8.10.5 + - 8.10.6 + - 8.10.7 + - 9.0.1 + - 9.0.2 + - 9.2.1 + - 9.2.2 + - 9.2.3 + - 9.2.4 + - 9.2.5 + - 9.2.6 + - 9.2.7 + - 9.2.8 + - 9.4.1 + - 9.4.2 + - 9.4.3 + - 9.4.4 + - 9.4.5 + - 9.4.6 + - 9.4.7 + - 9.4.8 + - 9.6.1 + - 9.6.2 + - 9.6.3 + - 9.6.4 + - 9.6.5 + - 9.6.6 + - 9.8.1 + - 9.8.2 + - 9.8.4 + - 9.10.1 diff --git a/.github/workflows/selftest.macos-11.yml b/.github/workflows/selftest.macos-14.yml similarity index 94% rename from .github/workflows/selftest.macos-11.yml rename to .github/workflows/selftest.macos-14.yml index a4141a3..7ce50ad 100644 --- a/.github/workflows/selftest.macos-11.yml +++ b/.github/workflows/selftest.macos-14.yml @@ -1,4 +1,4 @@ -name: selftest macos-11 +name: selftest macos-14 on: workflow_dispatch: null schedule: @@ -21,9 +21,10 @@ jobs: - run: cabal install alex - run: alex --version strategy: + fail-fast: false matrix: os: - - macos-11 + - macos-14 ghc: - 7.10.3 - 8.0.2 @@ -74,4 +75,5 @@ jobs: - 9.6.6 - 9.8.1 - 9.8.2 + - 9.8.4 - 9.10.1 diff --git a/.github/workflows/selftest.macos-12.yml b/.github/workflows/selftest.macos-15.yml similarity index 94% rename from .github/workflows/selftest.macos-12.yml rename to .github/workflows/selftest.macos-15.yml index 87c40e6..90f5c02 100644 --- a/.github/workflows/selftest.macos-12.yml +++ b/.github/workflows/selftest.macos-15.yml @@ -1,4 +1,4 @@ -name: selftest macos-12 +name: selftest macos-15 on: workflow_dispatch: null schedule: @@ -21,9 +21,10 @@ jobs: - run: cabal install alex - run: alex --version strategy: + fail-fast: false matrix: os: - - macos-12 + - macos-15 ghc: - 7.10.3 - 8.0.2 @@ -74,4 +75,5 @@ jobs: - 9.6.6 - 9.8.1 - 9.8.2 + - 9.8.4 - 9.10.1 diff --git a/.github/workflows/selftest.ubuntu-20.04.yml b/.github/workflows/selftest.ubuntu-20.04.yml index 72c7674..ec150bf 100644 --- a/.github/workflows/selftest.ubuntu-20.04.yml +++ b/.github/workflows/selftest.ubuntu-20.04.yml @@ -2,7 +2,7 @@ name: selftest ubuntu-20.04 on: workflow_dispatch: null schedule: - - cron: 0 0 5 * * + - cron: 0 0 4 * * push: branches: - selftest @@ -21,6 +21,7 @@ jobs: - run: cabal install alex - run: alex --version strategy: + fail-fast: false matrix: os: - ubuntu-20.04 @@ -78,4 +79,5 @@ jobs: - 9.6.6 - 9.8.1 - 9.8.2 + - 9.8.4 - 9.10.1 diff --git a/.github/workflows/selftest.ubuntu-22.04.yml b/.github/workflows/selftest.ubuntu-22.04.yml index 886ef76..846d662 100644 --- a/.github/workflows/selftest.ubuntu-22.04.yml +++ b/.github/workflows/selftest.ubuntu-22.04.yml @@ -2,7 +2,7 @@ name: selftest ubuntu-22.04 on: workflow_dispatch: null schedule: - - cron: 0 0 6 * * + - cron: 0 0 5 * * push: branches: - selftest @@ -21,6 +21,7 @@ jobs: - run: cabal install alex - run: alex --version strategy: + fail-fast: false matrix: os: - ubuntu-22.04 @@ -73,4 +74,5 @@ jobs: - 9.6.6 - 9.8.1 - 9.8.2 + - 9.8.4 - 9.10.1 diff --git a/.github/workflows/selftest.ubuntu-24.04.yml b/.github/workflows/selftest.ubuntu-24.04.yml new file mode 100644 index 0000000..86bfacf --- /dev/null +++ b/.github/workflows/selftest.ubuntu-24.04.yml @@ -0,0 +1,79 @@ +name: selftest ubuntu-24.04 +on: + workflow_dispatch: null + schedule: + - cron: 0 0 6 * * + push: + branches: + - selftest +jobs: + build: + name: ${{ matrix.os }} / GHC ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: setup-haskell + uses: ./ + with: + ghc-version: ${{ matrix.ghc }} + - run: ghc --version + - run: cabal update + - run: cabal install alex + - run: alex --version + strategy: + fail-fast: false + matrix: + os: + - ubuntu-24.04 + ghc: + - 7.10.3 + - 8.0.2 + - 8.2.2 + - 8.4.1 + - 8.4.2 + - 8.4.3 + - 8.4.4 + - 8.6.1 + - 8.6.2 + - 8.6.3 + - 8.6.4 + - 8.6.5 + - 8.8.1 + - 8.8.2 + - 8.8.3 + - 8.8.4 + - 8.10.1 + - 8.10.2 + - 8.10.3 + - 8.10.4 + - 8.10.5 + - 8.10.6 + - 8.10.7 + - 9.0.1 + - 9.0.2 + - 9.2.1 + - 9.2.2 + - 9.2.3 + - 9.2.4 + - 9.2.5 + - 9.2.6 + - 9.2.7 + - 9.2.8 + - 9.4.1 + - 9.4.2 + - 9.4.3 + - 9.4.4 + - 9.4.5 + - 9.4.6 + - 9.4.7 + - 9.4.8 + - 9.6.1 + - 9.6.2 + - 9.6.3 + - 9.6.4 + - 9.6.5 + - 9.6.6 + - 9.8.1 + - 9.8.2 + - 9.8.4 + - 9.10.1 diff --git a/.github/workflows/selftest.windows-2019.yml b/.github/workflows/selftest.windows-2019.yml index f8edd4a..4b03c56 100644 --- a/.github/workflows/selftest.windows-2019.yml +++ b/.github/workflows/selftest.windows-2019.yml @@ -21,6 +21,7 @@ jobs: - run: cabal install alex - run: alex --version strategy: + fail-fast: false matrix: os: - windows-2019 @@ -74,4 +75,5 @@ jobs: - 9.6.6 - 9.8.1 - 9.8.2 + - 9.8.4 - 9.10.1 diff --git a/.github/workflows/selftest.windows-2022.yml b/.github/workflows/selftest.windows-2022.yml index d1d73cd..28a53a8 100644 --- a/.github/workflows/selftest.windows-2022.yml +++ b/.github/workflows/selftest.windows-2022.yml @@ -21,6 +21,7 @@ jobs: - run: cabal install alex - run: alex --version strategy: + fail-fast: false matrix: os: - windows-2022 @@ -73,4 +74,5 @@ jobs: - 9.6.6 - 9.8.1 - 9.8.2 + - 9.8.4 - 9.10.1 diff --git a/README.md b/README.md index aea8097..87b13bc 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,57 @@ -| | `ubuntu-20.04` | `ubuntu-22.04` | `macos-11` | `macos-12` | `windows-2019` | `windows-2022` | -| :----------------------- | :------------: | :------------: | :--------: | :--------: | :------------: | :------------: | -| `latest` `9.10` `9.10.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.8` `9.8.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.8.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.6` `9.6.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.6.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.6.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.6.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.6.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.6.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4` `9.4.8` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4.7` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.4.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2` `9.2.8` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2.7` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.2.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.0` `9.0.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `9.0.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.10` `8.10.7` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.10.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.10.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.10.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.10.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.10.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.10.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.8` `8.8.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.8.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | ❌ | -| `8.8.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.8.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.6` `8.6.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.6.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.6.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.6.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.6.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.4` `8.4.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.4.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.4.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.4.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.2` `8.2.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `8.0` `8.0.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | -| `7.10` `7.10.3` | 🟢 | ❌ | 🟢 | 🟢 | 🟢 | 🟢 | -| `7.4` `7.4.2` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | -| `7.2` `7.2.2` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | -| `7.0` `7.0.4` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | -| `7.0.1` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | +| | `ubuntu-20.04` | `ubuntu-22.04` | `ubuntu-24.04` | `macos-13` | `macos-14` | `macos-15` | `windows-2019` | `windows-2022` | +| :----------------------- | :------------: | :------------: | :------------: | :--------: | :--------: | :--------: | :------------: | :------------: | +| `latest` `9.10` `9.10.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.8` `9.8.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.8.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.8.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.6` `9.6.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.6.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.6.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.6.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.6.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.6.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4` `9.4.8` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4.7` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.4.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2` `9.2.8` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2.7` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.2.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.0` `9.0.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `9.0.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.10` `8.10.7` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.10.6` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.10.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.10.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.10.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.10.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.10.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.8` `8.8.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.8.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | ❌ | +| `8.8.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.8.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.6` `8.6.5` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.6.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.6.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.6.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.6.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.4` `8.4.4` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.4.3` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.4.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.4.1` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.2` `8.2.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `8.0` `8.0.2` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `7.10` `7.10.3` | 🟢 | ❌ | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | +| `7.4` `7.4.2` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| `7.2` `7.2.2` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| `7.0` `7.0.4` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| `7.0.1` | 🟢 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | diff --git a/dist/index.js b/dist/index.js index 6bad9e4..0f3b770 100644 --- a/dist/index.js +++ b/dist/index.js @@ -105,10 +105,28 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.list = exports.install = void 0; +exports.list = exports.install = exports.ensure = void 0; const core = __importStar(__nccwpck_require__(186)); const exec_1 = __nccwpck_require__(514); const resolve_1 = __nccwpck_require__(778); +const io_1 = __nccwpck_require__(436); +async function ensure() { + if (!await (0, io_1.which)('ghcup')) { + await (0, exec_1.exec)('brew install ghcup'); + const home = process.env['HOME']; + if (home) { + core.addPath(home + '/.ghcup/bin/'); + } + } + if (!await (0, io_1.which)('cabal')) { + await (0, exec_1.exec)('ghcup install cabal latest --set'); + const result = await (0, exec_1.getExecOutput)('cabal', ['path', '-v0', '--installdir'], { + silent: true, + }); + core.addPath(result.stdout.trim()); + } +} +exports.ensure = ensure; async function install(version) { const older804 = (0, resolve_1.compareVersions)(version, '8.4') == -1; const ncursesRequired = older804 && process.env['ImageOS'] == 'ubuntu22'; @@ -119,7 +137,6 @@ async function install(version) { } await core.group('ghcup install', async () => { await (0, exec_1.exec)(`ghcup install ghc ${version} --set`); - core.addPath('$HOME/.ghcup/bin'); }); } exports.install = install; @@ -174,8 +191,8 @@ const ghcup = __importStar(__nccwpck_require__(474)); const resolve_1 = __nccwpck_require__(778); async function main() { try { + await ghcup.ensure(); await workaroundRunnerImageIssue7061(); - await addCabalBinToPath(); const requested = core.getInput('ghc-version'); const version = await ensure(requested); core.setOutput('ghc-version', version); @@ -198,12 +215,6 @@ async function workaroundRunnerImageIssue7061() { } }); } -async function addCabalBinToPath() { - const home = process.env['HOME']; - if (home) { - core.addPath(home + '/.cabal/bin/'); - } -} async function ensure(requested) { const resolved = await (0, resolve_1.resolve)(requested); await install(resolved); @@ -275,6 +286,7 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.installed = exports.resolve = exports.resolveVersion = exports.compareVersions = void 0; const exec_1 = __nccwpck_require__(514); +const io_1 = __nccwpck_require__(436); const apt = __importStar(__nccwpck_require__(911)); const ghcup = __importStar(__nccwpck_require__(474)); function compareVersions(a, b) { @@ -307,19 +319,27 @@ function resolveVersion(requested, versions) { } } exports.resolveVersion = resolveVersion; +async function doResolveVersion(requested) { + const versions = new Set([...apt.versions(), ...await ghcup.list()]); + return resolveVersion(requested, versions); +} async function resolve(requested) { const systemVersion = await installed(); const aptVersions = apt.versions(); let version; if (requested === 'system') { - version = systemVersion; + if (systemVersion) { + version = systemVersion; + } + else { + version = await doResolveVersion('latest'); + } } else if (apt.versions().has(requested)) { version = requested; } else { - const versions = new Set([...apt.versions(), ...await ghcup.list()]); - version = resolveVersion(requested, versions); + version = await doResolveVersion(requested); } if (version) { const source = version === systemVersion ? 'system' : @@ -335,10 +355,15 @@ async function resolve(requested) { } exports.resolve = resolve; async function installed() { - const result = await (0, exec_1.getExecOutput)('ghc', ['--numeric-version'], { - silent: true, - }); - return result.stdout.trim(); + if (await (0, io_1.which)('ghc')) { + const result = await (0, exec_1.getExecOutput)('ghc', ['--numeric-version'], { + silent: true, + }); + return result.stdout.trim(); + } + else { + return undefined; + } } exports.installed = installed; diff --git a/generate/selftest.ts b/generate/selftest.ts index 9e1ef1a..58f253d 100644 --- a/generate/selftest.ts +++ b/generate/selftest.ts @@ -18,8 +18,10 @@ export async function versionMap() { return { 'ubuntu-20.04': new Set([...ppa.ubuntu20, ...ghcup]), 'ubuntu-22.04': new Set([...ghcup].filter(v => !not_working_on_ubuntu_22_04.has(v))), - 'macos-11': ghcup, - 'macos-12': ghcup, + 'ubuntu-24.04': ghcup, + 'macos-13': ghcup, + 'macos-14': ghcup, + 'macos-15': ghcup, 'windows-2019': ghcup, 'windows-2022': new Set([...ghcup].filter(v => !not_working_on_windows_2022.has(v))), }; diff --git a/src/ghcup.ts b/src/ghcup.ts index f4bcb59..6b04e6b 100644 --- a/src/ghcup.ts +++ b/src/ghcup.ts @@ -1,6 +1,24 @@ import * as core from '@actions/core'; import { exec, getExecOutput } from '@actions/exec'; import { compareVersions } from './resolve'; +import { which } from '@actions/io'; + +export async function ensure() { + if (!await which('ghcup')) { + await exec('brew install ghcup'); + const home = process.env['HOME']; + if (home) { + core.addPath(home + '/.ghcup/bin/'); + } + } + if (!await which('cabal')) { + await exec('ghcup install cabal latest --set'); + const result = await getExecOutput('cabal', ['path', '-v0', '--installdir'], { + silent: true, + }); + core.addPath(result.stdout.trim()); + } +} export async function install(version: string) { const older804 = compareVersions(version, '8.4') == -1; @@ -12,7 +30,6 @@ export async function install(version: string) { } await core.group('ghcup install', async () => { await exec(`ghcup install ghc ${version} --set`); - core.addPath('$HOME/.ghcup/bin'); }); } diff --git a/src/main.ts b/src/main.ts index 5c70559..dbb2f5f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,8 +8,8 @@ import { installed, resolve, ResolvedVersion } from './resolve'; async function main() { try { + await ghcup.ensure(); await workaroundRunnerImageIssue7061(); - await addCabalBinToPath(); const requested = core.getInput('ghc-version'); const version = await ensure(requested); core.setOutput('ghc-version', version); @@ -32,13 +32,6 @@ async function workaroundRunnerImageIssue7061() { }); } -async function addCabalBinToPath() { - const home = process.env['HOME']; - if (home) { - core.addPath(home + '/.cabal/bin/'); - } -} - async function ensure(requested: string): Promise { const resolved = await resolve(requested); await install(resolved); diff --git a/src/resolve.spec.ts b/src/resolve.spec.ts index c8b5b9f..e394a2c 100644 --- a/src/resolve.spec.ts +++ b/src/resolve.spec.ts @@ -101,7 +101,7 @@ describe('resolve', () => { context('when version is already installed', () => { it('sets "source" to "system"', async () => { - const expected = await installed(); + const expected = (await installed())!; expect(await resolve(expected)).toEqual({ version: expected, source: 'system', diff --git a/src/resolve.ts b/src/resolve.ts index 43eeb0b..af454d6 100644 --- a/src/resolve.ts +++ b/src/resolve.ts @@ -1,4 +1,5 @@ import { getExecOutput } from '@actions/exec'; +import { which } from '@actions/io'; import * as apt from './apt'; import * as ghcup from './ghcup'; @@ -39,18 +40,26 @@ export type ResolvedVersion = { source: 'system' | 'apt' | 'ghcup'; }; +async function doResolveVersion(requested: string): Promise { + const versions = new Set([...apt.versions(), ...await ghcup.list()]); + return resolveVersion(requested, versions); +} + export async function resolve(requested: string): Promise { const systemVersion = await installed(); const aptVersions = apt.versions(); let version; if (requested === 'system') { - version = systemVersion; + if (systemVersion) { + version = systemVersion; + } else { + version = await doResolveVersion('latest'); + } } else if (apt.versions().has(requested)) { version = requested; } else { - const versions = new Set([...apt.versions(), ...await ghcup.list()]); - version = resolveVersion(requested, versions); + version = await doResolveVersion(requested); } if (version) { @@ -65,9 +74,13 @@ export async function resolve(requested: string): Promise { } } -export async function installed(): Promise { - const result = await getExecOutput('ghc', ['--numeric-version'], { - silent: true, - }); - return result.stdout.trim(); +export async function installed(): Promise { + if (await which('ghc')) { + const result = await getExecOutput('ghc', ['--numeric-version'], { + silent: true, + }); + return result.stdout.trim(); + } else { + return undefined; + } }