Skip to content

Commit 0423c5f

Browse files
committed
make sure cabal-install is compatible with Cabal
See #9833 If a ghc ships with a compatible Cabal, it will be preferred by the solver on `cabal install cabal-install`; the new `cabal-install` should in fact be compatible. So we test this on release branches that have had at least one release on Hackage. (Ideally we'd check ghc instead, but we can't do that from GHA. Even checking Hackage is pretty painful.)
1 parent 34bef80 commit 0423c5f

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

.github/workflows/validate.yml

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ jobs:
221221
if: matrix.ghc == env.GHC_FOR_SOLVER_BENCHMARKS
222222
run: sh validate.sh $FLAGS -s solver-benchmarks-run
223223

224+
# Save the release sdist for later validation
225+
# only do this on one platform/ghc because the sdists are the same everywhere
226+
# NB. we only test cabal-install
227+
- name: Create release sdist
228+
if: runner.os == 'Linux' && matrix.ghc == env.GHC_FOR_RELEASE
229+
run: cabal sdist cabal-install
230+
231+
- name: Upload release sdist to workflow artifacts
232+
if: runner.os == 'Linux' && matrix.ghc == env.GHC_FOR_RELEASE
233+
uses: actions/upload-artifact@v4
234+
with:
235+
name: cabal-sdists
236+
path: dist-newstyle/sdist/*
237+
224238
validate-old-ghcs:
225239
name: Validate old ghcs ${{ matrix.extra-ghc }}
226240
runs-on: ubuntu-latest
@@ -390,12 +404,71 @@ jobs:
390404
- name: Build using cabal HEAD
391405
run: sh validate.sh ${{ env.COMMON_FLAGS }} --with-cabal ./cabal-head/cabal -s build
392406

407+
# Dogfood the generated sdist, to avoid bugs like https://github.com/haskell/cabal/issues/9833
408+
# No caching, since the point is to verify they can be installed "from scratch"
409+
dogfood-sdists:
410+
name: Dogfood validated sdist on ${{ matrix.os }} ghc-${{ matrix.ghc }}
411+
runs-on: ${{ matrix.os }}
412+
if: ${{ github.ref_name }} != 'master' && ${{ github.head_ref }} != 'master'
413+
needs: validate
414+
strategy:
415+
matrix:
416+
os: [ubuntu-latest]
417+
# this should be kept up to date with the list above
418+
# sharing these with the main validate job is possible but extremely painful; sadly,
419+
# you can't simply reference another job's matrix
420+
ghc:
421+
[
422+
"9.10.1",
423+
"9.8.2",
424+
"9.6.4",
425+
"9.4.8",
426+
"9.2.8",
427+
"9.0.2",
428+
"8.10.7",
429+
"8.8.4",
430+
]
431+
432+
steps:
433+
434+
- uses: haskell-actions/setup@v2
435+
id: setup-haskell
436+
with:
437+
ghc-version: ${{ matrix.ghc }}
438+
cabal-version: latest
439+
440+
- name: Download sdist from workflow artifacts
441+
uses: actions/download-artifact@v4
442+
with:
443+
name: cabal-sdists
444+
path: .
445+
446+
- name: Install from sdist
447+
run: |
448+
echo "running for ${{ github.head_ref }}"
449+
# skip if a suitable Cabal isn't in the index (i.e. new major version, not released yet)
450+
# we only want to test cabal-install, to ensure that it works with existing Cabals
451+
sdist="$(ls cabal-install-*.tar.gz | sed -n '/^cabal-install-[0-9.]*\.tar\.gz$/{;p;q;}')"
452+
# extract the cabal-install major version
453+
# this could be done from the sdist's name as well, and possibly should
454+
tar xfz "$sdist" "${sdist/.tar.gz}/cabal-install.cabal"
455+
# (don't look at this too closely)
456+
ver="$(sed -n '/^[Vv]ersion:[ \t]*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9.]*$/{;s//\1/;p;q;}' "${sdist/.tar.gz}/cabal-install.cabal")"
457+
# why does `cabal list` force me to do this???
458+
if cabal list --simple-output Cabal | grep -q "^Cabal $cbl\\."; then
459+
cabal build "$sdist" --prefer-oldest
460+
else
461+
echo No released Cabal version to test against.
462+
exit 0
463+
fi
464+
393465
prerelease-head:
394466
name: Create a GitHub prerelease with the binary artifacts
395467
runs-on: ubuntu-latest
396468
if: github.ref == 'refs/heads/master'
397469

398470
# IMPORTANT! Any job added to the workflow should be added here too
471+
# NB: dogfood-sdists isn't here because it's pointless on master
399472
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
400473

401474
steps:
@@ -437,7 +510,7 @@ jobs:
437510
name: Validate post job
438511
runs-on: ubuntu-latest
439512
# IMPORTANT! Any job added to the workflow should be added here too
440-
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]
513+
needs: [validate, validate-old-ghcs, build-alpine, dogfooding, dogfood-sdists]
441514

442515
steps:
443516
- run: |

0 commit comments

Comments
 (0)