Skip to content

Commit

Permalink
Github Actions update from bellroy/gha-workflows#550 (#1)
Browse files Browse the repository at this point in the history
* workflow update from gha-workflows

* Fix CHANGELOG link

* Feedback from team

* Widen bounds

* Remove string-interpolate

* Make work with Haskell2010

* Widen bounds

* Widen bounds

* Widen bounds

* Widen bounds

* Desperately try to get bytestring to work

* Just guessing now

* Remove all bounds to see what happens

* Take the bounds that CI picked and apply them

* Try tweaking base bounds

* Try tweaking base bounds

* Try tweaking multiple package bounds

* Try tweaking multiple package bounds

---------

Co-authored-by: michaelwebb76 <[email protected]>
Co-authored-by: Michael Webb <[email protected]>
  • Loading branch information
3 people authored Dec 17, 2024
1 parent 23cb079 commit 3563483
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 196 deletions.
113 changes: 61 additions & 52 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
# This file is generated by `generate.sh`.
# Generated from https://github.com/bellroy/gha-workflows/tree/master/dhall/workflows/tasty-golden-extra/haskell-ci.dhall
# Think twice before editing it directly.
jobs:
generate-matrix:
name: "Generate matrix from cabal"
name: Generate matrix from cabal
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
matrix: "${{ steps.set-matrix.outputs.matrix }}"
runs-on: ubuntu-20.04
steps:
- name: Extract the tested GHC versions
id: set-matrix
uses: kleidukos/get-tested@a0aa3f2d4ab0d10daa49dc9ee8c706d673fb0e02
- id: set-matrix
name: Extract the tested GHC versions
uses: "kleidukos/get-tested@a0aa3f2d4ab0d10daa49dc9ee8c706d673fb0e02"
with:
cabal-file: tasty-golden-extra.cabal
ubuntu-version: "20.04"
version: 0.1.7.1
ubuntu-version: '20.04'
version: '0.1.7.1'
timeout-minutes: 30
tests:
name: ${{ matrix.ghc }} on ${{ matrix.os }}
needs: generate-matrix
runs-on: ${{ matrix.os }}
container:
image: buildpack-deps:jammy
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
name: "${{ matrix.ghc }} on ${{ matrix.os }}"
needs:
- generate-matrix
runs-on: "${{ matrix.os }}"
steps:
- name: apt
- env:
HCKIND: ghc
HCNAME: "ghc-${{ matrix.ghc }}"
HCVER: "${{ matrix.ghc }}"
name: apt
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
Expand All @@ -30,11 +37,11 @@ jobs:
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
- env:
HCKIND: ghc
HCNAME: ghc-${{ matrix.ghc }}
HCVER: ${{ matrix.ghc }}
- name: Set PATH and environment variables
HCNAME: "ghc-${{ matrix.ghc }}"
HCVER: "${{ matrix.ghc }}"
name: Set PATH and environment variables
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
Expand All @@ -55,13 +62,8 @@ jobs:
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
env:
HCKIND: ghc
HCNAME: ghc-${{ matrix.ghc }}
HCVER: ${{ matrix.ghc }}
- name: env
run: |
env
run: env
- name: write cabal config
run: |
mkdir -p $CABAL_DIR
Expand Down Expand Up @@ -92,13 +94,12 @@ jobs:
$HC --print-project-git-commit-id || true
$CABAL --version || true
- name: update cabal index
run: |
$CABAL v2-update -v
- name: cache (tools)
uses: actions/cache/restore@v4
run: "$CABAL v2-update -v"
- name: "cache (tools)"
uses: "actions/cache/restore@v4"
with:
key: ${{ runner.os }}-${{ matrix.ghc }}-tools-ac1dc7e1
path: ~/.haskell-ci-tools
key: "${{ runner.os }}-${{ matrix.ghc }}-tools-ac1dc7e1"
path: "~/.haskell-ci-tools"
- name: install cabal-plan
run: |
mkdir -p $HOME/.cabal/bin
Expand All @@ -112,14 +113,14 @@ jobs:
run: |
$CABAL --store-dir=$HOME/.haskell-ci-tools/store v2-install $ARG_COMPILER --ignore-project -j2 doctest --constraint='doctest ^>=0.22.0'
doctest --version
- name: save cache (tools)
uses: actions/cache/save@v4
if: always()
- if: "always()"
name: "save cache (tools)"
uses: "actions/cache/save@v4"
with:
key: ${{ runner.os }}-${{ matrix.ghc }}-tools-ac1dc7e1
path: ~/.haskell-ci-tools
key: "${{ runner.os }}-${{ matrix.ghc }}-tools-ac1dc7e1"
path: "~/.haskell-ci-tools"
- name: checkout
uses: actions/checkout@v4
uses: "actions/checkout@v4"
with:
path: source
- name: initial cabal.project for sdist
Expand All @@ -137,29 +138,29 @@ jobs:
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
- name: generate cabal.project
run: |
PKGDIR_aws_arn="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/aws-arn-[0-9.]*')"
echo "PKGDIR_aws_arn=${PKGDIR_aws_arn}" >> "$GITHUB_ENV"
PKGDIR_PROJECT="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/tasty-golden-extra-[0-9.]*')"
echo "PKGDIR_PROJECT=${PKGDIR_PROJECT}" >> "$GITHUB_ENV"
rm -f cabal.project cabal.project.local
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_aws_arn}" >> cabal.project
echo "package aws-arn" >> cabal.project
echo "packages: ${PKGDIR_PROJECT}" >> cabal.project
echo "package tasty-golden-extra" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(aws-arn)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(tasty-golden-extra)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: restore cache
uses: actions/cache/restore@v4
uses: "actions/cache/restore@v4"
with:
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
path: ~/.cabal/store
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
key: "${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}"
path: "~/.cabal/store"
restore-keys: "${{ runner.os }}-${{ matrix.ghc }}-"
- name: install dependencies
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
Expand All @@ -175,11 +176,11 @@ jobs:
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: doctest
run: |
cd ${PKGDIR_aws_arn} || false
cd ${PKGDIR_PROJECT} || false
doctest -XHaskell2010 src
- name: cabal check
run: |
cd ${PKGDIR_aws_arn} || false
cd ${PKGDIR_PROJECT} || false
${CABAL} -vnormal check
- name: haddock
run: |
Expand All @@ -188,12 +189,20 @@ jobs:
run: |
rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: save cache
uses: actions/cache/save@v4
if: always()
- if: "always()"
name: save cache
uses: "actions/cache/save@v4"
with:
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
path: ~/.cabal/store
key: "${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}"
path: "~/.cabal/store"
strategy:
matrix:
include:
- "${{ (fromJSON(needs.generate-matrix.outputs.matrix)).include }}"
timeout-minutes: 30
name: Haskell CI
on:
- push
push:
branches-ignore:
- "refs/tags/*_staging"
- "refs/tags/*_production"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changes

