From 8ada6b13a2fb0beba486ae1c058ac49294d505fd Mon Sep 17 00:00:00 2001 From: William Rusnack Date: Thu, 11 Jul 2024 21:13:30 -0400 Subject: [PATCH] improve ci (#226) * fixed macos ci by intalling stack * use haskell-actions * install llvm@12 * only macos * fixed llvm@12 path * print path and llvm dir * brew reccommended paths * remove Cellar * add opt * ls brew prefix * more ls * fixed paths * splitting matrix into different jobs * invalid strategy * fixed os name * find error * indent * build * @->V * test old * remove anchor * old steps * checkout@2 * narrow * widen * widen * narrow * widen * move checkout * for resolver * narrow * widen * install llvm@12 * matrix * fix list * quotes * lts * added other OSs * added --extra-*-dir instead of env var * removed single quotes * libffi * removed quotes * -I to extra-include-dirs * specific path * llvm 12 -> 13 * cache stack work * widen lts versions * stack path reorder * print largest cache file size * exclude .stack/programs * use haskell-actions to install ghc\ninstead of stack so ghc is not cached * clean up * added cabal builds * use sh and cabal * install correct ghc version non-macos, show versions * added cabal.project * chaned cache paths for windows * unique ids * minimize conflict set * restore-keys, fixed stack cache path * base_ref * base_ref -> head_ref, cabal uses 9.8.2 * cabal uses 9.8.2 * use haskell setup for all OSs * added build-tools: hspec-discover * cabal cleanup --- .github/workflows/tests.yml | 107 ++++++++++++++---- cabal.project | 2 + .../classy-prelude-conduit.cabal | 2 + classy-prelude-conduit/package.yaml | 1 + classy-prelude/classy-prelude.cabal | 2 + classy-prelude/package.yaml | 1 + mono-traversable/mono-traversable.cabal | 2 + mono-traversable/package.yaml | 1 + mutable-containers/mutable-containers.cabal | 2 + mutable-containers/package.yaml | 1 + 10 files changed, 101 insertions(+), 20 deletions(-) create mode 100644 cabal.project diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 42303cb..94cff15 100755 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,30 +11,97 @@ jobs: name: Stack runs-on: ${{ matrix.os }} strategy: - fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - resolver: - # Missing some packages now - #- "--resolver nightly" - - lts-18.16 # Win32 issue - - lts-16 - stack-yaml: - - stack.yaml - - stack-new-time.yaml - exclude: - - resolver: lts-16 - stack-yaml: stack-new-time.yaml - - os: windows-latest - stack-yaml: stack-new-time.yaml - + os: + - macos-latest + - ubuntu-latest + - windows-latest + versions: + #- + - 22.28 9.6.6 + - 21.25 9.4.8 + - 20.26 9.2.8 + - 19.33 9.0.2 + - 18.28 8.10.7 steps: + - name: Parse lts and ghc versions + shell: sh + run: | + echo snapshot=$(echo ${{ matrix.versions }} | cut -d ' ' -f 1) >> $GITHUB_ENV + echo ghcVersion=$(echo ${{ matrix.versions }} | cut -d ' ' -f 2) >> $GITHUB_ENV + - name: Install LLVM 13 + if: ${{ matrix.os == 'macos-latest' && env.snapshot < 20 }} + shell: sh + run: | + brew install llvm@13 + echo "/opt/homebrew/opt/llvm@13/bin" >> $GITHUB_PATH + echo extraLibDirs="--extra-lib-dirs /opt/homebrew/opt/llvm@13/lib" >> $GITHUB_ENV + echo extraIncludeDirsLLVM="--extra-include-dirs /opt/homebrew/opt/llvm@13/include" >> $GITHUB_ENV + echo extraIncludeDirsFFI="--extra-include-dirs /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/ffi" >> $GITHUB_ENV + - name: Setup Haskell + id: setup-haskell-stack + uses: haskell-actions/setup@v2.7 + with: + ghc-version: ${{ env.ghcVersion }} + enable-stack: true + stack-version: 'latest' + cabal-update: false - name: Clone project - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Use Cache + uses: actions/cache@v4 + with: + key: ${{ matrix.os }}_${{ env.snapshot }}_${{ github.head_ref }} + restore-keys: | + ${{ matrix.os }}_${{ env.snapshot }}_${{ github.head_ref }} + ${{ matrix.os }}_${{ env.snapshot }}_${{ github.base_ref }} + ${{ matrix.os }}_${{ env.snapshot }}_ + ${{ matrix.os }}_${{ env.snapshot }} + path: | + ${{ steps.setup-haskell-stack.outputs.stack-root }} + .stack-work + */.stack-work + - name: Build and run tests + shell: bash + run: | + set -ex + ghc --version + stack --version + stack test --system-ghc $extraLibDirs $extraIncludeDirsLLVM $extraIncludeDirsFFI --fast --no-terminal --snapshot=lts-$snapshot + Cabal: + name: Cabal + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - macos-latest + - macos-13 + - ubuntu-latest + - windows-latest + steps: + - name: Setup Haskell + id: setup-haskell-cabal + uses: haskell-actions/setup@v2.7 + with: + ghc-version: 9.6.6 + - name: Clone project + uses: actions/checkout@v4 + - name: Use Cache + uses: actions/cache@v4 + with: + key: ${{ matrix.os }}_cabal_${{ github.head_ref }} + restore-keys: | + ${{ matrix.os }}_cabal_${{ github.head_ref }} + ${{ matrix.os }}_cabal_${{ github.base_ref }} + ${{ matrix.os }}_cabal_ + ${{ matrix.os }}_cabal + path: | + ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + dist-newstyle - name: Build and run tests shell: bash run: | - set -ex - stack --version - stack test --fast --no-terminal --stack-yaml=${{ matrix.stack-yaml }} --resolver=${{ matrix.resolver }} + ghc --version + cabal --version + cabal test --minimize-conflict-set -O0 all diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..00dfed3 --- /dev/null +++ b/cabal.project @@ -0,0 +1,2 @@ +packages: + */*.cabal diff --git a/classy-prelude-conduit/classy-prelude-conduit.cabal b/classy-prelude-conduit/classy-prelude-conduit.cabal index 7e3ecc7..2ac82d0 100644 --- a/classy-prelude-conduit/classy-prelude-conduit.cabal +++ b/classy-prelude-conduit/classy-prelude-conduit.cabal @@ -50,6 +50,8 @@ test-suite spec Paths_classy_prelude_conduit hs-source-dirs: test + build-tool-depends: + hspec-discover:hspec-discover build-depends: QuickCheck , base >=4.13 && <5 diff --git a/classy-prelude-conduit/package.yaml b/classy-prelude-conduit/package.yaml index 550d6ed..1a676aa 100644 --- a/classy-prelude-conduit/package.yaml +++ b/classy-prelude-conduit/package.yaml @@ -38,3 +38,4 @@ tests: - classy-prelude-conduit - QuickCheck - conduit + build-tools: hspec-discover diff --git a/classy-prelude/classy-prelude.cabal b/classy-prelude/classy-prelude.cabal index 925ea9d..b727fe4 100644 --- a/classy-prelude/classy-prelude.cabal +++ b/classy-prelude/classy-prelude.cabal @@ -69,6 +69,8 @@ test-suite test hs-source-dirs: test ghc-options: -Wall + build-tool-depends: + hspec-discover:hspec-discover build-depends: QuickCheck , base >=4.13 && <5 diff --git a/classy-prelude/package.yaml b/classy-prelude/package.yaml index dd33b8d..a0133c9 100644 --- a/classy-prelude/package.yaml +++ b/classy-prelude/package.yaml @@ -64,3 +64,4 @@ tests: - hspec >=1.3 - QuickCheck - containers + build-tools: hspec-discover diff --git a/mono-traversable/mono-traversable.cabal b/mono-traversable/mono-traversable.cabal index 1baf9a9..c8cad75 100644 --- a/mono-traversable/mono-traversable.cabal +++ b/mono-traversable/mono-traversable.cabal @@ -57,6 +57,8 @@ test-suite test hs-source-dirs: test ghc-options: -O0 + build-tool-depends: + hspec-discover:hspec-discover build-depends: HUnit , QuickCheck diff --git a/mono-traversable/package.yaml b/mono-traversable/package.yaml index 8ecade0..bae7fac 100644 --- a/mono-traversable/package.yaml +++ b/mono-traversable/package.yaml @@ -44,6 +44,7 @@ tests: - containers - unordered-containers - foldl + build-tools: hspec-discover benchmarks: all: main: main.hs diff --git a/mutable-containers/mutable-containers.cabal b/mutable-containers/mutable-containers.cabal index 63b08d6..ce4f5ae 100644 --- a/mutable-containers/mutable-containers.cabal +++ b/mutable-containers/mutable-containers.cabal @@ -55,6 +55,8 @@ test-suite test Paths_mutable_containers hs-source-dirs: test + build-tool-depends: + hspec-discover:hspec-discover build-depends: QuickCheck , base >=4.13 && <5 diff --git a/mutable-containers/package.yaml b/mutable-containers/package.yaml index c04e41c..c007e8c 100644 --- a/mutable-containers/package.yaml +++ b/mutable-containers/package.yaml @@ -35,6 +35,7 @@ tests: - hspec - QuickCheck - primitive + build-tools: hspec-discover benchmarks: deque: main: deque.hs