Giter Club home page Giter Club logo

get-tested's Introduction

get-tested

A CLI tool that retrieves the tested-with stanza of a cabal file and formats it in such a way that GitHub Actions can use it.

Usage

The inputs of the action (under the with: stanza) are the following:

  • cabal-file:
    The path to your cabal file, e.g. somefolder/myproject.cabal.
    Required: true

  • version:
    The version of the get-tested tool that is used.
    Required: false
    Default: The latest release

  • windows:
    (deprecated) Enable Windows runner, latest version.
    Required: false
    Default: false

  • windows-version:
    Enable Windows runner. If both windows and windows-version inputs are set, the explicit version will take priority.
    Required: false
    Default: Not set

  • macos:
    (deprecated) Enable macOS runner, latest version.
    Required: false
    Default: false

  • macos-version:
    Enable macOS runner. If both macos and macos-version inputs are set, the explicit version will take priority.
    Required: false
    Default: Not set

  • ubuntu:
    (deprecated) Enable Ubuntu runner, latest version.
    Required: false
    Default: false

  • ubuntu-version:
    Enable Ubuntu runner. If both ubuntu and ubuntu-version inputs are set, the explicit version will take priority.
    Required: false
    Default: Not set

See below for an example:

jobs:
  generate-matrix:
    name: "Generate matrix from cabal"
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    runs-on: ubuntu-latest
    steps:
      - name: Extract the tested GHC versions
        id: set-matrix
        uses: kleidukos/[email protected]
        with:
          cabal-file: get-tested.cabal
          ubuntu-version: "latest"
          macos-version: "13"
          version: 0.1.7.1
  tests:
    name: ${{ matrix.ghc }} on ${{ matrix.os }}
    needs: generate-matrix
    runs-on: ${{ matrix.os }}
    strategy:
      matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}

get-tested's People

Contributors

dependabot[bot] avatar kleidukos avatar mmhat avatar sereja313 avatar turion 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

get-tested's Issues

Option to print the compiler versions in a shell-friendly format ?

Currently get-tested outputs JSON:

$ get-tested my-project.cabal
["9.8.2", "9.10.1"]

It was nice if there was an option to print that in a more shell-friendly format, i.e. one version per line, unquoted:

$ get-tested --format=shell my-project.cabal
9.8.2
9.10.1

Then one could do something like for v in $(get-tested --shell); do cabal test all --with-compiler "ghc-${v}"; done...

Only take precise versions and reject version ranges

We should encourage people to use the exact-version syntax, and not use version ranges. For instance

tested-with: GHC == { 8.6.3, 8.4.4, 8.2.2, 8.0.2, 7.10.3, 7.8.4, 7.6.3, 7.4.2 }

or

tested-with: GHC == 8.6.3, GHC == 8.4.4, GHC == 8.2.2, GHC == 8.0.2,
             GHC == 7.10.3, GHC == 7.8.4, GHC == 7.6.3, GHC == 7.4.2

This frees us from having to maintain a whitelist.

Using `base` version bounds to determine GHCs to test with

To support the * automagic * nature of this plugin, it'd be cool to additionally support base version bounds for generating CI. While this is convenient (don't have to specify a Tested-With clause), it's also great for bounds checking.

A base constraint with no upper bound would "opt in" to be tested, automatically, once new versions of GHC are released. This would alert library authors to breaking changes in their CI much more quickly than if they were to opt-in.

Likewise, a base constraint with no lower bound would have lots of old GHCs to test with. This would help prevent problems where a feature of a new GHC is used and the CI suite doesn't manually test old enough versions of GHC.

But, IMO, the best part about this would be that it would take into account the information that cabal actually uses when providing dependencies. If I say tested-with: GHC == 8.10 || == 9.0 || == 9.2 || == 9.4, but I've got base < 5, then cabal will happily try to build my library with GHC 8.2 or 9.6. Both are likely to break.

Add a `check` mode

Is it possible to have a check mode, that tells you whether a given GHC version is in the get-tested stanza of a Cabal file or not?
What I mean is something like this:

