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

Support GHC nightly #20

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
plan:
# Nightly releases
- ghc: latest-nightly
cabal: latest
# Latest releases
- ghc: latest
cabal: latest
Expand Down Expand Up @@ -90,13 +93,29 @@ jobs:
# and of cabal just 2.4, 3.0, 3.2, 3.4
# according to https://launchpad.net/~hvr/+archive/ubuntu/ghc?field.series_filter=focal

# Test ghcup pre-release channel
# Any matrix combinations with latest-nightly should add the appropriate release channel
- plan:
ghc: latest-nightly
ghcup_release_channels: |
https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml

# Test deprecated release channel still works for now
- os: ubuntu-latest
ghcup_release_channel: "https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml"
plan:
ghc: "9.6.0.20230111"
cabal: "3.8"

# Test ghcup release channels
- os: ubuntu-latest
ghcup_release_channels: |
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml
https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.7.yaml
plan:
ghc: "9.6.0.20230111"
cabal: "3.8"

# setup does something special for 7.10.3 (issue #79)
- os: ubuntu-20.04
plan:
Expand Down Expand Up @@ -143,6 +162,7 @@ jobs:
with:
ghc-version: ${{ matrix.plan.ghc }}
ghcup-release-channel: ${{ matrix.ghcup_release_channel }}
ghcup-release-channels: ${{ matrix.ghcup_release_channels }}
cabal-version: ${{ matrix.plan.cabal }}
cabal-update: ${{ matrix.cabal_update }}

Expand Down
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,33 @@ jobs:

## Inputs

