dev: add new freeze file helper script: scripts/cabal-freeze-update.sh

This was reworked from an earlier version based on feedback from @solomon-b : https://github.com/hasura/graphql-engine-mono/pull/4618

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4646
GitOrigin-RevId: c54469a2d8466471e6d5c25a0cc80e26d94ce7c7
This commit is contained in:
Brandon Simmons 2022-06-08 17:13:10 -04:00 committed by hasura-bot
parent 623b856101
commit 45af456fb3
2 changed files with 158 additions and 113 deletions

View File

@ -1,34 +1,25 @@
active-repositories: hackage.haskell.org:merge
constraints: any.Cabal ==3.2.1.0,
Cabal -bundled-binary-generic,
any.Diff ==0.4.1,
any.HTTP ==4000.3.16,
HTTP -conduit10 -mtl1 +network-uri -warn-as-error -warp-tests,
any.HUnit ==1.6.2.0,
any.OneTuple ==0.3.1,
any.Only ==0.1,
any.PyF ==0.10.2.0,
PyF -python_test,
any.QuickCheck ==2.14.2,
QuickCheck -old-random +templatehaskell,
any.RSA ==2.4.1,
any.SHA ==1.6.4.4,
SHA -exe,
any.Spock ==0.14.0.0,
any.Spock-core ==0.14.0.0,
any.StateVar ==1.2.2,
any.adjunctions ==4.4,
any.aeson ==2.0.3.0,
aeson -bytestring-builder +cffi -developer -fast,
any.aeson-casing ==0.2.0.0,
any.aeson-pretty ==0.8.9,
aeson-pretty -lib-only,
any.aeson-qq ==0.8.4,
any.alex ==3.2.7.1,
any.ansi-terminal ==0.11.1,
ansi-terminal -example,
any.ansi-wl-pprint ==0.6.9,
ansi-wl-pprint -example,
any.appar ==0.1.8,
any.array ==0.5.4.0,
any.asn1-encoding ==0.9.6,
@ -36,13 +27,9 @@ constraints: any.Cabal ==3.2.1.0,
any.asn1-types ==0.3.4,
any.assoc ==1.0.2,
any.async ==2.2.4,
async -bench,
any.atomic-primops ==0.8.4,
atomic-primops -debug,
any.attoparsec ==0.14.4,
attoparsec -developer,
any.attoparsec-iso8601 ==1.0.2.1,
attoparsec-iso8601 -developer -fast,
any.authenticate-oauth ==1.7,
any.auto-update ==0.1.6,
any.autodocodec ==0.1.0.0,
@ -56,41 +43,32 @@ constraints: any.Cabal ==3.2.1.0,
any.base64-bytestring ==1.2.1.0,
any.basement ==0.0.12,
any.bifunctors ==5.5.11,
bifunctors +semigroups +tagged,
any.binary ==0.8.8.0,
any.binary-parser ==0.5.7.1,
any.blaze-builder ==0.4.2.2,
any.blaze-html ==0.9.1.2,
any.blaze-markup ==0.8.2.8,
any.blaze-textual ==0.2.2.1,
blaze-textual -developer -integer-simple +native,
any.boring ==0.2,
any.bsb-http-chunked ==0.0.0.4,
any.bytebuild ==0.3.9.0,
bytebuild -checked,
any.byteorder ==1.0.4,
any.byteslice ==0.2.7.0,
byteslice +avoid-rawmemchr,
any.bytesmith ==0.3.8.0,
any.bytestring ==0.10.12.0,
any.bytestring-builder ==0.10.8.2.0,
bytestring-builder +bytestring_has_builder,
any.bytestring-lexing ==0.5.0.8,
any.bytestring-strict-builder ==0.4.5.5,
any.cabal-doctest ==1.0.9,
any.call-stack ==0.4.0,
any.case-insensitive ==1.2.1.0,
any.cereal ==0.5.8.2,
cereal -bytestring-builder,
any.charset ==0.3.9,
any.ci-info ==0.1.0.0,
any.clock ==0.8.3,
clock -llvm,
any.cmdargs ==0.10.21,
cmdargs +quotation -testprog,
any.colour ==2.3.6,
any.comonad ==5.0.8,
comonad +containers +distributive +indexed-traversable,
any.concise ==0.1.0.1,
any.concurrent-output ==1.10.15,
any.conduit ==1.3.4.2,
@ -98,21 +76,16 @@ constraints: any.Cabal ==3.2.1.0,
any.connection ==0.3.1,
any.constraints ==0.13.3,
any.constraints-extras ==0.3.2.1,
constraints-extras +build-readme,
any.containers ==0.6.5.1,
any.contiguous ==0.6.1.1,
any.contravariant ==1.5.5,
contravariant +semigroups +statevar +tagged,
any.cookie ==0.4.5,
any.cron ==0.7.0,
cron -lib-werror,
any.crypto-api ==0.13.3,
crypto-api -all_cpolys,
any.crypto-pubkey-types ==0.4.3,
any.cryptohash-md5 ==0.11.101.0,
any.cryptohash-sha1 ==0.11.101.0,
any.cryptonite ==0.29,
cryptonite -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq -support_pclmuldq +support_rdrand -support_sse +use_target_attributes,
any.data-bword ==0.1.0.1,
any.data-checked ==0.3,
any.data-default ==0.7.1.1,
@ -133,17 +106,13 @@ constraints: any.Cabal ==3.2.1.0,
any.dependent-sum ==0.7.1.0,
any.directory ==1.3.6.0,
any.distributive ==0.6.2.1,
distributive +semigroups +tagged,
any.dlist ==1.0,
dlist -werror,
any.double-conversion ==2.0.4.1,
double-conversion -developer,
any.easy-file ==0.2.2,
any.either ==5.0.1.1,
any.ekg-core ==0.1.1.7,
any.ekg-json ==0.1.0.7,
any.entropy ==0.4.1.7,
entropy -halvm,
any.erf ==2.0.0.0,
any.errors ==2.3.0,
any.exceptions ==0.10.4,
@ -156,32 +125,26 @@ constraints: any.Cabal ==3.2.1.0,
any.foldl ==1.4.12,
any.formatting ==7.1.3,
any.free ==5.1.7,
any.generic-monoid ==0.1.0.1,
any.generics-sop ==0.5.1.2,
any.ghc ==8.10.7,
any.ghc-boot ==8.10.7,
any.ghc-boot-th ==8.10.7,
any.ghc-heap ==8.10.7,
any.ghc-heap-view ==0.6.3,
ghc-heap-view -prim-supports-any,
any.ghc-prim ==0.6.1,
any.ghci ==8.10.7,
any.graphql-parser ==0.2.0.0,
any.happy ==1.20.0,
any.hashable ==1.3.5.0,
hashable -examples +integer-gmp +sse2 -sse41,
any.hashtables ==1.2.4.2,
hashtables -bounds-checking -debug -detailed-profiling -portable -sse42 +unsafe-tricks,
any.haskell-lexer ==1.1,
any.haskell-src-exts ==1.23.1,
any.haskell-src-meta ==0.8.9,
any.hedgehog ==1.1.1,
any.hedis ==0.15.1,
hedis -dev,
any.hourglass ==0.2.12,
any.hpc ==0.6.1.0,
any.hsc2hs ==0.68.8,
hsc2hs -in-ghc-tree,
any.hscolour ==1.24.4,
any.hspec ==2.9.4,
any.hspec-core ==2.9.4,
@ -190,20 +153,14 @@ constraints: any.Cabal ==3.2.1.0,
any.hspec-expectations-lifted ==0.10.0,
any.hspec-expectations-pretty-diff ==0.7.2.6,
any.hspec-hedgehog ==0.0.1.2,
any.hspec-wai ==0.11.0,
any.hspec-wai-json ==0.11.0,
any.http-api-data ==0.4.3,
http-api-data -use-text-show,
any.http-client ==0.7.11,
http-client +network-uri,
any.http-client-tls ==0.3.6.1,
any.http-conduit ==2.3.8,
http-conduit +aeson,
any.http-date ==0.0.11,
any.http-media ==0.8.0.0,
any.http-types ==0.12.3,
any.http2 ==3.0.3,
http2 -devel -doc -h2spec,
any.hvect ==0.4.0.1,
any.immortal ==0.2.2.1,
any.indexed-profunctors ==0.1.1,
@ -211,38 +168,29 @@ constraints: any.Cabal ==3.2.1.0,
any.indexed-traversable-instances ==0.1.1,
any.insert-ordered-containers ==0.2.5.1,
any.inspection-testing ==0.4.6.0,
inspection-testing -more-tests -old-text-tests,
any.integer-gmp ==1.0.3.0,
any.integer-logarithms ==1.0.3.1,
integer-logarithms -check-bounds +integer-gmp,
any.invariant ==0.5.5,
any.ip ==1.7.4,
any.iproute ==1.7.12,
any.jose ==0.9,
jose -demos,
any.kan-extensions ==5.2.3,
any.keys ==3.12.3,
any.kriti-lang ==0.3.1,
any.lens ==5.1,
lens -benchmark-uniplate -dump-splices +inlining -j +test-hunit +test-properties +test-templates +trustworthy,
any.lens-aeson ==1.1.3,
any.libyaml ==0.1.2,
libyaml -no-unicode -system-libyaml,
any.lifted-async ==0.10.2.2,
any.lifted-base ==0.2.3.12,
any.list-t ==1.0.5.1,
any.logict ==0.7.0.3,
any.megaparsec ==9.2.0,
megaparsec -dev,
any.memory ==0.16.0,
memory +support_basement +support_bytestring +support_deepseq +support_foundation,
any.mime-types ==0.1.0.9,
any.mmorph ==1.2.0,
any.monad-control ==1.0.3.1,
any.monad-logger ==0.3.36,
monad-logger +template_haskell,
any.monad-loops ==0.4.3,
monad-loops +base4,
any.monad-time ==0.3.1.0,
any.monad-validate ==1.2.0.0,
any.mono-traversable ==1.0.15.3,
@ -252,16 +200,12 @@ constraints: any.Cabal ==3.2.1.0,
any.morpheus-graphql-core ==0.19.3,
any.mtl ==2.2.2,
any.mtl-compat ==0.2.2,
mtl-compat -two-point-one -two-point-two,
any.mustache ==2.4.0,
any.mysql ==0.2.1,
mysql -developer,
any.mysql-simple ==0.4.7.1,
mysql-simple -developer,
any.natural-arithmetic ==0.1.2.0,
any.natural-transformation ==0.4,
any.network ==3.1.2.7,
network -devel,
any.network-bsd ==2.8.1.0,
any.network-byte-order ==0.1.6,
any.network-info ==0.2.1,
@ -273,36 +217,25 @@ constraints: any.Cabal ==3.2.1.0,
any.old-time ==1.1.0.3,
any.openapi3 ==3.2.1,
any.optics-core ==0.4,
optics-core -explicit-generic-labels,
any.optics-extra ==0.4,
any.optics-th ==0.4,
any.optparse-applicative ==0.16.1.0,
optparse-applicative +process,
any.optparse-generic ==1.4.7,
any.parallel ==3.2.2.0,
any.parsec ==3.1.14.0 || ==3.1.15.0,
any.parser-combinators ==1.3.0,
parser-combinators -dev,
any.parsers ==0.12.10,
parsers +attoparsec +binary +parsec,
any.pcre-light ==0.4.1.0,
pcre-light -old_base -use-pkg-config,
any.pem ==0.2.4,
any.pg-client ==0.1.0,
any.pointed ==5.0.3,
pointed +comonad +containers +kan-extensions +semigroupoids +semigroups +stm +tagged +transformers +unordered-containers,
any.port-utils ==0.2.1.0,
any.postgres-options ==0.2.0.0,
any.postgresql-binary ==0.12.4.2,
any.postgresql-libpq ==0.9.4.3,
postgresql-libpq -use-pkg-config,
any.postgresql-simple ==0.6.4,
any.pretty ==1.1.3.6,
any.pretty-show ==1.10,
any.pretty-simple ==4.0.0.0,
pretty-simple -buildexample -buildexe,
any.prettyprinter ==1.7.1,
prettyprinter -buildreadme +text,
any.prettyprinter-ansi-terminal ==1.1.3,
any.primitive ==0.7.3.0,
any.primitive-addr ==0.1.0.2,
@ -313,34 +246,25 @@ constraints: any.Cabal ==3.2.1.0,
any.profunctors ==5.6.2,
any.psqueues ==0.2.7.3,
any.quickcheck-instances ==0.3.27,
quickcheck-instances -bytestring-builder,
any.quickcheck-io ==0.2.0,
any.random ==1.2.1,
any.reflection ==2.1.6,
reflection -slow +template-haskell,
any.regex-base ==0.94.0.2,
any.regex-tdfa ==1.3.1.1,
regex-tdfa -force-o2,
any.relude ==1.0.0.1,
any.reroute ==0.6.0.0,
any.resource-pool ==0.2.3.2,
resource-pool -developer,
any.resourcet ==1.2.4.3,
any.retry ==0.9.1.0,
retry -lib-werror,
any.rts ==1.0.1,
any.run-st ==0.1.1.0,
any.safe ==0.3.19,
any.safe-exceptions ==0.1.7.2,
any.scanner ==0.3.1,
any.scientific ==0.3.7.0,
scientific -bytestring-builder -integer-simple,
any.semialign ==1.2.0.1,
semialign +semigroupoids,
any.semigroupoids ==5.3.7,
semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers,
any.semigroups ==0.20,
semigroups +binary +bytestring -bytestring-builder +containers +deepseq +hashable +tagged +template-haskell +text +transformers +unordered-containers,
any.semver ==0.4.0.1,
any.servant ==0.19,
any.servant-client ==0.19,
@ -349,43 +273,33 @@ constraints: any.Cabal ==3.2.1.0,
any.servant-server ==0.19.1,
any.setenv ==0.1.1.3,
any.shakespeare ==2.0.25.1,
shakespeare -test_coffee -test_export -test_roy,
any.simple-sendfile ==0.2.30,
simple-sendfile +allow-bsd,
any.singleton-bool ==0.1.6,
any.socks ==0.6.1,
any.some ==1.0.3,
some +newtype-unsafe,
any.sop-core ==0.5.0.2,
any.split ==0.2.3.4,
any.splitmix ==0.1.0.4,
splitmix -optimised-mixer,
any.stm ==2.5.0.1,
any.stm-chans ==3.0.0.6,
any.stm-containers ==1.2,
any.stm-hamt ==1.2.0.7,
any.streaming-commons ==0.2.2.4,
streaming-commons -use-bytestring-builder,
any.strict ==0.4.0.1,
strict +assoc,
any.string-conversions ==0.4.0.1,
any.superbuffer ==0.3.1.1,
any.syb ==0.7.2.1,
any.system-filepath ==0.4.14,
any.tagged ==0.8.6.1,
tagged +deepseq +transformers,
any.template-haskell ==2.16.0.0,
any.temporary ==1.3,
any.terminal-size ==0.3.2.1,
any.terminfo ==0.4.1.4,
any.text ==1.2.3.2 || ==1.2.4.1,
text -developer -integer-simple,
any.text-builder ==0.6.6.3,
any.text-conversions ==0.3.1,
any.text-latin1 ==0.3.1,
any.text-printer ==0.5.0.2,
any.text-short ==0.1.5,
text-short -asserts,
any.tf-random ==0.5,
any.th-abstraction ==0.4.3.0,
any.th-compat ==0.1.3,
@ -395,37 +309,26 @@ constraints: any.Cabal ==3.2.1.0,
any.th-orphans ==0.13.12,
any.th-reify-many ==0.1.10,
any.these ==1.1.1.1,
these +assoc,
any.time ==1.9.3,
any.time-compat ==1.9.6.1,
time-compat -old-locale,
any.time-locale-compat ==0.1.1.5,
time-locale-compat -old-locale,
any.time-manager ==0.0.0,
any.tls ==1.5.7,
tls +compat -hans +network,
any.tmp-postgres ==1.34.1.0,
any.transformers ==0.5.6.2,
any.transformers-base ==0.4.6,
transformers-base +orphaninstances,
any.transformers-compat ==0.6.6,
transformers-compat -five +five-three -four +generic-deriving +mtl -three -two,
any.tuples ==0.1.0.0,
any.type-equality ==1,
any.type-hint ==0.1,
any.typed-process ==0.2.8.0,
any.unbounded-delays ==0.1.1.1,
any.unicode-show ==0.1.1.0,
any.unix ==2.7.2.2,
any.unix-compat ==0.5.4,
unix-compat -old-time,
any.unix-time ==0.4.7,
any.unliftio ==0.2.21.0,
any.unliftio-core ==0.2.0.1,
any.unordered-containers ==0.2.15.0,
unordered-containers -debug,
any.uri-encode ==1.5.0.7,
uri-encode +network-uri -tools,
any.url ==2.1.3,
any.utf8-string ==1.0.2,
any.uuid ==1.3.15,
@ -434,40 +337,26 @@ constraints: any.Cabal ==3.2.1.0,
any.validity ==0.12.0.0,
any.validity-scientific ==0.2.0.3,
any.vault ==0.3.1.5,
vault +useghc,
any.vector ==0.12.3.1,
vector +boundschecks -internalchecks -unsafechecks -wall,
any.vector-algorithms ==0.8.0.4,
vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks,
any.vector-instances ==3.4,
vector-instances +hashable,
any.void ==0.7.3,
void -safe,
any.wai ==3.2.3,
any.wai-extra ==3.1.8,
any.wai-app-static ==3.1.7.4,
wai-extra -build-example,
any.wai-extra ==3.1.8,
any.wai-logger ==2.4.0,
any.warp ==3.3.19,
warp +allow-sendfilefd -network-bytestring -warp-debug,
any.wcwidth ==0.0.2,
wcwidth -cli +split-base,
any.websockets ==0.12.7.3,
websockets -example,
any.wide-word ==0.1.1.2,
any.witch ==1.0.0.1,
witch -pedantic,
any.witherable ==0.4.2,
any.wl-pprint-annotated ==0.1.0.1,
any.word8 ==0.1.3,
any.wreq ==0.5.3.3,
wreq -aws -developer +doctest -httpbin,
any.x509 ==1.7.6,
any.x509-store ==1.6.9,
any.x509-system ==1.6.7,
any.x509-validation ==1.6.12,
any.yaml ==0.11.7.0,
yaml +no-examples +no-exe,
any.zlib ==0.6.2.3,
zlib -bundled-c-zlib -non-blocking-ffi -pkg-config
index-state: hackage.haskell.org 2022-05-10T04:52:26Z
index-state: hackage.haskell.org 2022-06-06T19:18:14Z

