Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit b60d27d

Browse files
author
Jared Weakly
authored
Merge pull request #5 from haskell/updates
Address most of the outstanding issues left over from the actions/setup-haskell -> haskell/actions/setup migration.
2 parents 6d69175 + 0dab3aa commit b60d27d

File tree

12 files changed

+10378
-2751
lines changed

12 files changed

+10378
-2751
lines changed

.github/workflows/workflow.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,49 @@ jobs:
3636
install-haskell:
3737
name: GHC ${{ matrix.ghc }}, Cabal ${{ matrix.cabal }} - ${{ matrix.os }}
3838
runs-on: ${{ matrix.os }}
39+
continue-on-error: ${{ matrix.expect-fail }}
3940
strategy:
40-
fail-fast: false
41+
fail-fast: true
4142
matrix:
4243
os: [ubuntu-latest, macOS-latest, windows-latest]
4344
ghc: ["latest", "8.4.4"]
4445
cabal: ["latest"]
46+
expect-fail: [false]
4547
include:
4648
- os: ubuntu-latest
4749
ghc: "7.10.3"
4850
cabal: "3.0.0.0"
51+
expect-fail: false
4952
- os: ubuntu-latest
5053
ghc: "8.2.2"
5154
cabal: "2.0"
52-
55+
expect-fail: false
56+
- os: ubuntu-latest
57+
ghc: "8.12.0" # A version that will never exist.
58+
expect-fail: true
5359
steps:
5460
- uses: actions/checkout@v2
5561
- uses: ./setup
62+
continue-on-error: ${{ matrix.expect-fail }}
5663
with:
5764
ghc-version: ${{ matrix.ghc }}
5865
cabal-version: ${{ matrix.cabal }}
5966
- run: |
6067
runhaskell --version
6168
runhaskell __tests__/hello.hs
62-
- shell: bash
63-
run: cd __tests__/project && cabal build && cabal run
69+
continue-on-error: ${{ matrix.expect-fail }}
70+
- working-directory: setup/__tests__/project
71+
run: cabal build
72+
continue-on-error: ${{ matrix.expect-fail }}
73+
- working-directory: setup/__tests__/project
74+
run: cabal run
75+
continue-on-error: ${{ matrix.expect-fail }}
6476
- run: |
6577
cabal --version
6678
ghc --version
79+
continue-on-error: ${{ matrix.expect-fail }}
6780
- shell: bash
81+
continue-on-error: ${{ matrix.expect-fail }}
6882
if: matrix.ghc != 'latest'
6983
# this check depends on the ghc versions being "exact" in the matrix
7084
run: |
@@ -81,6 +95,7 @@ jobs:
8195

8296
steps:
8397
- uses: actions/checkout@v2
98+
8499
- uses: ./setup
85100
with:
86101
enable-stack: true

setup/.lintstagedrc.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module.exports = {
2-
'!(*test).{js,ts}': 'eslint --cache --fix',
3-
'!(*test).ts': () => ['ncc build', 'git add dist'],
4-
'src/**/*.ts': () => 'tsc -p tsconfig.json',
5-
'*.{js,ts,json,md}': 'prettier --write'
2+
'setup/!(*test).{js,ts,json}': [
3+
'eslint --cache --fix',
4+
() => 'ncc build',
5+
() => 'git add dist'
6+
],
7+
'setup/src/**/*.ts': () => 'tsc -p tsconfig.json',
8+
'setup/*.{js,ts,json,md}': 'prettier --write'
69
};

setup/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ jobs:
124124
**GHC:**
125125

126126
- `latest` (default, recommended)
127-
- `8.10.1` `8.10`
127+
- `8.10.2` `8.10`
128+
- `8.10.1`
128129
- `8.8.3` `8.8`
129130
- `8.8.2`
130131
- `8.8.1`
@@ -157,7 +158,9 @@ Recommendation: Use the latest available version if possible.
157158
**Stack:**
158159

159160
- `latest` (recommended) -- follows the latest release automatically.
160-
- `2.3.1` `2.3`
161+
- `2.5.1` `2.5`
162+
- `2.3.3` `2.3`
163+
- `2.3.1`
161164
- `2.1.3` `2.1`
162165
- `2.1.1`
163166
- `1.9.3.1` `1.9`
Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
import {getOpts, getDefaults, Tool} from '../src/opts';
1+
import {getOpts, getDefaults} from '../src/opts';
2+
import type {OS, Revisions, Tool} from '../src/opts';
23
import {getInput} from '@actions/core';
34
import * as supported_versions from '../src/versions.json';
5+
import * as rv from '../src/release-revisions.json';
46

5-
const def = getDefaults();
7+
const release_revisions = rv as Revisions;
8+
const def = (os: OS) => getDefaults(os);
69
const latestVersions = {
710
ghc: supported_versions.ghc[0],
811
cabal: supported_versions.cabal[0],
912
stack: supported_versions.stack[0]
1013
};
14+
const latestRevisions = (os: OS) => ({
15+
ghc: release_revisions?.[os]?.ghc?.[0]?.to,
16+
cabal: release_revisions?.[os]?.cabal?.[0]?.to,
17+
stack: release_revisions?.[os]?.stack?.[0]?.to
18+
});
1119

1220
const mkName = (s: string): string =>
1321
`INPUT_${s.replace(/ /g, '_').toUpperCase()}`;
1422

