From a1778e43354cc5d2d1d5bc2457fc2a3776d91b2f Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Wed, 2 Aug 2023 09:02:58 +0100 Subject: [PATCH 1/3] Move Stack build outside of GHC matrix since it has a single pinned GHC version Fixes #177. --- .github/workflows/main.yml | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aec90707..97a516ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,8 +14,11 @@ jobs: # and use fromJson in the next job to construct the matrix. # This dynamic approach means we don't have to update the CI file when we # change supported GHC versions. + # + # Only the Cabal build job will use the generated matrix, since Stack has a + # pinned GHC version in the stack.yaml file. generate-matrix: - name: Generate GHC build matrix + name: Generate GHC build matrix for Cabal runs-on: ubuntu-latest outputs: ghc-matrix: ${{ steps.set-ghc-matrix.outputs.versions }} @@ -35,7 +38,7 @@ jobs: run: echo '::set-output name=versions::{"ghc-version":${{ steps.parse.outputs.tested-with-versions }}}' build: - name: Build Check + name: Cabal Build Check needs: generate-matrix runs-on: ubuntu-latest strategy: @@ -48,14 +51,16 @@ jobs: steps: - uses: actions/checkout@v2 + # Although the GitHub Action Runner comes with pre-installed Cabal and GHC, + # we'll only use Cabal out of the box since that is independent of + # the GHC version. For GHC, we'll use the Haskell setup action to install + # the correct version needed for the build. - uses: haskell/actions/setup@v2 id: setup-haskell with: - # We install a global GHC and use Stack with --system-ghc + # We install a global GHC ghc-version: ${{ matrix.ghc-version }} - enable-stack: true - # First run cabal, since it is generally quicker - name: "Cabal: Update cabal package database, generate build plan" run: | cabal update @@ -77,15 +82,29 @@ jobs: - name: "Cabal: Build" run: cabal build - # Now run stack + build-stack: + name: Stack Build Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # Since the GitHub Action Runner comes with a pre-installed Stack, we'll + # use that instead of installing our own through the Haskell setup action, + # since all we need to test the stack build is Stack itself. + - name: "Stack: Cache ~/.stack" id: cache-stack uses: actions/cache@v2 with: path: ~/.stack - key: stack-${{ runner.os }}-${{ matrix.ghc-version }}-${{ hashFiles('stack.yaml') }} + key: stack-${{ runner.os }}-${{ hashFiles('stack.yaml') }} restore-keys: | - stack-${{ runner.os }}-${{ matrix.ghc-version }} + stack-${{ runner.os }} + + - name: "Print GHC version resolved from stack.yaml" + run: | + stack ghc -- --version + stack path --compiler-exe - name: "Stack: Build" - run: stack build --system-ghc + run: stack build From b78519ff626291d7355313b7d75902f8e75c4425 Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Wed, 2 Aug 2023 09:05:06 +0100 Subject: [PATCH 2/3] Migrate from deprecated set-output in GitHub CI to using GITHUB_OUTPUT See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 97a516ed..2d5f7808 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,14 +28,14 @@ jobs: - name: Parse the cabal tested-with stanza id: parse run: | - echo "::set-output name=tested-with-versions::$(runghc .github/workflows/parseVersions.hs)" + echo "tested-with-versions=$(runghc .github/workflows/parseVersions.hs)" >> $GITHUB_OUTPUT - name: Set the GHC matrix for the next job id: set-ghc-matrix # We use single quotes here, since the output from the previous step # will not have escaped double quotes, and it's just easier to use single # quotes on the outside than try to escape the inner double quotes. - run: echo '::set-output name=versions::{"ghc-version":${{ steps.parse.outputs.tested-with-versions }}}' + run: echo 'versions={"ghc-version":${{ steps.parse.outputs.tested-with-versions }}}' >> $GITHUB_OUTPUT build: name: Cabal Build Check From fbf6cb28472786385a7ef651a5569fa1d7e50dfb Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Wed, 2 Aug 2023 09:30:10 +0100 Subject: [PATCH 3/3] Rename build job to build-cabal for consistenty in CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d5f7808..0d5aa651 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ jobs: # quotes on the outside than try to escape the inner double quotes. run: echo 'versions={"ghc-version":${{ steps.parse.outputs.tested-with-versions }}}' >> $GITHUB_OUTPUT - build: + build-cabal: name: Cabal Build Check needs: generate-matrix runs-on: ubuntu-latest