156
scripts/cabal-freeze-update.sh Executable file
View File

@ -0,0 +1,156 @@
#!/usr/bin/env bash
set -euo pipefail
shopt -s globstar
help(){
cat << EOF
USAGE: $0 (--all | [--target <package_name> <package_version>]... )
This script is to help updating the freeze file to bring in newer versions of
dependencies. It takes care of a few gotchas and footguns for you (see source).
The simplest mode, when called with '--all', removes all existing constraints
and finds a brand new build plan and freezes it.
Instead if you want to upgrade one or more particular packages, while keeping
as many of the other dependencies the same as possible, you can use '--target
foo 1.2.3.4'. This may take a bit of time, and might fail to find a plan,
especially if you pass more than one target.
If you want to "normalize" the freeze file (for example removing any extraneous
items or redoing the formatting), for now you can pass an existing package
version to the --target flag.
EOF
}
echo_pretty() { echo ">>> $(tput setaf 2)$1$(tput sgr0)" ; }
echo_error() { echo ">>> $(tput setaf 1)$1$(tput sgr0)" ; }
echo_warn() { echo ">>> $(tput setaf 3)$1$(tput sgr0)" ; }
# absolute paths to files we care about:
REPO_TOPLEVEL=$(git rev-parse --show-toplevel)
FREEZE_FILE="$REPO_TOPLEVEL/cabal.project.freeze"
# Make sure freeze file isn't dirty so we can freely write to it:
if ! git diff --quiet HEAD "$FREEZE_FILE" ; then
echo_error "It looks like cabal.project.freeze already has some changes, which we don't want to clobber. Please commit or remove them."
exit 1
fi
### Argument parsing / exit handling
# map of: package_name->package_version
declare -A PACKAGE_TARGETS
UPDATE_ALL=""
if [[ $# -eq 0 ]]; then
echo_error "expecting at least one argument"
help
exit 1
fi
while [[ $# -gt 0 ]]; do
case $1 in
--target)
PACKAGE_TARGETS["$2"]="$3"
shift ; shift ; shift # past values
;;
--all)
UPDATE_ALL=YES
shift # past argument
;;
*)
echo_error "Unknown option $1"
help
exit 1
;;
esac
done
# In case something goes wrong once we start messing with freeze file...
err_report() {
echo_error "Error on line $(caller)"
echo_error "Freeze file is probably messed up, so you probably want to:"
echo_error " $ git checkout $FREEZE_FILE"
}
trap '[[ $? != 0 ]] && err_report' EXIT
if [ "$UPDATE_ALL" = "YES" ]; then
### Maybe just updating all dependencies
# Remove all constraints and write new build plan
rm "$FREEZE_FILE"
cabal freeze --enable-tests --enable-benchmarks --minimize-conflict-set
else
echo_pretty "Doing 'cabal update'... "
# First we need to remove the frozen `index-state` so that `cabal update` works
sed -i '/^index-state:.*/d' "$FREEZE_FILE"
cabal update
echo_pretty "Trying to come up with a new plan with a minimal delta. This may take some time."
# Replace target dependencies with requested versions:
for package_name in "${!PACKAGE_TARGETS[@]}"; do
package_version="${PACKAGE_TARGETS[$package_name]}";
# Remove existing target entries (baked in flag lines may not be present):
sed -ri "/\s+any.$package_name ==/d" "$FREEZE_FILE"
sed -ri "/\s+$package_name /d" "$FREEZE_FILE" # baked in flags
# add back target version
sed -i "\$s/\$/, $package_name ==$package_version/" "$FREEZE_FILE"
done
freeze_line_count_orig=$(wc -l "$FREEZE_FILE" | awk '{print $1}')
freeze_line_count_prev=$freeze_line_count_orig # mutable
while : ; do
if out=$(cabal freeze --enable-tests --enable-benchmarks --minimize-conflict-set 2>&1); then
break
else
# newline-separated:
conflict_set=$(echo "$out" | tr '\n' ' ' | sed -r 's/^.*conflict set: ([^\)]+)\).*$/\1/' | tr ',' '\n' | tr -d ' ')
if [ -z "$conflict_set" ]; then
echo_error "Something went wrong :/"
exit 77
fi
# omit target packages:
for package_name in "${!PACKAGE_TARGETS[@]}"; do
conflict_set=$(echo "$conflict_set" | sed "/^$package_name$/d")
done
# filter conflicts from the freeze file
while IFS= read -r package_name; do
sed -ri "/\s+any.$package_name ==/d" "$FREEZE_FILE"
sed -ri "/\s+$package_name /d" "$FREEZE_FILE" # baked in flags
done <<< "$conflict_set"
freeze_line_count=$(wc -l "$FREEZE_FILE" | awk '{print $1}')
if [ "$freeze_line_count" -eq "$freeze_line_count_prev" ]; then
# No longer making progress, so...
echo_error "It looks like we can't find a build plan :( Exiting"
exit 31
else
echo -ne "Relaxed $((freeze_line_count_orig-freeze_line_count)) constraints so far...\r"
freeze_line_count_prev=$freeze_line_count
# ...and try again
fi
fi
done
echo
fi
### Finally do a little cleanup/normalizing:
# Remove graphql engine internal mono-repo packages. This doesn't matter unless
# we happen to bump the version number in one of our cabal files.
sed -ri "/\s+graphql-engine/d" "$FREEZE_FILE"
# Remove all flags from the freeze file. By default cabal bakes in the default
# flags for a library; This makes it very difficult to review the freeze file
# to determine where we might be either intentionally or unintentionally
# overriding default flags, and it's easy for flags from a local developers
# environment to get accidentally committed. This is checked in CI. For
# discussion, see:
# https://hasurahq.slack.com/archives/CV3UR1MT2/p1654544760362949
# https://github.com/hasura/graphql-engine-mono/pull/4618
sed -ri "/\s+\S+ [+-]/d" "$FREEZE_FILE"
echo_pretty "Success!(?) Be sure to check that we were actually able to get a plan with package versions you hoped for"