Skip to content

Commit

Permalink
Add config option, deprecate release-channels
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Jan 4, 2025
1 parent 517c92c commit b8ca95b
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 65 deletions.
45 changes: 36 additions & 9 deletions .github/workflows/test-ghcup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
- uses: actions/checkout@v4

- uses: ./
with:
stack-hook: true
version: ${{ matrix.version }}

- run: ghcup config
- run: ghcup debug-info
Expand Down Expand Up @@ -53,12 +50,6 @@ jobs:
- if: runner.os == 'Windows'
run: ghcup run -m sh -- -c 'pacman --version'

- name: Stack hook test
run: |
ghcup install stack latest
cat $(stack path --stack-root)/hooks/ghc-install.sh
shell: bash

vanilla-channel:
strategy:
matrix:
Expand Down Expand Up @@ -98,3 +89,39 @@ jobs:

- if: runner.os == 'Windows'
run: ghcup run -m sh -- -c 'pacman --version'

config:
strategy:
matrix:
runs-on:
- ubuntu-latest
version:
- latest
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4

- uses: ./
with:
stack-hook: true
version: ${{ matrix.version }}
config: |
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
# for full documentation
url-source:
- StackSetupURL
verbose: true
- run: ghcup config
- run: ghcup debug-info
- run: ghcup list

- run: ghcup -s GHCupURL install stack latest --set
- run: ghcup -s GHCupURL whereis stack latest
- run: which stack
- run: stack --version

- name: Stack hook test
run: |
cat $(stack path --stack-root)/hooks/ghc-install.sh
shell: bash
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ jobs:
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
config: |
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
# for full documentation
url-source:
- GHCupURL
- prereleases
- run: |
runhaskell Hello.hs
```
Expand All @@ -63,7 +66,7 @@ jobs:
| 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` |
| config | Set ghcup config | `string[]` | `[]` |
| stack-hook | Install the GHCup stack hook (GHCs are installed through ghcup) | `boolean` | `false` |

## Outputs
Expand All @@ -77,4 +80,3 @@ jobs:
| cachedir | Cache directory of GHCup | `string` |
| logsdir | Log directory of GHCup | `string` |
| confdir | Config directory of GHCup | `string` |

6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ inputs:
description: GHCup version to install
default: latest
release-channels:
description: Set the release-channels
default: |
GHCupURL
description: Set the release-channels (deprecated, use 'config' instead)
stack-hook:
description: Install the GHCup stack hook (GHCs are installed through ghcup)
default: false
Expand All @@ -24,6 +22,8 @@ inputs:
description: Stack version to install
hls:
description: HLS version to install
config:
description: GHCup config (partial or full)

outputs:
path:
Expand Down
Binary file modified ghcup/bun.lockb
Binary file not shown.
218 changes: 178 additions & 40 deletions ghcup/dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ghcup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1"
"@actions/tool-cache": "^2.0.1",
"yaml": "^2.7.0"
}
}
5 changes: 5 additions & 0 deletions ghcup/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { main } from "./main.ts";
import core from "@actions/core";
import YAML from "yaml";

try {
main({
Expand All @@ -10,6 +11,10 @@ try {
cabal: core.getInput("cabal"),
stack: core.getInput("stack"),
hls: core.getInput("hls"),
config: core.getInput("config")
? (YAML.parse(core.getInput("config")) ??
JSON.parse(core.getInput("config")))
: undefined,
});
} catch (error) {
core.setFailed((error as Error).message);
Expand Down
24 changes: 17 additions & 7 deletions ghcup/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ async function installStackHook() {

export type Opts = {
version: string;
release_channels: string[];
release_channels?: string[];
stack_hook: boolean;
ghc?: string;
cabal?: string;
stack?: string;
hls?: string;
config?: string;
};

export async function main(opts: Opts) {
Expand Down Expand Up @@ -169,12 +170,21 @@ export async function main(opts: Opts) {
installStackHook();
}

await exec.exec(ghcupPath, [
"config",
"set",
"url-source",
JSON.stringify(opts.release_channels),
]);
if (opts.config) {
await exec.exec(ghcupPath, ["config", "set", JSON.stringify(opts.config)]);
}

if (opts.release_channels && opts.release_channels.length > 0) {
core.warning(
"'release-channels' option is deprecated, use 'config' instead!",
);
await exec.exec(ghcupPath, [
"config",
"set",
"url-source",
JSON.stringify(opts.release_channels),
]);
}

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

0 comments on commit b8ca95b

Please sign in to comment.