Verify Cabal functionality for various installs
This patch adds functionality to * Test cabal build and cabal run in the CI workflow * Test GHC 7.10.3 on Linux and ensures that it works * On Linux, try hvr's PPA before ghcup
This commit is contained in:
12
.github/workflows/workflow.yml
vendored
12
.github/workflows/workflow.yml
vendored
@@ -2,9 +2,10 @@ name: Main workflow
|
||||
on: [push]
|
||||
jobs:
|
||||
test:
|
||||
name: Test ${{ matrix.os }}
|
||||
name: Unit Tests - ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
steps:
|
||||
@@ -17,9 +18,10 @@ jobs:
|
||||
- run: npm run pre-push
|
||||
|
||||
install-haskell:
|
||||
name: Test GHC Install ${{ matrix.os }}
|
||||
name: GHC ${{ matrix.ghc }}, Cabal ${{ matrix.cabal }} - ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
ghc: ['8.8.3', '8.4.4']
|
||||
@@ -33,7 +35,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/cache@v1
|
||||
if: matrix.os == 'macOS-latest' || matrix.ghc == '7.10.3'
|
||||
if: matrix.os == 'macOS-latest'
|
||||
with:
|
||||
path: ~/.ghcup
|
||||
key: ${{ runner.os }}-${{ matrix.ghc }}-ghcup
|
||||
@@ -43,9 +45,11 @@ jobs:
|
||||
ghc-version: ${{ matrix.ghc }}
|
||||
cabal-version: ${{ matrix.cabal }}
|
||||
- run: runhaskell __tests__/hello.hs
|
||||
- shell: bash
|
||||
run: cd __tests__/project && cabal build && cabal run
|
||||
|
||||
install-stack:
|
||||
name: Test Stack Install ${{ matrix.os }}
|
||||
name: Stack ${{ matrix.stack }} ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -97,3 +97,5 @@ Thumbs.db
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
lib/**/*
|
||||
|
||||
dist-newstyle
|
||||
|
||||
4
__tests__/project/Main.hs
Normal file
4
__tests__/project/Main.hs
Normal file
@@ -0,0 +1,4 @@
|
||||
module Main where
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello, Haskell!"
|
||||
2
__tests__/project/Setup.hs
Normal file
2
__tests__/project/Setup.hs
Normal file
@@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
9
__tests__/project/project.cabal
Normal file
9
__tests__/project/project.cabal
Normal file
@@ -0,0 +1,9 @@
|
||||
cabal-version: >=1.10
|
||||
name: project
|
||||
version: 0.1.0.0
|
||||
build-type: Simple
|
||||
|
||||
executable project
|
||||
main-is: Main.hs
|
||||
build-depends: base
|
||||
default-language: Haskell2010
|
||||
22
dist/index.js
vendored
22
dist/index.js
vendored
@@ -8640,21 +8640,33 @@ async function installStack(version) {
|
||||
exports.installStack = installStack;
|
||||
async function installTool(tool, version) {
|
||||
core.startGroup(`Installing ${tool}`);
|
||||
// Currently only linux comes pre-installed with some versions of GHC.
|
||||
// They're intalled to /opt. Let's see if we can save ourselves a download
|
||||
// Linux comes pre-installed with some versions of GHC and supports older
|
||||
// versions through hvr's PPA.
|
||||
if (process.platform === 'linux') {
|
||||
// Cabal is installed to /opt/cabal/x.x but cabal's full version is X.X.Y.Z
|
||||
const v = tool === 'cabal' ? version.slice(0, 3) : version;
|
||||
const p = path_1.join('/opt', tool, v, 'bin');
|
||||
const installed = await fs_1.promises
|
||||
.access(p)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
if (tool === 'ghc' && !installed) {
|
||||
try {
|
||||
// hvr's PPA has better support for GHC < 8.0
|
||||
await exec_1.exec(`sudo -- sh -c "apt-get -y install ghc-${v}"`);
|
||||
}
|
||||
catch {
|
||||
// oh well, we tried
|
||||
}
|
||||
}
|
||||
try {
|
||||
const p = path_1.join('/opt', tool, v, 'bin');
|
||||
await fs_1.promises.access(p);
|
||||
core.debug(`Using pre-installed ${tool} ${version}`);
|
||||
core.addPath(p);
|
||||
core.endGroup();
|
||||
return;
|
||||
}
|
||||
catch {
|
||||
// oh well, we tried
|
||||
// ok, let's try the generic install now
|
||||
}
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
|
||||
@@ -113,20 +113,34 @@ export async function installStack(version: string): Promise<void> {
|
||||
type Tool = 'cabal' | 'ghc';
|
||||
async function installTool(tool: Tool, version: string): Promise<void> {
|
||||
core.startGroup(`Installing ${tool}`);
|
||||
// Currently only linux comes pre-installed with some versions of GHC.
|
||||
// They're intalled to /opt. Let's see if we can save ourselves a download
|
||||
// Linux comes pre-installed with some versions of GHC and supports older
|
||||
// versions through hvr's PPA.
|
||||
if (process.platform === 'linux') {
|
||||
// Cabal is installed to /opt/cabal/x.x but cabal's full version is X.X.Y.Z
|
||||
const v = tool === 'cabal' ? version.slice(0, 3) : version;
|
||||
|
||||
const p = join('/opt', tool, v, 'bin');
|
||||
const installed = await fs
|
||||
.access(p)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
if (tool === 'ghc' && !installed) {
|
||||
try {
|
||||
// hvr's PPA has better support for GHC < 8.0
|
||||
await exec(`sudo -- sh -c "apt-get -y install ghc-${v}"`);
|
||||
} catch {
|
||||
// oh well, we tried
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const p = join('/opt', tool, v, 'bin');
|
||||
await fs.access(p);
|
||||
core.debug(`Using pre-installed ${tool} ${version}`);
|
||||
core.addPath(p);
|
||||
core.endGroup();
|
||||
return;
|
||||
} catch {
|
||||
// oh well, we tried
|
||||
// ok, let's try the generic install now
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user