diff --git a/.github/actions/cabal-cache/action.yml b/.github/actions/cabal-cache/action.yml new file mode 100644 index 0000000..207e049 --- /dev/null +++ b/.github/actions/cabal-cache/action.yml @@ -0,0 +1,18 @@ +name: Cabal dependency and incremental build caches +runs: + using: composite + steps: + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.local/state/cabal/store/ + key: cabal-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} + restore-keys: | + cabal-${{ runner.os }} + - name: Cache incremental build + uses: actions/cache@v3 + with: + path: ./dist-newstyle/ + key: dist-${{ runner.os }}-${{ github.sha }} + restore-keys: | + dist-${{ runner.os }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ac1b3cc..ba4d662 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -22,10 +22,7 @@ jobs: - uses: cachix/install-nix-action@v22 - run: nix develop -c cabal update - run: nix develop -c cabal freeze - - uses: actions/cache@v3 - with: - path: ~/.cabal/store - key: cabal-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} + - uses: ./.github/actions/cabal-cache - run: nix develop -c cabal build test: name: Test @@ -35,10 +32,7 @@ jobs: - uses: cachix/install-nix-action@v22 - run: nix develop -c cabal update - run: nix develop -c cabal freeze - - uses: actions/cache@v3 - with: - path: ~/.cabal/store - key: cabal-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} + - uses: ./.github/actions/cabal-cache - run: nix develop -c cabal test lint: name: Lint @@ -71,5 +65,7 @@ jobs: with: path: ~/.cache/yarn/v6 key: yarn-${{ runner.os }}-${{ hashFiles('.golden/ts/yarn.lock') }} - - run: nix develop -c yarn install --frozen-lockfile - - run: nix develop -c yarn typecheck + restore-keys: | + yarn-${{ runner.os }} + - run: nix develop .#golden -c yarn install --frozen-lockfile + - run: nix develop .#golden -c yarn typecheck diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 665f36b..8e982a6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,10 +25,7 @@ jobs: with: ghc-version: 9.4.6 - run: cabal freeze - - uses: actions/cache@v3 - with: - path: ~/.cabal/store - key: cabal-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }} + - uses: ./.github/actions/cabal-cache - name: Build run: | # Unlike `cabal build`, `cabal install` appears to build in a diff --git a/flake.nix b/flake.nix index 584000d..0cfd55f 100644 --- a/flake.nix +++ b/flake.nix @@ -15,19 +15,24 @@ haskPkgs = pkgs.haskell.packages."${ghcVer}"; in { - devShells.default = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ - cabal-install - haskell.compiler."${ghcVer}" - haskPkgs.haskell-language-server - hlint - haskPkgs.hspec-golden - stylish-haskell + devShells = { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + cabal-install + haskell.compiler."${ghcVer}" + haskPkgs.haskell-language-server + hlint + haskPkgs.hspec-golden + stylish-haskell + ]; + }; - # For typechecking golden output - nodejs - yarn - ]; + golden = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + nodejs + yarn + ]; + }; }; }); }