Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/scripts/assert-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Usage: ./assert-version.sh <package-name> <expected-version>

set -euo pipefail

PKG="$1"
EXPECTED="$2"
FREEZE_FILE="cabal.project.freeze"

cabal freeze -v0
[[ -f "$FREEZE_FILE" ]] || { echo "Error: Missing freeze file"; exit 1; }

if grep -q "any.$PKG ==$EXPECTED" "$FREEZE_FILE"; then
echo "Assertion passed: $PKG's version is $EXPECTED"
rm "$FREEZE_FILE"
else
echo "Assertion failed: $PKG's version is NOT $EXPECTED"
cat "$FREEZE_FILE" | grep "any.$PKG"
rm "$FREEZE_FILE"
exit 1
fi
22 changes: 17 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:

- uses: actions/checkout@v3

- name: Add scripts to GITHUB_PATH
run: |
chmod +x .github/scripts/*
echo "${{ github.workspace }}/.github/scripts" >> $GITHUB_PATH

- name: Set up GHC and Cabal
uses: haskell-actions/setup@v2
with:
Expand All @@ -56,11 +61,17 @@ jobs:

- name: Import Stackage snapshot
run: |
echo "import: https://www.stackage.org/${{ matrix.stackage }}/cabal.config" >> cabal.project.local
LOCAL_CONFIG="stackage-local.config"
curl -sSL https://www.stackage.org/${{ matrix.stackage }}/cabal.config > $LOCAL_CONFIG

# Remove any existing constraint on this package from the Stackage snapshot.
sed -i "/^[[:space:]]*json-rpc-server[[:space:]]*==/d" $LOCAL_CONFIG

echo "import: $LOCAL_CONFIG" >> cabal.project.local

- name: Constrain aeson version
- name: Assert aeson version
run: |
echo "constraints: aeson==${{ matrix.aeson }}" >> cabal.project.local
assert-version.sh aeson "${{ matrix.aeson }}"

- name: Install dependencies
run: cabal v2-build --only-dependencies --enable-tests
Expand All @@ -80,13 +91,14 @@ jobs:
- name: Verify that sdist installs
run: |
SDIST=$(grep '^version:' json-rpc-server.cabal | awk '{print "json-rpc-server-" $2 ".tar.gz"}')
cp cabal.project.local dist-newstyle/sdist/
cp cabal.project.local stackage-local.config dist-newstyle/sdist/
cd dist-newstyle/sdist/
if [ -f "$SDIST" ]; then
tar xzf "$SDIST"
PKGDIR=$(basename "$SDIST" .tar.gz)
mv cabal.project.local "$PKGDIR"
mv cabal.project.local stackage-local.config "$PKGDIR"
cd "$PKGDIR"
assert-version.sh aeson "${{ matrix.aeson }}"
cabal v2-build all
else
echo "expected '$SDIST' not found"
Expand Down
Loading