Skip to content

Commit

Permalink
ci: add cache and try to fix version hash
Browse files Browse the repository at this point in the history
  • Loading branch information
stevana committed Nov 3, 2024
1 parent f244d2f commit 7fcfe48
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,38 @@ jobs:
if: ${{ env.platform == 'x86_64-linux' }}
run: make push-image

- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
env:
key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-${{ matrix.cabal-version }}
with:
path: |
${HOME}/.cache/cabal/packages
${HOME}/.cabal/store
dist-newstyle
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-plan-

- name: Build dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: make build-deps

# 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@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
${HOME}/.cache/cabal/packages
${HOME}/.cabal/store
dist-newstyle
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
env:
GIT_COMMIT: ${{ github.sha }}
SPEX_GIT_COMMIT: ${{ github.sha }}
run: make build

- name: Test
Expand All @@ -186,6 +212,8 @@ jobs:
github.event_name == 'push' &&
github.ref == 'refs/heads/main' }}
id: install
env:
SPEX_GIT_COMMIT: ${{ github.sha }}
run: make install

- name: Upload binary artifacts
Expand Down
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ endif
ifeq ($(OS),linux)
CABAL := docker run --rm --entrypoint=cabal \
--volume $(PWD):/mnt \
--volume $(PWD)/.container-cache/cabal-store:/root/.local/state/cabal/store \
--volume $(PWD)/.container-cache/cabal-packages:/root/.cache/cabal/packages \
--volume $(PWD)/.container-cache/dist-newstyle:/mnt/dist-newstyle \
--volume $(HOME)/.cache/cabal/packages:/root/.cache/cabal/packages \
--volume $(HOME)/.cabal/store:/root/.local/state/cabal/store \
--volume $(PWD)/dist-newstyle:/mnt/dist-newstyle \
--env SPEX_GIT_COMMIT=$(SPEX_GIT_COMMIT) \
ghcr.io/spex-lang/spex-build:latest
ENABLE_STATIC := --enable-executable-static
Expand All @@ -41,9 +41,8 @@ all: build-deps build test bump install release

dist-newstyle/cache/plan.json: cabal.project cabal.project.freeze spex.cabal
ifeq ($(OS),linux)
mkdir -p .container-cache/cabal-store
mkdir -p .container-cache/cabal-packages
mkdir -p .container-cache/dist-newstyle
mkdir -p $(HOME)/.cache/cabal/packages
mkdir -p $(HOME)/.cabal/store
endif
$(CABAL) configure \
$(ENABLE_STATIC) \
Expand Down

0 comments on commit 7fcfe48

Please sign in to comment.