1523
const setupEnv = (o: Record<string, unknown>): void =>
1624
Object.entries(o).forEach(([k, v]) => v && (process.env[mkName(k)] = `${v}`));
1725

18-
const forAll = (fn: (t: Tool) => any) =>
26+
const forAllOS = (fn: (t: OS) => any) =>
27+
(['win32', 'darwin', 'linux'] as const).forEach(fn);
28+
29+
const forAllTools = (fn: (t: Tool) => any) =>
1930
(['ghc', 'cabal', 'stack'] as const).forEach(fn);
2031

2132
describe('haskell/actions/setup', () => {
@@ -30,11 +41,19 @@ describe('haskell/actions/setup', () => {
3041
afterEach(() => (process.env = OLD_ENV));
3142

3243
it('Parses action.yml to get correct default versions', () => {
33-
forAll(t => expect(def[t].version).toBe(latestVersions[t]));
44+
forAllOS(os =>
45+
forAllTools(t =>
46+
expect(def(os)[t].version).toBe(
47+
latestRevisions(os)[t] ?? latestVersions[t]
48+
)
49+
)
50+
);
3451
});
3552

3653
it('Supported versions are parsed from JSON correctly', () =>
37-
forAll(t => expect(def[t].supported).toBe(supported_versions[t])));
54+
forAllOS(os =>
55+
forAllTools(t => expect(def(os)[t].supported).toBe(supported_versions[t]))
56+
));
3857

3958
it('[meta] Setup Env works', () => {
4059
setupEnv({input: 'value'});
@@ -44,58 +63,74 @@ describe('haskell/actions/setup', () => {
4463

4564
it('getOpts grabs defaults correctly from environment', () => {
4665
setupEnv({});
47-
const options = getOpts(def);
48-
forAll(t => expect(options[t].raw).toBe(def[t].version));
66+
forAllOS(os => {
67+
const options = getOpts(def(os), os);
68+
forAllTools(t => expect(options[t].raw).toBe(def(os)[t].version));
69+
});
4970
});
5071

5172
it('Versions resolve correctly', () => {
5273
const v = {ghc: '8.6.5', cabal: '2.4.1.0', stack: '2.1.3'};
5374
setupEnv({
75+
'enable-stack': 'true',
5476
'stack-version': '2.1',
5577
'ghc-version': '8.6',
5678
'cabal-version': '2.4'
5779
});
58-
const options = getOpts(def);
59-
forAll(t => expect(options[t].resolved).toBe(v[t]));
80+
forAllOS(os => {
81+
const options = getOpts(def(os), os);
82+
forAllTools(t => expect(options[t].resolved).toBe(v[t]));
83+
});
6084
});
6185

6286
it('"latest" Versions resolve correctly', () => {
6387
setupEnv({
88+
'enable-stack': 'true',
6489
'stack-version': 'latest',
6590
'ghc-version': 'latest',
6691
'cabal-version': 'latest'
6792
});
68-
const options = getOpts(def);
69-
forAll(t => expect(options[t].resolved).toBe(latestVersions[t]));
93+
forAllOS(os => {
94+
const options = getOpts(def(os), os);
95+
forAllTools(t =>
96+
expect(options[t].resolved).toBe(
97+
latestRevisions(os)[t] ?? latestVersions[t]
98+
)
99+
);
100+
});
70101
});
71102

72103
it('Enabling stack does not disable GHC or Cabal', () => {
73104
setupEnv({'enable-stack': 'true'});
74-
const {ghc, cabal, stack} = getOpts(def);
75-
expect({
76-
ghc: ghc.enable,
77-
stack: stack.enable,
78-
cabal: cabal.enable
79-
}).toStrictEqual({ghc: true, cabal: true, stack: true});
105+
forAllOS(os => {
106+
const {ghc, cabal, stack} = getOpts(def(os), os);
107+
expect({
108+
ghc: ghc.enable,
109+
stack: stack.enable,
110+
cabal: cabal.enable
111+
}).toStrictEqual({ghc: true, cabal: true, stack: true});
112+
});
80113
});
81114

82115
it('Enabling stack-no-global disables GHC and Cabal', () => {
83116
setupEnv({'enable-stack': 'true', 'stack-no-global': 'true'});
84-
const {ghc, cabal, stack} = getOpts(def);
85-
expect({
86-
ghc: ghc.enable,
87-
cabal: cabal.enable,
88-
stack: stack.enable
89-
}).toStrictEqual({ghc: false, cabal: false, stack: true});
117+
forAllOS(os => {
118+
const {ghc, cabal, stack} = getOpts(def(os), os);
119+
expect({
120+
ghc: ghc.enable,
121+
cabal: cabal.enable,
122+
stack: stack.enable
123+
}).toStrictEqual({ghc: false, cabal: false, stack: true});
124+
});
90125
});
91126

92127
it('Enabling stack-no-global without setting enable-stack errors', () => {
93128
setupEnv({'stack-no-global': 'true'});
94-
expect(() => getOpts(def)).toThrow();
129+
forAllOS(os => expect(() => getOpts(def(os), os)).toThrow());
95130
});
96131

97132
it('Enabling stack-setup-ghc without setting enable-stack errors', () => {
98133
setupEnv({'stack-setup-ghc': 'true'});
99-
expect(() => getOpts(def)).toThrow();
134+
forAllOS(os => expect(() => getOpts(def(os), os)).toThrow());
100135
});
101136
});

0 commit comments

Comments
 (0)