Giter Site home page Giter Site logo

setup's Introduction

haskell-actions/setup

GitHub Actions status

This action sets up a Haskell environment for use in actions by:

  • if requested, installing a version of ghc and cabal and adding them to PATH,
  • if requested, installing a version of Stack and adding it to the PATH,
  • outputting of ghc-version/exe/path, cabal-version/exe/path, stack-version/exe/path, stack-root and cabal-store (for the requested components).

The GitHub runners come with pre-installed versions of GHC and Cabal. Those will be used whenever possible. For all other versions, this action utilizes ppa:hvr/ghc, ghcup, and chocolatey.

Usage

See action.yml

Minimal

on: [push]
name: build
jobs:
  runhaskell:
    name: Hello World
    runs-on: ubuntu-latest # or macOS-latest, or windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: haskell-actions/setup@v2
      - run: runhaskell Hello.hs

Basic

on: [push]
name: build
jobs:
  runhaskell:
    name: Hello World
    runs-on: ubuntu-latest # or macOS-latest, or windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: haskell-actions/setup@v2
        with:
          ghc-version: '8.8' # Resolves to the latest point release of GHC 8.8
          cabal-version: '3.0.0.0' # Exact version of Cabal
      - run: runhaskell Hello.hs

Basic with Stack

on: [push]
name: build
jobs:
  runhaskell:
    name: Hello World
    runs-on: ubuntu-latest # or macOS-latest, or windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: haskell-actions/setup@v2
        with:
          ghc-version: '8.8.4' # Exact version of ghc to use
          # cabal-version: 'latest'. Omitted, but defaults to 'latest'
          enable-stack: true
          stack-version: 'latest'
      - run: runhaskell Hello.hs

Matrix Testing

on: [push]
name: build
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        ghc: ['8.6.5', '8.8.4']
        cabal: ['2.4.1.0', '3.0.0.0']
        os: [ubuntu-latest, macOS-latest, windows-latest]
        exclude:
          # GHC 8.8+ only works with cabal v3+
          - ghc: 8.8.4
            cabal: 2.4.1.0
    name: Haskell GHC ${{ matrix.ghc }} sample
    steps:
      - uses: actions/checkout@v4
      - name: Setup Haskell
        uses: haskell-actions/setup@v2
        with:
          ghc-version: ${{ matrix.ghc }}
          cabal-version: ${{ matrix.cabal }}
      - run: runhaskell Hello.hs

Model cabal workflow with caching

name: build
on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

# INFO: The following configuration block ensures that only one build runs per branch,
# which may be desirable for projects with a costly build process.
# Remove this block from the CI workflow to let each CI job run to completion.
concurrency:
  group: build-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        ghc-version: ['9.8', '9.6', '9.4', '9.2', '9.0']

        include:
          - os: windows-latest
            ghc-version: '9.8'
          - os: macos-latest
            ghc-version: '9.8'

    steps:
      - uses: actions/checkout@v4

      - name: Set up GHC ${{ matrix.ghc-version }}
        uses: haskell-actions/setup@v2
        id: setup
        with:
          ghc-version: ${{ matrix.ghc-version }}
          # Defaults, added for clarity:
          cabal-version: 'latest'
          cabal-update: true

      - name: Configure the build
        run: |
          cabal configure --enable-tests --enable-benchmarks --disable-documentation
          cabal build all --dry-run
        # The last step generates dist-newstyle/cache/plan.json for the cache key.

      - name: Restore cached dependencies
        uses: actions/cache/restore@v4
        id: cache
        env:
          key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
        with:
          path: ${{ steps.setup.outputs.cabal-store }}
          key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
          restore-keys: ${{ env.key }}-

      - name: Install dependencies
        # If we had an exact cache hit, the dependencies will be up to date.
        if: steps.cache.outputs.cache-hit != 'true'
        run: cabal build all --only-dependencies

      # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
      - name: Save cached dependencies
        uses: actions/cache/save@v4
        # If we had an exact cache hit, trying to save the cache would error because of key clash.
        if: steps.cache.outputs.cache-hit != 'true'
        with:
          path: ${{ steps.setup.outputs.cabal-store }}
          key: ${{ steps.cache.outputs.cache-primary-key }}

      - name: Build
        run: cabal build all

      - name: Run tests
        run: cabal test all

      - name: Check cabal file
        run: cabal check

      - name: Build documentation
        run: cabal haddock all

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 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.

Outputs

The action outputs parameters for the components it installed. E.g. if ghc-version: 8.10 is requested, the action will output ghc-version: 8.10.7 if installation succeeded, and ghc-exe and ghc-path will be set accordingly. (Details on version resolution see next section.)