| Name | Description | Type | Default |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------- |
| `ghc-version` | GHC version to use, e.g. `9.2` or `9.2.5`. | `string` | `latest` |
| `cabal-version` | Cabal version to use, e.g. `3.6`. | `string` | `latest` |
| `stack-version` | Stack version to use, e.g. `latest`. Stack will only be installed if `enable-stack` is set. | `string` | `latest` |
| `enable-stack` | If set, will setup Stack. | "boolean" | false/unset |
| `stack-no-global` | If set, `enable-stack` must be set. Prevents installing GHC and Cabal globally. | "boolean" | false/unset |
| `stack-setup-ghc` | If set, `enable-stack` must be set. Runs stack setup to install the specified GHC. (Note: setting this does _not_ imply `stack-no-global`.) | "boolean" | false/unset |
| `disable-matcher` | If set, disables match messages from GHC as GitHub CI annotations. | "boolean" | false/unset |
| `cabal-update` | If set to `false`, skip `cabal update` step. | `boolean` | `true` |
| `ghcup-release-channel` | If set, add a [release channel](https://www.haskell.org/ghcup/guide/#pre-release-channels) to ghcup. | `URL` | none |

Note: "boolean" types are set/unset, not true/false.
That is, setting any "boolean" to a value other than the empty string (`""`) will be considered true/set.
However, to avoid confusion and for forward compatibility, it is still recommended to **only use value `true` to set a "boolean" flag.**

In contrast, a proper `boolean` input like `cabal-update` only accepts values `true` and `false`.
| Name | Description | Type | Default |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------- |
| `ghc-version` | GHC version to use, e.g. `9.2` or `9.2.5`. | `string` | `latest` |
| `cabal-version` | Cabal version to use, e.g. `3.6`. | `string` | `latest` |
| `stack-version` | Stack version to use, e.g. `latest`. Stack will only be installed if `enable-stack` is set. | `string` | `latest` |
| `enable-stack` | If set, will setup Stack. | `Toggle` | false/unset |
| `stack-no-global` | If set, `enable-stack` must be set. Prevents installing GHC and Cabal globally. | `Toggle` | false/unset |
| `stack-setup-ghc` | If set, `enable-stack` must be set. Runs stack setup to install the specified GHC. (Note: setting this does _not_ imply `stack-no-global`.) | `Toggle` | false/unset |
| `disable-matcher` | If set, disables match messages from GHC as GitHub CI annotations. | `Toggle` | false/unset |
| `cabal-update` | If set to `false`, skip `cabal update` step. | `boolean` | `true` |
| `ghcup-release-channels` | If set, add [release channels](https://www.haskell.org/ghcup/guide/#pre-release-channels) to ghcup. | `URL[]` | none |

Notes:

- `Toggle` inputs are booleans that are false when set as the empty string and true when set to _anything_.
However, to avoid confusion and for forward compatibility, it is still recommended to **only use value `true` to set a `Toggle` input.**

- Inputs that can take multiple values (like `ghcup-release-channels`) should be specified as a multiline list, e.g.

```yaml
- uses: haskell-actions/setup@v2
with:
ghcup-release-channels: |
https://example.com/channel1
https://example.com/channel2
https://example.com/channel3
```

## Outputs

Expand Down Expand Up @@ -236,6 +246,8 @@ E.g., `8.10` will be resolved to `8.10.7`, and so will `8`.

**GHC:**

- `latest-nightly`
- This requires adding https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml to `ghcup-release-channels`
- `latest` (default)
- `9.6.2` `9.6`
- `9.6.1`
Expand Down
40 changes: 20 additions & 20 deletions __tests__/find-haskell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('haskell/actions/setup', () => {
it('Setting disable-matcher to true disables matcher', () => {
forAllOS(os => {
const options = getOpts(def(os), os, {
'disable-matcher': 'true'
disableMatcher: true
});
expect(options.general.matcher.enable).toBe(false);
});
Expand All @@ -70,10 +70,10 @@ describe('haskell/actions/setup', () => {
const v = {ghc: '8.6.5', cabal: '3.4.1.0', stack: '1.9.3'};
forAllOS(os => {
const options = getOpts(def(os), os, {
'enable-stack': 'true',
'stack-version': '1',
'ghc-version': '8.6',
'cabal-version': '3.4'
enableStack: true,
stackVersion: '1',
ghcVersion: '8.6',
cabalVersion: '3.4'
});
forAllTools(t => expect(options[t].resolved).toBe(v[t]));
});
Expand All @@ -82,10 +82,10 @@ describe('haskell/actions/setup', () => {
it('"latest" Versions resolve correctly', () => {
forAllOS(os => {
const options = getOpts(def(os), os, {
'enable-stack': 'true',
'stack-version': 'latest',
'ghc-version': 'latest',
'cabal-version': 'latest'
enableStack: true,
stackVersion: 'latest',
ghcVersion: 'latest',
cabalVersion: 'latest'
});
forAllTools(t =>
expect(options[t].resolved).toBe(
Expand All @@ -100,10 +100,10 @@ describe('haskell/actions/setup', () => {
const v = {ghc: '8.10.7', cabal: '2.4.1.0', stack: '2.1.3'};
forAllOS(os => {
const options = getOpts(def(os), os, {
'enable-stack': 'true',
'stack-version': '2.1',
'ghc-version': '8.10',
'cabal-version': '2'
enableStack: true,
stackVersion: '2.1',
ghcVersion: '8.10',
cabalVersion: '2'
});
forAllTools(t => expect(options[t].resolved).toBe(v[t]));
});
Expand All @@ -112,7 +112,7 @@ describe('haskell/actions/setup', () => {
it('Enabling stack does not disable GHC or Cabal', () => {
forAllOS(os => {
const {ghc, cabal, stack} = getOpts(def(os), os, {
'enable-stack': 'true'
enableStack: true
});
expect({
ghc: ghc.enable,
Expand All @@ -125,20 +125,20 @@ describe('haskell/actions/setup', () => {
it('Resolves revisions correctly on Windows', () => {
// Test the case where there is a revision in chocolatey
expect(
getOpts(def('win32'), 'win32', {'ghc-version': '8.10.2'}).ghc.resolved
getOpts(def('win32'), 'win32', {ghcVersion: '8.10.2'}).ghc.resolved
).toBe('8.10.2'); // Andreas, 2022-12-29: revisions are handled locally in choco() now

// Test the case where there is not a revision in chocolatey
expect(
getOpts(def('win32'), 'win32', {'ghc-version': '8.8.1'}).ghc.resolved
getOpts(def('win32'), 'win32', {ghcVersion: '8.8.1'}).ghc.resolved
).toBe('8.8.1');
});

it('Enabling stack-no-global disables GHC and Cabal', () => {
forAllOS(os => {
const {ghc, cabal, stack} = getOpts(def(os), os, {
'enable-stack': 'true',
'stack-no-global': 'true'
enableStack: true,
stackNoGlobal: true
});
expect({
ghc: ghc.enable,
Expand All @@ -150,13 +150,13 @@ describe('haskell/actions/setup', () => {

it('Enabling stack-no-global without setting enable-stack errors', () => {
forAllOS(os =>
expect(() => getOpts(def(os), os, {'stack-no-global': 'true'})).toThrow()
expect(() => getOpts(def(os), os, {stackNoGlobal: true})).toThrow()
);
});

it('Enabling stack-setup-ghc without setting enable-stack errors', () => {
forAllOS(os =>
expect(() => getOpts(def(os), os, {'stack-setup-ghc': 'true'})).toThrow()
expect(() => getOpts(def(os), os, {stackNoGlobal: true})).toThrow()
);
});
});
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: 'GitHub'
inputs:
ghc-version:
required: false
description: 'Version of GHC to use. If set to "latest", it will always get the latest stable version. If set to "head", it will always get the latest build of GHC.'
description: 'Version of GHC to use. If set to "latest", it will always get the latest stable version. If set to "latest-nightly", it will always get the latest nightly version of GHC'
default: 'latest'
cabal-version:
required: false
Expand All @@ -30,9 +30,12 @@ inputs:
# Note: 'cabal-update' only accepts 'true' and 'false' as values.
# This is different from the other flags ('enable-stack', 'disable-matcher' etc.)
# which are true as soon as they are not null.
ghcup-release-channels:
required: false
description: "Release channel URLs to add to ghcup via `ghcup config add-release-channel`, as a multiline string"
ghcup-release-channel:
required: false
description: "A release channel URL to add to ghcup via `ghcup config add-release-channel`."
description: "Deprecated by ghcup-release-channels."
disable-matcher:
required: false
description: 'If specified, disables match messages from GHC as GitHub CI annotations.'
Expand Down
Loading