Skip to content

Commit 7937ef7

Browse files
TeofilCMikolaj
authored andcommitted
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 663e98f commit 7937ef7

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

.github/workflows/validate.yml

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

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

348410
# IMPORTANT! Any job added to the workflow should be added here too
349-
needs: [validate, validate-old-ghcs, dogfooding]
411+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
350412

351413
steps:
352414
- uses: actions/download-artifact@v3
@@ -357,6 +419,10 @@ jobs:
357419
with:
358420
name: cabal-Linux-x86_64
359421

422+
- uses: actions/download-artifact@v3
423+
with:
424+
name: cabal-Linux-static-x86_64
425+
360426
- uses: actions/download-artifact@v3
361427
with:
362428
name: cabal-macOS-x86_64
@@ -371,6 +437,7 @@ jobs:
371437
files: |
372438
cabal-head-Windows-x86_64.tar.gz
373439
cabal-head-Linux-x86_64.tar.gz
440+
cabal-head-Linux-static-x86_64.tar.gz
374441
cabal-head-macOS-x86_64.tar.gz
375442
376443
# We use this job as a summary of the workflow
@@ -382,7 +449,7 @@ jobs:
382449
name: Validate post job
383450
runs-on: ubuntu-latest
384451
# IMPORTANT! Any job added to the workflow should be added here too
385-
needs: [validate, validate-old-ghcs, dogfooding]
452+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
386453

387454
steps:
388455
- run: |

0 commit comments

Comments
 (0)