Skip to content

Commit 9570602

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 9570602

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

.github/workflows/validate.yml

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

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

339401
steps:
340402
- uses: actions/download-artifact@v3
@@ -359,6 +421,7 @@ jobs:
359421
files: |
360422
cabal-head-Windows-x86_64.tar.gz
361423
cabal-head-Linux-x86_64.tar.gz
424+
cabal-head-Linux-static-x86_64.tar.gz
362425
cabal-head-macOS-x86_64.tar.gz
363426
364427
# We use this job as a summary of the workflow
@@ -370,7 +433,7 @@ jobs:
370433
name: Validate post job
371434
runs-on: ubuntu-latest
372435
# IMPORTANT! Any job added to the workflow should be added here too
373-
needs: [validate, validate-old-ghcs, dogfooding]
436+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
374437

375438
steps:
376439
- run: |

0 commit comments

Comments
 (0)