## Version 1.0.0
## Version 0.1.0.0

_2024-12-17_

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ A library providing additional golden test helpers for the
the output of functions that return textual output and instances of @Show@,
@ToJSON@ or @ToYAML@.

To find out what's new, read the **[change log][]**.

[change log]: https://github.com/UnkindPartition/tasty/blob/master/core/CHANGELOG.md
To find out what's new, read the [change log](https://github.com/bellroy/tasty-golden-extra/blob/master/CHANGELOG.md).
18 changes: 10 additions & 8 deletions src/Test/Tasty/Golden/Extra/GoldenVsShow.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE ExistentialQuantification #-}

-- |
--
-- Module : Test.Tasty.Golden.Extra.GoldenVsShow
Expand All @@ -13,10 +15,10 @@ module Test.Tasty.Golden.Extra.GoldenVsShow
)
where

import Data.Text.Lazy qualified as Text
import qualified Data.Text.Lazy as Text
import Data.Text.Lazy.Encoding (encodeUtf8)
import Test.Tasty (TestName, TestTree)
import Test.Tasty.Discover qualified as Discover
import qualified Test.Tasty.Discover as Discover
import Test.Tasty.Golden
import Text.Show.Pretty (ppShow)

Expand All @@ -26,12 +28,12 @@ import Text.Show.Pretty (ppShow)
--
-- @
-- import MySchemasWithShowAndToJSONInstances.Person (Person)
-- import Data.Aeson qualified as Aeson
-- import qualified Data.Aeson as Aeson
-- import System.FilePath ((\</\>))
-- import Test.Tasty.Golden.Extra.GoldenVsShow (GoldenVsShow (..))
--
-- tasty_FromJSON_ToJSON :: GoldenVsShow
-- tasty_FromJSON_ToJSON =
-- tasty_GoldenVsShow :: GoldenVsShow
-- tasty_GoldenVsShow =
-- GoldenVsShow (goldenFilesPath \</\> "Person.golden.txt") $
-- Aeson.eitherDecodeFileStrict @Person (goldenFilesPath \</\> "Person.json")
-- @
Expand All @@ -48,17 +50,17 @@ instance Discover.Tasty GoldenVsShow where
--
-- @
-- import MySchemasWithShowAndShowInstances.Person (Person)
-- import Data.Aeson qualified as Aeson
-- import qualified Data.Aeson as Aeson
-- import System.FilePath ((\</\>))
-- import Test.Tasty.Golden.Extra.GoldenVsShow (GoldenVsShow (..))
-- import Test.Tasty.Golden.Extra.GoldenVsShow (goldenVsShow)
--
-- test_Show :: TestTree
-- test_Show = do
-- let inputFile = goldenFilesPath \</\> "Person.json"
-- goldenVsShow
-- "Test Show instance for Person"
-- (goldenFilesPath \</\> "Person.golden.txt")
-- (Aeson.decodeFileStrict' inputFile)
-- (Aeson.decodeFileStrict' @Person inputFile)
-- @
goldenVsShow ::
(Show a) =>
Expand Down
13 changes: 8 additions & 5 deletions src/Test/Tasty/Golden/Extra/GoldenVsString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
--
-- These helpers are useful for creating golden tests for functions that
-- produce textual output.
module Test.Tasty.Golden.Extra.GoldenVsString (GoldenVsString (..)) where
module Test.Tasty.Golden.Extra.GoldenVsString
( GoldenVsString (..),
goldenVsString,
)
where

import Data.ByteString.Lazy (ByteString)
import Test.Tasty.Discover qualified as Discover
import qualified Test.Tasty.Discover as Discover
import Test.Tasty.Golden

-- | Tasty-discoverable type for creating golden tests for functions that produce
Expand All @@ -20,9 +24,8 @@ import Test.Tasty.Golden
-- Example use:
--
-- @
-- import MySchemasWithShowAndToJSONInstances.Person (Person, convertToCSVText)
-- import Data.Aeson qualified as Aeson
-- import Data.Aeson.Encode.Pretty qualified as AesonPretty
-- import MySchemasWithShowAndToJSONInstances.Person (convertToCSVText)
-- import qualified Data.Aeson as Aeson
-- import System.FilePath ((\</\>))
-- import Test.Tasty.Golden.Extra.GoldenVsString (GoldenVsString (..))
--
Expand Down
Loading

0 comments on commit 3563483

Please sign in to comment.