Skip to content

Commit

Permalink
ci: try to clean up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
stevana committed Oct 22, 2024
1 parent 438440d commit 15e3467
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 47 deletions.
73 changes: 27 additions & 46 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ name: main

env:
LANG: C.UTF-8
cabal: |
docker run \
--volume "${{ github.workspace }}":/mnt/ \
--volume "${HOME}/.cache/cabal":/root/.cache/cabal \
--volume "${HOME}/.cabal/store":/root/.local/state/cabal/store \
--volume "${{ github.workspace }}/dist-newstyle":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:9.6.6 \
# --volume "${{ github.workspace }}":/mnt/:ro \
# --volume "${HOME}/.cabal/packages":/root/.cache/cabal/packages \

on:
push:
Expand Down Expand Up @@ -72,22 +82,16 @@ jobs:

- name: Configure the build
run: |
docker run \
-v "${{ github.workspace }}":/mnt/ \
-v "${HOME}/.cabal/packages":/root/.cache/cabal/packages \
-v "${HOME}/.cabal/store":/root/.local/state/cabal/store \
-v "${{ github.workspace }}/dist-newstyle":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:9.6.6 \
configure \
--enable-static \
--disable-shared \
--enable-executable-static \
--disable-executable-dynamic \
--disable-profiling \
--disable-library-for-ghci \
--enable-library-stripping \
--enable-executable-stripping \
--enable-tests --enable-benchmarks --disable-documentation --project-dir=/mnt
${{ env.cabal }} configure \
--enable-static \
--disable-shared \
--enable-executable-static \
--disable-executable-dynamic \
--disable-profiling \
--disable-library-for-ghci \
--enable-library-stripping \
--enable-executable-stripping \
--enable-tests --enable-benchmarks --disable-documentation --project-dir=/mnt
# XXX: this shouldn't be necessary, already done in image...
# Using historical state as of 2024-10-21T00:00:00Z as explicitly requested (via
Expand All @@ -98,24 +102,12 @@ jobs:
# Hmmm? Try unix time instead?
- name: Run cabal update
run: |
docker run \
-v "${{ github.workspace }}":/mnt/:ro \
-v "${HOME}/.cabal/packages":/root/.cache/cabal/packages \
-v "${HOME}/.cabal/store":/root/.local/state/cabal/store \
-v "${{ github.workspace }}/dist-newstyle":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:9.6.6 \
update --project-dir=/mnt -v
${{ env.cabal }} update --project-dir=/mnt
#update hackage.haskell.org,@1729577343 --project-dir=/mnt -v
- name: Build the cache key
run: |
docker run \
-v "${{ github.workspace }}":/mnt/:ro \
-v "${HOME}/.cabal/packages":/root/.cache/cabal/packages \
-v "${HOME}/.cabal/store":/root/.local/state/cabal/store \
-v "${{ github.workspace }}/dist-newstyle":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:9.6.6 \
build all --dry-run --project-dir=/mnt -v
${{ env.cabal }} build all --dry-run --project-dir=/mnt
# The last step generates dist-newstyle/cache/plan.json for the cache key.
- name: Restore cached dependencies
Expand All @@ -125,7 +117,7 @@ jobs:
key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-${{ matrix.cabal-version }}
with:
path: |
~/.cabal/packages
~/.cache/cabal
~/.cabal/store
${{ github.workspace }}/dist-newstyle
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
Expand All @@ -135,13 +127,7 @@ jobs:
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker run \
-v "${{ github.workspace }}":/mnt/:ro \
-v "${HOME}/.cabal/packages":/root/.cache/cabal/packages \
-v "${HOME}/.cabal/store":/root/.local/state/cabal/store \
-v "${{ github.workspace }}/dist-newstyle":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:9.6.6 \
build all --only-dependencies --project-dir=/mnt
${{ env.cabal }} build all --only-dependencies --project-dir=/mnt
- name: Inspect caches
run: |
Expand All @@ -157,7 +143,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
with:
path: |
~/.cabal/packages
~/.cache/cabal
~/.cabal/store
${{ github.workspace }}/dist-newstyle
key: ${{ steps.cache.outputs.cache-primary-key }}
Expand All @@ -177,13 +163,8 @@ jobs:

- name: Build static binary
run: |
docker run \
-v "${{ github.workspace }}":/mnt/:ro \
-v "${HOME}/.cabal/packages":/root/.cache/cabal/packages \
-v "${HOME}/.cabal/store":/root/.local/state/cabal/store \
-v "${{ github.workspace }}/dist-newstyle":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:9.6.6 \
build exe:spex exe:spex-demo-petstore --enable-executable-static --project-dir=/mnt
${{ env.cabal }} build exe:spex exe:spex-demo-petstore \
--enable-executable-static --project-dir=/mnt
- name: Copy binaries
run: |
Expand Down
10 changes: 9 additions & 1 deletion release/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ static-build: build-image
-v "${PWD}/cache/cabal-cache-musl":/root/.cache/cabal \
-v "${PWD}/cache/cabal-store-musl":/root/.local/state/cabal/store \
-v "${PWD}/cache/dist-newstyle-musl":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:$(GHC_VERSION)
ghcr.io/spex-lang/static-build:$(GHC_VERSION) \
update hackage.haskell.org,@1729577343 \
docker run \
-v "${PWD}/..":/mnt/:ro \
-v "${PWD}/cache/cabal-cache-musl":/root/.cache/cabal \
-v "${PWD}/cache/cabal-store-musl":/root/.local/state/cabal/store \
-v "${PWD}/cache/dist-newstyle-musl":/mnt/dist-newstyle \
ghcr.io/spex-lang/static-build:$(GHC_VERSION) \
build exe:spex exe:spex-demo-petstore --enable-executable-static --project-dir=/mnt

build-image: Dockerfile
docker build --tag ghcr.io/spex-lang/static-build:$(GHC_VERSION) .
Expand Down

0 comments on commit 15e3467

Please sign in to comment.