From ac2b0e83bcaa9bf9a847d4dbf3243d9b3f5b4050 Mon Sep 17 00:00:00 2001 From: Will Coster Date: Thu, 7 Dec 2023 18:42:54 -0800 Subject: [PATCH 1/3] Update github action to use stack --- .github/workflows/cabal.yml | 73 --------------------------------- .github/workflows/stack.yml | 80 +++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 73 deletions(-) delete mode 100644 .github/workflows/cabal.yml create mode 100644 .github/workflows/stack.yml diff --git a/.github/workflows/cabal.yml b/.github/workflows/cabal.yml deleted file mode 100644 index 5cbcbe0..0000000 --- a/.github/workflows/cabal.yml +++ /dev/null @@ -1,73 +0,0 @@ -# https://github.com/haskell/actions/tree/main/setup - -name: build -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -permissions: - contents: read - -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.6', '9.4', '9.2', '9.0'] - - steps: - - uses: actions/checkout@v3 - - - 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 --dry-run - # The last step generates dist-newstyle/cache/plan.json for the cache key. - - - name: Restore cached dependencies - uses: actions/cache/restore@v3 - 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 - 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@v3 - # Caches are immutable, trying to save with the same key would error. - if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }} - 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 diff --git a/.github/workflows/stack.yml b/.github/workflows/stack.yml new file mode 100644 index 0000000..cb84f40 --- /dev/null +++ b/.github/workflows/stack.yml @@ -0,0 +1,80 @@ +# https://github.com/haskell/actions/tree/main/setup + +name: build +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +permissions: + contents: read + +jobs: + build: + name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + stackage-version: + - lts-21.23 + - lts-20.26 + - lts-19.33 + - lts-18.28 + - lts-16.31 + + steps: + - uses: actions/checkout@v3 + + - uses: haskell-actions/setup@v2 + name: Set up stack ${{ matrix.stackage-version }} + id: setup + with: + enable-stack: true + stack-version: ${{ matrix.stackage-version }} + + - uses: actions/cache/restore@v3 + name: Restore cached ~/.stack + with: + path: ~/.stack + key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**/*.cabal') }}-version-${{ matrix.stackage-version }} + restore-keys: | + ${{ runner.os }}-stack-global- + - uses: actions/cache/restore@v3 + name: Restore cached .stack-work + with: + path: .stack-work + key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/*.hs') }}-version-${{ matrix.stackage-version }} + restore-keys: | + ${{ runner.os }}-stack-work- + + - name: Install dependencies + run: stack build --resolver ${{ matrix.stackage-version }} --dependencies-only --test --bench + + # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. + + - uses: actions/cache/save@v3 + name: Cache ~/.stack + with: + path: ~/.stack + key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**/*.cabal') }}-version-${{ matrix.stackage-version }} + restore-keys: | + ${{ runner.os }}-stack-global- + - uses: actions/cache/save@v3 + name: Cache .stack-work + with: + path: .stack-work + key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/*.hs') }}-version-${{ matrix.stackage-version }} + restore-keys: | + ${{ runner.os }}-stack-work- + + - name: Build + run: stack build --test --bench + + - name: Run tests + run: stack test + + - name: Build documentation + run: stack haddock From 5697ab375e2b59c5fc5e0f2331bbd72003f0bff3 Mon Sep 17 00:00:00 2001 From: Will Coster Date: Thu, 7 Dec 2023 18:46:54 -0800 Subject: [PATCH 2/3] Fix stack version in haskel-actions setup --- .github/workflows/stack.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stack.yml b/.github/workflows/stack.yml index cb84f40..77aae22 100644 --- a/.github/workflows/stack.yml +++ b/.github/workflows/stack.yml @@ -12,7 +12,7 @@ permissions: jobs: build: - name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} + name: GHC ${{ matrix.stackage-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -33,7 +33,7 @@ jobs: id: setup with: enable-stack: true - stack-version: ${{ matrix.stackage-version }} + stack-version: latest - uses: actions/cache/restore@v3 name: Restore cached ~/.stack From 541f69ee6aa1a05ed03bf3760b22033ba994a09a Mon Sep 17 00:00:00 2001 From: Will Coster Date: Thu, 7 Dec 2023 19:23:26 -0800 Subject: [PATCH 3/3] Actually use the appropriate resolver --- .github/workflows/stack.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stack.yml b/.github/workflows/stack.yml index 77aae22..9e8fbcd 100644 --- a/.github/workflows/stack.yml +++ b/.github/workflows/stack.yml @@ -12,7 +12,7 @@ permissions: jobs: build: - name: GHC ${{ matrix.stackage-version }} on ${{ matrix.os }} + name: Stack resolver ${{ matrix.stackage-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -71,10 +71,13 @@ jobs: ${{ runner.os }}-stack-work- - name: Build - run: stack build --test --bench + run: stack build --resolver ${{ matrix.stackage-version }} - name: Run tests - run: stack test + run: stack test --resolver ${{ matrix.stackage-version }} + + - name: Run benchmarks + run: stack bench --resolver ${{ matrix.stackage-version }} - name: Build documentation - run: stack haddock + run: stack haddock --resolver ${{ matrix.stackage-version }}