Skip to content

Commit d8173dc

Browse files
committed
Add static pre-release job
Add a job that builds a statically linked cabal-install executable, and make it available for pre-releases. Resolves #9631.
1 parent adc283a commit d8173dc

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

.github/workflows/validate.yml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,71 @@ jobs:
271271
EXTRA_GHC: "/opt/ghc/${{ matrix.extra-ghc }}/bin/ghc-${{ matrix.extra-ghc }}"
272272
run: sh validate.sh ${{ env.COMMON_FLAGS }} --lib-only -s lib-suite-extras --extra-hc ${{ env.EXTRA_GHC }}
273273

274+
build-alpine:
275+
name: Build statically linked using alpine ghc-${{ matrix.ghc }}
276+
runs-on: "ubuntu-latest"
277+
container: "alpine:3.19"
278+
strategy:
279+
matrix:
280+
ghc: [ "${{ env.GHC_FOR_RELEASE }}" ]
281+
steps:
282+
- name: Install extra dependencies
283+
shell: sh
284+
run: |
285+
apk add bash curl sudo jq pkgconfig \
286+
zlib-dev zlib-static binutils-gold curl \
287+
gcc g++ gmp-dev libc-dev libffi-dev make \
288+
musl-dev ncurses-dev perl tar xz
289+
290+
- uses: actions/checkout@v4
291+
292+
# See https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#hackage-revisions
293+
- name: Manually supplied constraints/allow-newer
294+
if: ${{ github.event_name == 'workflow_dispatch' }}
295+
run: |
296+
echo 'allow-newer:' ${ALLOWNEWER} >> cabal.project.validate
297+
echo 'constraints:' ${CONSTRAINTS} >> cabal.project.validate
298+
299+
# See the following link for a breakdown of the following step
300+
# https://github.com/haskell/actions/issues/7#issuecomment-745697160
301+
- uses: actions/cache@v3
302+
with:
303+
# validate.sh uses a special build dir
304+
path: |
305+
${{ steps.setup-haskell.outputs.cabal-store }}
306+
dist-*
307+
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
308+
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
309+
310+
- uses: haskell-actions/setup@v2
311+
id: setup-haskell
312+
with:
313+
ghc-version: ${{ matrix.ghc }}
314+
cabal-version: latest # latest is mandatory for cabal-testsuite, see https://github.com/haskell/cabal/issues/8133
315+
316+
- name: Enable statically linked executables
317+
run: |
318+
echo 'executable-static: true' >> cabal.project.validate
319+
320+
- name: Build
321+
run: sh validate.sh $FLAGS -s build
322+
323+
- name: Tar cabal head executable
324+
run: |
325+
CABAL_EXEC=$(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ matrix.ghc }} --project-file=cabal.project.validate cabal-install:exe:cabal)
326+
# We have to tar the executable to preserve executable permissions
327+
# see https://github.com/actions/upload-artifact/issues/38
328+
export CABAL_EXEC_TAR="cabal-head-${{ runner.os }}-static-x86_64.tar.gz"
329+
tar -czvf $CABAL_EXEC_TAR -C $(dirname "$CABAL_EXEC") $(basename "$CABAL_EXEC")
330+
echo "CABAL_EXEC_TAR=$CABAL_EXEC_TAR" >> $GITHUB_ENV
331+
332+
- name: Upload cabal-install executable to workflow artifacts
333+
uses: actions/upload-artifact@v3
334+
with:
335+
name: cabal-${{ runner.os }}-static-x86_64
336+
path: ${{ env.CABAL_EXEC_TAR }}
337+
338+
274339
# The previous jobs use a released version of cabal to build cabal HEAD itself
275340
# This one uses the cabal HEAD generated executable in the previous step
276341
# to build itself again, as sanity check
@@ -334,7 +399,7 @@ jobs:
334399
if: github.ref == 'refs/heads/master'
335400

336401
# IMPORTANT! Any job added to the workflow should be added here too
337-
needs: [validate, validate-old-ghcs, dogfooding]
402+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
338403

339404
steps:
340405
- uses: actions/download-artifact@v3
@@ -359,6 +424,7 @@ jobs:
359424
files: |
360425
cabal-head-Windows-x86_64.tar.gz
361426
cabal-head-Linux-x86_64.tar.gz
427+
cabal-head-Linux-static-x86_64.tar.gz
362428
cabal-head-macOS-x86_64.tar.gz
363429
364430
# We use this job as a summary of the workflow
@@ -370,7 +436,7 @@ jobs:
370436
name: Validate post job
371437
runs-on: ubuntu-latest
372438
# IMPORTANT! Any job added to the workflow should be added here too
373-
needs: [validate, validate-old-ghcs, dogfooding]
439+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
374440

375441
steps:
376442
- run: |

0 commit comments

Comments
 (0)