From 3b313a7e1975139cd638146deace4b3dccb77339 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Wed, 6 Jan 2021 04:21:10 +0200 Subject: [PATCH] CI: GitHub: Cabal: improvement of the GitHub caching A riff on the theme of https://markkarpov.com/post/github-actions-for-haskell-ci.html --- .github/workflows/Cabal-Linux.yml | 37 ++++++++++++------- .github/workflows/On-Release-Cabal-Linux.yml | 38 +++++++++++++------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/.github/workflows/Cabal-Linux.yml b/.github/workflows/Cabal-Linux.yml index d8b9e80a..2eb2cefe 100644 --- a/.github/workflows/Cabal-Linux.yml +++ b/.github/workflows/Cabal-Linux.yml @@ -8,6 +8,8 @@ on: schedule: - cron: "45 02 * * *" +env: + cabalConfig: --enable-tests --enable-benchmarks --disable-optimization --enable-deterministic jobs: @@ -18,18 +20,13 @@ jobs: matrix: ghc: [ "8.10", "8.4" ] steps: - - uses: actions/checkout@v2 + - name: "Git checkout" + uses: actions/checkout@v2 with: submodules: recursive - - name: "Cache of ~/.cabal/packages, ~/.cabal/store and dist-newstyle" - uses: actions/cache@v2 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - dist-newstyle - key: ${{ runner.os }}-Cabal-${{ matrix.ghc }} - - uses: haskell/actions/setup@v1 + - name: "Haskell env setup" + id: HaskEnvSetup + uses: haskell/actions/setup@v1 with: ghc-version: ${{ matrix.ghc }} - name: "Install additional system packages" @@ -37,6 +34,20 @@ jobs: # 2020-08-01: NOTE: Nix instantiate still needed for HNix tests - name: "Install Nix" uses: cachix/install-nix-action@v12 - - run: cabal v2-configure --disable-optimization --enable-tests --enable-deterministic - - run: cabal v2-build - - run: cabal v2-test + - name: "Repository update" + run: cabal v2-update + # NOTE: Freeze is for the caching + - name: "Configuration freeze" + run: cabal v2-freeze $cabalConfig + - name: "Configuring GitHub cache" + uses: actions/cache@v2 + with: + path: | + ${{ steps.HaskEnvSetup.outputs.cabal-store }} + dist-newstyle + key: ${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + restore-keys: ${{ runner.os }}-Cabal-${{ matrix.ghc }}- + - name: "Build" + run: cabal v2-build $cabalConfig + - name: "Tests" + run: cabal v2-test $cabalConfig diff --git a/.github/workflows/On-Release-Cabal-Linux.yml b/.github/workflows/On-Release-Cabal-Linux.yml index 8cd9e8c8..b59b6a5a 100644 --- a/.github/workflows/On-Release-Cabal-Linux.yml +++ b/.github/workflows/On-Release-Cabal-Linux.yml @@ -5,6 +5,9 @@ on: # created: a draft is saved, or a release or pre-release is published without previously being saved as a draft types: [ created ] +env: + cabalConfig: --enable-tests --enable-benchmarks --disable-optimization --enable-deterministic + jobs: build10: @@ -15,18 +18,13 @@ jobs: # Since CI by default tests boundary GHCs, test middle versions of GHCs ghc: [ "8.8", "8.6"] steps: - - uses: actions/checkout@v2 + - name: "Git checkout" + uses: actions/checkout@v2 with: submodules: recursive - - name: Cache of ~/.cabal/packages, ~/.cabal/store and dist-newstyle - uses: actions/cache@v2 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - dist-newstyle - key: ${{ runner.os }}-Cabal-${{ matrix.ghc }} - - uses: haskell/actions/setup@v1 + - name: "Haskell env setup" + id: HaskEnvSetup + uses: haskell/actions/setup@v1 with: ghc-version: ${{ matrix.ghc }} - name: "Install additional system packages" @@ -34,6 +32,20 @@ jobs: # 2020-08-01: NOTE: Nix instantiate still needed for HNix tests - name: "Install Nix" uses: cachix/install-nix-action@v12 - - run: cabal v2-configure --disable-optimization --enable-tests --enable-deterministic - - run: cabal v2-build - - run: cabal v2-test + - name: "Repository update" + run: cabal v2-update + # NOTE: Freeze is for the caching + - name: "Configuration freeze" + run: cabal v2-freeze $cabalConfig + - name: "Configuring GitHub cache" + uses: actions/cache@v2 + with: + path: | + ${{ steps.HaskEnvSetup.outputs.cabal-store }} + dist-newstyle + key: ${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + restore-keys: ${{ runner.os }}-Cabal-${{ matrix.ghc }}- + - name: "Build" + run: cabal v2-build $cabalConfig + - name: "Tests" + run: cabal v2-test $cabalConfig