Skip to content

Commit

Permalink
make sure cabal-install is compatible with Cabal
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
geekosaur committed Aug 20, 2024
1 parent 75711fc commit 65cd68a
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,20 @@ jobs:
if: matrix.ghc == env.GHC_FOR_SOLVER_BENCHMARKS
run: sh validate.sh $FLAGS -s solver-benchmarks-run

# Save the release sdists for later validation
# only do this on one platform/ghc because the sdists are the same everywhere
# NB. we only test cabal-install
- name: Create release sdists
if: runner.name == 'ubuntu-latest'
run: cabal sdist cabal-install

- name: Upload release sdists to workflow artifacts
if: runner.name == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: cabal-sdists-${{ matrix.ghc }}
path: dist-newstyle/sdist/*

validate-old-ghcs:
name: Validate old ghcs ${{ matrix.extra-ghc }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -390,6 +404,59 @@ jobs:
- name: Build using cabal HEAD
run: sh validate.sh ${{ env.COMMON_FLAGS }} --with-cabal ./cabal-head/cabal -s build

# Dogfood the generated sdists, to avoid bugs like https://github.com/haskell/cabal/issues/9833
# No caching, since the point is to verify they can be installed "from scratch"
dogfood-sdists:
name: Dogfood validated sdists on ${{ matrix.os }} ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
if: ${{ github.ref_name}} != 'master'
needs: validate
strategy:
matrix:
os: [ubuntu-latest]
# this should be kept up to date with the list above
# sharing these with the main validate job is possible but extremely painful; sadly,
# you can't simply reference another job's matrix
ghc:
[
"9.10.1",
"9.8.2",
"9.6.4",
"9.4.8",
"9.2.8",
"9.0.2",
"8.10.7",
"8.8.4",
]

steps:

- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: latest

- name: Download sdists from workflow artifacts
uses: actions/download-artifact@v4
with:
name: cabal-sdists
path: repo

- name: Install from sdists
run: |
# skip if a suitable Cabal isn't in the index (i.e. new major version, not released yet)
# we only want to test cabal-install, to ensure that it works with existing Cabals
tar xf repo/dist-newstyle/sdists/cabal-install.tar.gz cabal-install.cabal
# (don't look at this too closely)
ver="$(sed -n '/^[Vv]ersion:[ \t]*\([0-9][0-9]*\.[0-9][0-9]*\)\.[0-9.]*$/{;s//\1/;p;q;}' cabal-install.cabal)"
# why???
if cabal list --simple-output Cabal | grep -q "^Cabal $cbl\\.""; then
cabal install repo/dist-newstyle/sdists/cabal-install.tar.gz --prefer-oldest
else
exit 0
fi
prerelease-head:
name: Create a GitHub prerelease with the binary artifacts
runs-on: ubuntu-latest
Expand Down

0 comments on commit 65cd68a

Please sign in to comment.