Name Description Type
ghc-version The resolved version of ghc string
cabal-version The resolved version of cabal string
stack-version The resolved version of stack string
ghc-exe The path of the ghc executable string
cabal-exe The path of the cabal executable string
stack-exe The path of the stack executable string
ghc-path The path of the ghc executable directory string
cabal-path The path of the cabal executable directory string
stack-path The path of the stack executable directory string
cabal-store The path to the cabal store string
stack-root The path to the stack root (equal to the STACK_ROOT environment variable if it is set; otherwise an OS-specific default) string

Version Support

This action is conscious about the tool versions specified in versions.json. This list is replicated (hopefully correctly) below.

Versions specified by the inputs, e.g. ghc-version, are resolved against this list, by taking the first entry from the list if latest is requested, or the first entry that matches exactly, or otherwise the first entry that is a (string-)extension of the requested version extended by a .. E.g., 8.10 will be resolved to 8.10.7, and so will 8.

GHC:

  • latest-nightly (requires the resp. ghcup-release-channel, e.g. https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml)
  • latest (default)
  • 9.10.1 9.10
  • 9.8.2 9.8
  • 9.8.1
  • 9.6.5 9.6
  • 9.6.4
  • 9.6.3
  • 9.6.2
  • 9.6.1
  • 9.4.8 9.4
  • 9.4.7
  • 9.4.6
  • 9.4.5
  • 9.4.4
  • 9.4.3
  • 9.4.2
  • 9.4.1
  • 9.2.8 9.2
  • 9.2.7
  • 9.2.6
  • 9.2.5
  • 9.2.4
  • 9.2.3
  • 9.2.2
  • 9.2.1
  • 9.0.2 9.0
  • 9.0.1
  • 8.10.7 8.10
  • 8.10.6
  • 8.10.5
  • 8.10.4
  • 8.10.3
  • 8.10.2
  • 8.10.1
  • 8.8.4 8.8
  • 8.8.3
  • 8.8.2
  • 8.8.1
  • 8.6.5 8.6
  • 8.6.4
  • 8.6.3
  • 8.6.2
  • 8.6.1
  • 8.4.4 8.4
  • 8.4.3
  • 8.4.2
  • 8.4.1
  • 8.2.2 8.2
  • 8.0.2 8.0
  • 7.10.3 7.10 (deprecated, not on ubuntu-22.04 or up)

Suggestion: Try to support at least the three latest major versions of GHC.

Cabal:

  • head (the cabal-head release of the most recent build of the master branch)
  • latest (default, recommended)
  • 3.10.3.0 3.10
  • 3.10.2.1
  • 3.10.2.0
  • 3.10.1.0
  • 3.8.1.0 3.8
  • 3.6.2.0 3.6
  • 3.6.0.0
  • 3.4.1.0 3.4
  • 3.4.0.0
  • 3.2.0.0 3.2
  • 3.0.0.0 3.0
  • 2.4.1.0 2.4

Recommendation: Use the latest available version if possible.

Stack: (with enable-stack: true)

  • latest (default, recommended)
  • 2.15.7 2.15
  • 2.15.5
  • 2.15.3
  • 2.15.1
  • 2.13.1 2.13
  • 2.11.1 2.11
  • 2.9.3 2.9
  • 2.9.1
  • 2.7.5 2.7
  • 2.7.3
  • 2.7.1
  • 2.5.1 2.5
  • 2.3.3 2.3
  • 2.3.1
  • 2.1.3 2.1
  • 2.1.1
  • 1.9.3.1 1.9
  • 1.9.1.1
  • 1.7.1 1.7
  • 1.6.5 1.6
  • 1.6.3.1
  • 1.6.1.1
  • 1.5.1 1.5
  • 1.5.0
  • 1.4.0 1.4
  • 1.3.2 1.3
  • 1.3.0
  • 1.2.0 1.2

Recommendation: Use the latest available version if possible.

Beyond the officially supported listed versions above, you can request any precise version of GHC, Cabal, and Stack. The action will forward the request to the install methods (apt, ghcup, choco), and installation might succeed.

Note however that Chocolatey's version numbers might differ from the official ones, please consult their pages for GHC and Cabal.

License

The scripts and documentation in this project are released under the MIT License.

Contributions

Contributions are welcome! See the Contributor's Guide.

setup's People

Contributors

alexbiehl avatar andreasabel avatar anton-latukha avatar brandonchinn178 avatar dependabot[bot] avatar donatello avatar elopez avatar hazelweakly avatar jhrcek avatar jneira avatar kleidukos avatar ludat avatar luispedro avatar lukel97 avatar mihaimaruseac avatar msakai avatar newhoggy avatar nlander avatar omelkonian avatar rethab avatar rhendric avatar rufflewind avatar rwe avatar ryanglscott avatar sestrella avatar simmsb avatar sorki avatar tclem avatar ulysses4ever avatar wismill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

