diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 80d6034..714a9b0 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -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: diff --git a/.gitignore b/.gitignore index 4ecb7a9..43e49b1 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,5 @@ Thumbs.db # Ignore built ts files __tests__/runner/* lib/**/* + +dist-newstyle diff --git a/__tests__/project/Main.hs b/__tests__/project/Main.hs new file mode 100644 index 0000000..65ae4a0 --- /dev/null +++ b/__tests__/project/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = putStrLn "Hello, Haskell!" diff --git a/__tests__/project/Setup.hs b/__tests__/project/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/__tests__/project/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/__tests__/project/project.cabal b/__tests__/project/project.cabal new file mode 100644 index 0000000..b6db4d0 --- /dev/null +++ b/__tests__/project/project.cabal @@ -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 diff --git a/dist/index.js b/dist/index.js index 1341984..fdee03c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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') { diff --git a/src/installer.ts b/src/installer.ts index 59d8804..8006cbf 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -113,20 +113,34 @@ export async function installStack(version: string): Promise { type Tool = 'cabal' | 'ghc'; async function installTool(tool: Tool, version: string): Promise { 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 } }