Skip to content

Commit 76a3e69

Browse files
hasufellandreabedini
authored andcommitted
Add config option, deprecate release-channels
1 parent 517c92c commit 76a3e69

File tree

8 files changed

+81
-86
lines changed

8 files changed

+81
-86
lines changed

.github/workflows/test-ghcup.yaml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ jobs:
2121
- uses: actions/checkout@v4
2222

2323
- uses: ./
24-
with:
25-
stack-hook: true
26-
version: ${{ matrix.version }}
2724

2825
- run: ghcup config
2926
- run: ghcup debug-info
@@ -53,12 +50,6 @@ jobs:
5350
- if: runner.os == 'Windows'
5451
run: ghcup run -m sh -- -c 'pacman --version'
5552

56-
- name: Stack hook test
57-
run: |
58-
ghcup install stack latest
59-
cat $(stack path --stack-root)/hooks/ghc-install.sh
60-
shell: bash
61-
6253
vanilla-channel:
6354
strategy:
6455
matrix:
@@ -98,3 +89,39 @@ jobs:
9889

9990
- if: runner.os == 'Windows'
10091
run: ghcup run -m sh -- -c 'pacman --version'
92+
93+
config:
94+
strategy:
95+
matrix:
96+
runs-on:
97+
- ubuntu-latest
98+
version:
99+
- latest
100+
runs-on: ${{ matrix.runs-on }}
101+
steps:
102+
- uses: actions/checkout@v4
103+
104+
- uses: ./
105+
with:
106+
stack-hook: true
107+
version: ${{ matrix.version }}
108+
config: |
109+
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
110+
# for full documentation
111+
url-source:
112+
- StackSetupURL
113+
verbose: true
114+
115+
- run: ghcup config
116+
- run: ghcup debug-info
117+
- run: ghcup list
118+
119+
- run: ghcup -s GHCupURL install stack latest --set
120+
- run: ghcup -s GHCupURL whereis stack latest
121+
- run: which stack
122+
- run: stack --version
123+
124+
- name: Stack hook test
125+
run: |
126+
cat $(stack path --stack-root)/hooks/ghc-install.sh
127+
shell: bash

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ jobs:
4747
with:
4848
ghc: ${{ matrix.ghc }}
4949
cabal: ${{ matrix.cabal }}
50-
release-channels: |
51-
GHCupURL
52-
https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/master/ghcup-prereleases-0.0.8.yaml
50+
config: |
51+
# see https://github.com/haskell/ghcup-hs/blob/master/data/config.yaml
52+
# for full documentation
53+
url-source:
54+
- GHCupURL
55+
- prereleases
5356
- run: |
57+
ghcup install ghc --set ${{ matrix.ghc }}
58+
ghcup install cabal --set ${{ matrix.cabal }}
5459
runhaskell Hello.hs
5560
```
5661
@@ -63,7 +68,7 @@ jobs:
6368
| cabal | cabal-install version to install | `string ` | `undefined`|
6469
| stack | Stack version to install | `string ` | `undefined`|
6570
| hls | HLS version to install | `string ` | `undefined`|
66-
| release-channels | Set the release-channels | `string[]` | `GHCupURL` |
71+
| config | Set ghcup config | `string[]` | `[]` |
6772
| stack-hook | Install the GHCup stack hook (GHCs are installed through ghcup) | `boolean` | `false` |
6873

6974
## Outputs
@@ -77,4 +82,3 @@ jobs:
7782
| cachedir | Cache directory of GHCup | `string` |
7883
| logsdir | Log directory of GHCup | `string` |
7984
| confdir | Config directory of GHCup | `string` |
80-

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ inputs:
1010
description: GHCup version to install
1111
default: latest
1212
release-channels:
13-
description: Set the release-channels
14-
default: |
15-
GHCupURL
13+
description: Set the release-channels (deprecated, use 'config' instead)
1614
stack-hook:
1715
description: Install the GHCup stack hook (GHCs are installed through ghcup)
1816
default: false
@@ -24,6 +22,8 @@ inputs:
2422
description: Stack version to install
2523
hls:
2624
description: HLS version to install
25+
config:
26+
description: GHCup config (partial or full)
2727

2828
outputs:
2929
path:

ghcup/bun.lockb

336 Bytes
Binary file not shown.

ghcup/dist/index.js

Lines changed: 6 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ghcup/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@actions/core": "^1.11.1",
1313
"@actions/exec": "^1.1.1",
1414
"@actions/io": "^1.1.3",
15-
"@actions/tool-cache": "^2.0.1"
15+
"@actions/tool-cache": "^2.0.1",
16+
"yaml": "^2.7.0"
1617
}
1718
}

ghcup/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { main } from "./main.ts";
22
import core from "@actions/core";
3+
import YAML from "yaml";
34

45
try {
56
main({
@@ -10,6 +11,10 @@ try {
1011
cabal: core.getInput("cabal"),
1112
stack: core.getInput("stack"),
1213
hls: core.getInput("hls"),
14+
config: core.getInput("config")
15+
? (YAML.parse(core.getInput("config")) ??
16+
JSON.parse(core.getInput("config")))
17+
: undefined,
1318
});
1419
} catch (error) {
1520
core.setFailed((error as Error).message);

ghcup/src/main.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ function getStackRoot() {
9191
const hdir = os.homedir();
9292
return stackXdg
9393
? path.join(
94-
process.env["XDG_DATA_HOME"] ?? path.join(hdir, ".local", "share"),
95-
"stack",
96-
)
94+
process.env["XDG_DATA_HOME"] ?? path.join(hdir, ".local", "share"),
95+
"stack",
96+
)
9797
: path.join(hdir, ".stack");
9898
}
9999
})();
@@ -116,12 +116,13 @@ async function installStackHook() {
116116

117117
export type Opts = {
118118
version: string;
119-
release_channels: string[];
119+
release_channels?: string[];
120120
stack_hook: boolean;
121121
ghc?: string;
122122
cabal?: string;
123123
stack?: string;
124124
hls?: string;
125+
config?: string;
125126
};
126127

127128
export async function main(opts: Opts) {
@@ -169,12 +170,21 @@ export async function main(opts: Opts) {
169170
installStackHook();
170171
}
171172

172-
await exec.exec(ghcupPath, [
173-
"config",
174-
"set",
175-
"url-source",
176-
JSON.stringify(opts.release_channels),
177-
]);
173+
if (opts.config) {
174+
await exec.exec(ghcupPath, ["config", "set", JSON.stringify(opts.config)]);
175+
}
176+
177+
if (opts.release_channels && opts.release_channels.length > 0) {
178+
core.warning(
179+
"'release-channels' option is deprecated, use 'config' instead!",
180+
);
181+
await exec.exec(ghcupPath, [
182+
"config",
183+
"set",
184+
"url-source",
185+
JSON.stringify(opts.release_channels),
186+
]);
187+
}
178188

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

0 commit comments

Comments
 (0)