setup's Issues

M1 (aarch64 darwin) runner support

Hi! GitHub announced M1 runners today: https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/

I tried using this action on one of our repositories (with runs-on: macos-latest-xlarge) but it seems that ghcup chooses to install an intel build for some reason, even though there's an aarch64 one available on the yml metadata. Ideally I would expect it would install the native version of the tools when available. Do you have any idea about what might be going on? Thanks!

Run haskell-actions/setup@v2
  with:
    ghc-version: 9.2
    enable-stack: true
    stack-version: latest
    cabal-version: latest
    cabal-update: true
  env:
    CACHE_VERSION: v6
  
Preparing to setup a Haskell environment
Resolved ghc 9.2 to 9.2.8
Resolved cabal latest to 3.10.1.0
Resolved stack latest to 2.13.1
Preparing ghc environment
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup unset ghc
  [ Info  ] GHC successfully unset
Installing ghc version 9.2.8
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup whereis ghc 9.2.8
  [ Error ] [�
  
  
  Attempting to access tool ghc at location /Users/runner/.ghcup/bin
  Succeeded accessing tool ghc at location /Users/runner/.ghcup/bin
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup set ghc 9.2.8
  [ Info  ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.7.yaml as file /Users/runner/.ghcup/cache/ghcup-0.0.7.yaml
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
  
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  100  306k  100  306k    0     0  4908k      0 --:--:-- --:--:-- --:--:-- 5673k
  [ Error ] [�
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup unset ghc
  [ Info  ] GHC successfully unset
  Attempting to install ghc 9.2.8 using ghcup
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup install ghc 9.2.8
  [ Info  ] downloading: https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-x86_64-apple-darwin.tar.xz as file /Users/runner/.ghcup/tmp/ghcup-95ebcf9d9beaedd5/ghc-9.2.8-x86_64-apple-darwin.tar.xz
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
  
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
   40  169M   40 68.1M    0     0  79.0M      0  0:00:02 --:--:--  0:00:02 79.3M
   84  169M   84  144M    0     0  78.3M      0  0:00:02  0:00:01  0:00:01 78.4M
  100  169M  100  169M    0     0  78.3M      0  0:00:02  0:00:02 --:--:-- 78.5M
  [ Info  ] verifying digest of: ghc-9.2.8-x86_64-apple-darwin.tar.xz
  [ Info  ] Unpacking: ghc-9.2.8-x86_64-apple-darwin.tar.xz to /Users/runner/.ghcup/tmp/ghcup-760615249947cfaa
  [ Info  ] Installing GHC (this may take a while)
  
  
 
  
  
  [ Info  ] Merging file tree from "/Users/runner/.ghcup/tmp/ghcup-4819e735bb1f57fa/Users/runner/.ghcup/ghc/9.2.8" to "/Users/runner/.ghcup/ghc/9.2.8"
  [ Info  ] GHC installation successful
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup set ghc 9.2.8
  [ Warn  ] New ghc version available. If you want to install this latest version, run 'ghcup install ghc 9.6.3'
  [ Info  ] GHC 9.2.8 successfully set as default version
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup whereis ghc 9.2.8
  /Users/runner/.ghcup/ghc/9.2.8/bin/ghc
  
  Attempting to access tool ghc at location /Users/runner/.ghcup/bin
  Succeeded accessing tool ghc at location /Users/runner/.ghcup/bin
  /Users/runner/hostedtoolcache/ghcup/0.1.19.5/arm64/ghcup set ghc 9.2.8
  [ Warn  ] New ghc version available. If you want to install this latest version, run 'ghcup install ghc 9.6.3'
  [ Info  ] GHC 9.2.8 successfully set as default version
  Found ghc 9.2.8 in cache at path /Users/runner/.ghcup/bin. Setup successful.

(full log here)

XDG: Broken cabal installation in macos 20240105 GHA runners

These macos runners come with existing XDG directories for cabal. Since the start of the runner, the following files are present:

  • .config/cabal/config
  • .cache/cabal/packages/...

In this haskell-actions/setup there is a deliberate choice (decided in haskell/actions#210) to create ~/.cabal/bin (here) in order to disable XDG, however, cabal will still think it is using XDG because of the existence of ~/.config/cabal. See this logic.

I do not know which one should be the path forward:

  1. This action relocates/deletes those files in the MacOS runners if they exist.
  2. This action deletes those files in all runners if they exist to disable XDG always.
  3. Users of this action should take care of this when using MacOS runners.
  4. The MacOS runners should not create those files in the first place.
  5. The logic in Cabal should be made more accurate to even deal with cases where ~/.cabal and ~/.config/cabal/config exist but not ~/.cabal/config (as is happening here).

The 20240105 image is still very new, only 9.79% of rollout progress as I'm writing this, but this still has resulted in CI pipelines failing for example in Cabal itself. 1 2 and more if you look at the Validate workflow.

Bump node.js to 20?

When using haskell-actions/[email protected] (for example https://github.com/tomjaguarpaw/tomland/actions/runs/8231453913) I get the warning

Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: haskell-actions/[email protected]. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

Perhaps this needs to be changed to 20?

node-version: "16"

LLVM errors when building on `macOS-latest` with `ghc-{8.10,9.0}`.

Hi there!

I'm not sure whether this is an issue with haskell-actions per se, but I thought it worth recording in case others are also running into the same issue.

Affected OS, GHC, and cabal version combinations

macOS-latest windows-latest ubuntu-latest
ghc-8.10 🔴 affected 🟢 unaffected 🟢 unaffected
ghc-9.0 🔴 affected 🟢 unaffected 🟢 unaffected
ghc-9.2 🟢 unaffected 🟢 unaffected 🟢 unaffected
ghc-9.4 🟢 unaffected 🟢 unaffected 🟢 unaffected
ghc-9.6 🟢 unaffected 🟢 unaffected 🟢 unaffected
ghc-9.8 🟢 unaffected 🟢 unaffected 🟢 unaffected

Building with cabal-3.10.3.0.

Known workarounds

  • Use macOS-13 instead of macOS-latest.

Issue

On affected OS platform and GHC versions, there are LLVM-related build failures similar to the following:

> cabal build all --builddir=b --only-dependencies
Building     StateVar-1.2.2 (lib)
Configuring library for StateVar-1.2.2..
Preprocessing library for StateVar-1.2.2..
Building library for StateVar-1.2.2..

<no location info>: error:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM between [9 and 13)
[1 of 1] Compiling Data.StateVar    ( src/Data/StateVar.hs, dist/build/Data/StateVar.o, dist/build/Data/StateVar.dyn_o )

<no location info>: error:
    Warning: Couldn't figure out LLVM version!
             Make sure you have installed LLVM between [9 and 13)
ghc: could not execute: opt 

Note that the LLVM error appears for whatever dependency cabal is attempting to build first. (It's not specific to StateVar.)

Example action failures

musl libc support?

It would be great if there was a way to specify musl as libc for the build, so that the CI could produce statically linked executables that could be ran on any distro, without regard to the libc sort and version used (that is a problem with glibc).

Add v2 tag?

The README references haskell-actions/setup@v2, but the repo doesn't have a v2 tag

Expose GHCup binary location as action output

vscode-haskell needs direct access to ghcup to run its test successfully. Until recently, ghcup was always on $PATH and we could simply run ghcup install ... and install all the binaries that we needed. Additionally, the tests themselves also call ghcup install.

However, this seems to have changed recently for macos-latest: https://github.com/haskell/vscode-haskell/actions/runs/9015398738/job/24769933756?pr=1077

It looks like ghcup is not on the $PATH any more, but hidden somewhere in the hostedtoolcache.

One way to work around this for good, is to provide the path to ghcup as an action output, then we don't have to rely on ghcup to be on the $PATH, and can find it reliably.

Fix HEAD and/or support GHC nightlies

Using ghc_version: head breaks; this URL is a 404:

'https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-deb9-linux-integer-simple.tar.xz?job=validate-x86_64-linux-deb9-integer-simple',

It would be great for one of the following to occur:

  1. Fix the URL (e.g. https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-fedora33-release.tar.xz?job=x86_64-linux-fedora33-release)
  2. Enable GHCup's nightly feature: https://discourse.haskell.org/t/ann-ghcup-0-1-19-3-released/6749

It seems like all that's needed for (2) is to upgrade GHCup installed by this action to 0.1.19.3 + set

ghc-version: latest-nightly
ghcup-release-channel: https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml

Add cabal-install 3.10.2.1

The current latest, provided by this action, is 3.10.2.0, which has an unfortunate bug in its --version interface.

Is it possible to install two GHC versions (and two Cabal versions)?

Is it possible to install two GHC versions (and two Cabal versions1)? I encountered a situation where I want to build a project with ghc-9.8.2 and cabal-install-3.10.3.0 but to get there I need to first run a Stack script that needs other versions installed. Stack will do that for me but it takes a long time, about 10 mins on Github's runners.

#!/usr/bin/env stack
-- stack script --resolver=lts-18.27 --package=base --package=dhall --package=filepath --package=text

Stackage snapshot LTS 18.27 specifies GHC 8.10.7. GHC 8.10.7's Cabal boot library is Cabal-3.2.1.0.
From commercialhaskell/stack#6588 (comment)

Footnotes

  1. I'm not sure exactly what Stack needs to get going here, perhaps it is just ghc-8.10.7 with included Cabal boot library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.