$ get-tested get-tested.cabal
["9.10.1"]
$ get-tested check get-tested.cabal 9.10.1; echo $?
0
$ get-tested check get-tested.cabal 9.8.2; echo $?
1
$ get-tested check get-tested.cabal 9.8.2 9.10.1; echo $?
1

I know I can work around that (e.g. get-tested get-tested.cabal | jq --raw-output '.[]' | grep -q '9.10.1'), but that's rather hacky...

Publish on Hackage

It would be great if this package was published on hackage. Then it would be automatically be picked up and packaged in nixpkgs.

Maybe just emit the GHC versions as an array

Then you can load it into your own dimension. That's useful if you want to add other dimensions to your matrix. I think you can't actually do that at all with get-tested today since it emits the entire matrix definition.

That might also simplify things since you wouldn't need the OS flags to emit those parts of the matrix. More composable.

mleh! (Outputs unhelpful error message)

I mistyped the name of the cabal file in my CI setup, and I got this error message:

get-tested: mleh!
CallStack (from HasCallStack):
  error, called at app/Main.hs:28:15 in main:Main
Error: Process completed with exit code 1.

This is fun, but not helpful ;) a better error message would have been something like mleh! File foo.cabal could not be found!

Outputs empty list of jobs

I tried to use get-tested here: turion/rhine#201

But unfortunately, the list of versions is always empty. I reproduced locally:

$ ./get-tested --ubuntu --macos rhine/rhine.cabal 
matrix={"include":[]}

The corresponding section is:

tested-with:
  GHC == 8.8.4,
  GHC == 8.10.7,
  GHC == 9.0.2

Option to emit GHC versions in Nix-like format?

Nix (at least in both in nixpkgs and haskell.nix) usually represents GHC versions as e.g. ghc865/ghc8107/ghc944. Would you be open to a convenience flag that allows to emit the GHC versions in this format, or do you consider this out of scope for this project?

Add support for selecting the runner version

Hi! Nice to meet you! First of all thanks for creating this tool and GH Action ❤️

I'm trying to push for the adoption of this GH Action at @stackbuilders for some of the repos we maintain. I was having a slightly unrelated conversation with regards to the macOS runners that GitHub offers, and wanted to test the macos-14 one since that uses Apple Silicon (macos-latest is based on macos-12 which is currently x86-64 based AFAIK). But I noticed that this tool doesn't currently support that, and that it has the *-latest versions hardcoded.

I think it would be nice to support choosing the runner version for each OS. Adding a new input to the action that allows one to set an explicit list of the OS runners one wants to support could be a possible approach.

I am willing to try to work on this, unless you prefer doing that. Let me know if you have any ideas/preferences with regards to how you would like to see this reflected in the action.

Create a reusable Github action

It would be cool if there was a Github action that one could simply use like:

jobs:
  get-tested:
    name: Generate matrix
    steps:
    -uses: Kleidukos/get-tested/v1

  build:
    needs: get-tested
    strategy:
      matrix: ${{ fromJSON(needs.get-tested.outputs.matrix) }}
...

That way, one saves on code to write, and dependabot could automatically bump versions.

`cabal.project` support

I think it was nice if get-tested supported the extraction of the tested-with stanzas of multiple Cabal files; In particular those listed as packages in a cabal.project file. What I have in mind is something similar to the following:

  1. Make the Cabal file an optional input on the CLI.
  2. If no Cabal file was given, look for a cabal.project file in the current directory and its parents.
  3. Resolve the Cabal files in the packages stanza of the cabal.project file.
  4. Extract the get-tested stanzas of the packages.
  5. Output the union of the collected stanzas. Or output a separate entry for each file (e.g. <file>: <listed versions>)

I think most of the work can be done by using cabal-install-parsers, but the real question is if that is useful feature.
Personally I think it would be useful for mono-repos like https://github.com/dhall-lang/dhall-haskell to keep the tested-with stanzas in sync with what was actually tested in the CI.

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.