Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to declaratively specify tools to install #13

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/test-ghcup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,25 @@ jobs:

- uses: ./
with:
ghc: latest
cabal: 3.12.1.0
release-channels: |
https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/master/ghcup-vanilla-0.0.9.yaml
https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/master/ghcup-prereleases-0.0.9.yaml

- run: ghcup whereis ghc latest
- run: which ghc
- run: ghc --version

- run: ghcup whereis cabal 3.12.1.0
- run: which cabal
- run: cabal --version

- run: ghcup config
- run: ghcup debug-info
- run: ghcup tool-requirements
- run: ghcup list

- run: ghcup install ghc latest --set
- run: ghcup whereis ghc latest
- run: which ghc
- run: ghc --version

- run: ghcup install ghc latest-prerelease --set
- run: ghcup whereis ghc latest-prerelease
- run: which ghc
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ jobs:
- uses: actions/checkout@v4
- uses: haskell/ghcup-setup@v1
with:
ghc: ${{ matrix.ghc }}
cabal: ${{ matrix.cabal }}
release-channels: |
GHCupURL
https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/master/ghcup-prereleases-0.0.8.yaml
- run: |
ghcup install ghc --set ${{ matrix.ghc }}
ghcup install cabal --set ${{ matrix.cabal }}
runhaskell Hello.hs
```

Expand All @@ -59,6 +59,10 @@ jobs:
| Name | Description | Type | Default |
|------------------|-----------------------------------------------------------------|------------|------------|
| version | GHCup version to install | `string` | `latest` |
| ghc | GHC version to install | `string ` | `undefined`|
| cabal | cabal-install version to install | `string ` | `undefined`|
| stack | Stack version to install | `string ` | `undefined`|
| hls | HLS version to install | `string ` | `undefined`|
| release-channels | Set the release-channels | `string[]` | `GHCupURL` |
| stack-hook | Install the GHCup stack hook (GHCs are installed through ghcup) | `boolean` | `false` |

Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ inputs:
stack-hook:
description: Install the GHCup stack hook (GHCs are installed through ghcup)
default: false
ghc:
description: GHC version to install
cabal:
description: cabal-install version to install
stack:
description: Stack version to install
hls:
description: HLS version to install

outputs:
path:
Expand Down
48 changes: 24 additions & 24 deletions ghcup/dist/index.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions ghcup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ try {
version: core.getInput("version"),
release_channels: core.getMultilineInput("release-channels"),
stack_hook: core.getBooleanInput("stack-hook"),
ghc: core.getInput("ghc"),
cabal: core.getInput("cabal"),
stack: core.getInput("stack"),
hls: core.getInput("hls"),
});
} catch (error) {
core.setFailed((error as Error).message);
Expand Down
20 changes: 20 additions & 0 deletions ghcup/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export type Opts = {
version: string;
release_channels: string[];
stack_hook: boolean;
ghc?: string;
cabal?: string;
stack?: string;
hls?: string;
};

export async function main(opts: Opts) {
Expand Down Expand Up @@ -171,4 +175,20 @@ export async function main(opts: Opts) {
"url-source",
JSON.stringify(opts.release_channels),
]);

if (opts.ghc) {
await exec.exec(ghcupPath, ["install", "ghc", "--set", opts.ghc]);
}

if (opts.cabal) {
await exec.exec(ghcupPath, ["install", "cabal", "--set", opts.cabal]);
}

if (opts.stack) {
await exec.exec(ghcupPath, ["install", "stack", "--set", opts.stack]);
}

if (opts.hls) {
await exec.exec(ghcupPath, ["install", "hls", "--set", opts.hls]);
}
}
Loading