Skip to content

Commit

Permalink
Merge pull request #203 from unsplash/better-ci-caching
Browse files Browse the repository at this point in the history
Better CI caching
  • Loading branch information
samhh authored Jan 7, 2024
2 parents 618e5b3 + d4d8fb9 commit 23f78cb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 deletions.
18 changes: 18 additions & 0 deletions .github/actions/cabal-cache/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 6 additions & 10 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
5 changes: 1 addition & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 17 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
};
};
});
}

0 comments on commit 23f78cb

Please sign in to comment.