2018-08-06 21:00:58 +03:00
|
|
|
#!/usr/bin/env bash
|
2018-05-14 00:25:41 +03:00
|
|
|
|
2020-05-27 17:42:58 +03:00
|
|
|
# NOTE: Script for the CI builds. CI comes here from `.travis.yml`
|
|
|
|
|
2020-05-27 17:50:11 +03:00
|
|
|
GHCJS_BUILD(){
|
|
|
|
# NOTE: Function for GHCJS build that outputs its huge log into a file
|
|
|
|
|
|
|
|
# NOTE: Run the build into Log (log is too long for Travis)
|
|
|
|
"$@" &> "$ghcjsTmpLogFile"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-27 17:50:33 +03:00
|
|
|
SILENT(){
|
2020-05-28 17:42:01 +03:00
|
|
|
# NOTE: Function that silences the build process
|
2020-05-27 17:50:33 +03:00
|
|
|
# In normal mode outputs only the /nix/store paths
|
|
|
|
|
|
|
|
echo "Log: $ghcjsTmpLogFile"
|
|
|
|
# NOTE: Pass into the ghcjsbuild function the build command
|
|
|
|
if GHCJS_BUILD "$@"
|
|
|
|
then
|
|
|
|
|
|
|
|
# NOTE: Output log lines for stdout -> cachix caching
|
|
|
|
grep '^/nix/store/' "$ghcjsTmpLogFile"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# NOTE: Output log lines for stdout -> cachix caching
|
|
|
|
grep '^/nix/store/' "$ghcjsTmpLogFile"
|
|
|
|
|
|
|
|
# NOTE: Propagate the error state, fail the CI build
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:57:48 +03:00
|
|
|
BUILD_PROJECT(){
|
2018-08-06 21:00:58 +03:00
|
|
|
set -xe
|
2018-05-14 00:25:41 +03:00
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
2020-05-27 17:44:49 +03:00
|
|
|
# NOTE: If var not imported - set to the default value
|
|
|
|
GHCVERSION=${GHCVERSION:-ghc865}
|
|
|
|
rev=${rev:-nixpkgs-unstable}
|
|
|
|
NIX_PATH=${NIX_PATH:-"nixpkgs=https://github.com/nixos/nixpkgs/archive/$rev.tar.gz"}
|
|
|
|
export NIX_PATH
|
|
|
|
name=${name:-defaultBinaryName}
|
|
|
|
pkgName=${pkgName:-defaultPkgName}
|
|
|
|
failOnAllWarnings=${failOnAllWarnings:-'false'}
|
|
|
|
checkUnusedPackages=${checkUnusedPackages:-'false'}
|
|
|
|
doCoverage=${doCoverage:-'false'}
|
|
|
|
doHaddock=${doHaddock:-'false'}
|
|
|
|
doJailbreak=${doJailbreak:-'false'}
|
|
|
|
doCheck=${doCheck:-'true'}
|
|
|
|
doBenchmark=${doBenchmark:-'false'}
|
|
|
|
enableExecutableProfiling=${enableExecutableProfiling:-'false'}
|
|
|
|
enableLibraryProfiling=${enableLibraryProfiling:-'false'}
|
|
|
|
buildFromSdist=${buildFromSdist:-'false'}
|
|
|
|
buildStrictly=${buildStrictly:-'false'}
|
|
|
|
disableOptimization=${disableOptimization:-'true'}
|
|
|
|
buildStackProject=${buildStackProject:-'false'}
|
|
|
|
# NOTE: *Oprparse* key is redifined in the code further
|
|
|
|
generateOptparseApplicativeCompletion=${generateOptparseApplicativeCompletion:-'false'}
|
|
|
|
allowInconsistentDependencies=${allowInconsistentDependencies:-'false'}
|
|
|
|
ghcjsTmpLogFile=${ghcjsTmpLogFile:-'/tmp/ghcjsTmpLogFile.jog'}
|
|
|
|
ghcjsLogTailLength=${ghcjsLogTailLength:-'10000'}
|
|
|
|
|
2020-05-27 20:13:32 +03:00
|
|
|
|
|
|
|
if [ "$generateOptparseApplicativeCompletion" = 'true' ]
|
|
|
|
then
|
2020-05-28 17:50:37 +03:00
|
|
|
# NOTE: Enable shell completion generation
|
2020-05-27 20:13:32 +03:00
|
|
|
generateOptparseApplicativeCompletion="--arg generateOptparseApplicativeCompletion $name $pkgName"
|
|
|
|
else
|
2020-05-28 17:51:02 +03:00
|
|
|
# NOTE: Skip the shell completion generation
|
2020-05-27 20:13:32 +03:00
|
|
|
generateOptparseApplicativeCompletion=''
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-05-28 01:01:12 +03:00
|
|
|
if [ "$GHCVERSION" = "ghcjs" ]
|
|
|
|
then
|
|
|
|
|
2020-05-28 17:45:29 +03:00
|
|
|
# NOTE: GHCJS build
|
|
|
|
# By itself, GHCJS creates >65000 lines of log that are >4MB in size, so Travis terminates due to log size quota.
|
2020-05-28 01:01:12 +03:00
|
|
|
# nixbuild --quiet (x5) does not work on GHC JS build
|
|
|
|
# So there was a need to make it build.
|
2020-05-28 17:45:29 +03:00
|
|
|
# The solution is to silence the stdout
|
2020-05-28 01:01:12 +03:00
|
|
|
# But Travis then terminates on 10 min no stdout timeout
|
|
|
|
# so HACK: SILENT wrapper allows to surpress the huge log, while still preserves the Cachix caching ability in any case of the build
|
|
|
|
# On build failure outputs the last 10000 lines of log (that should be more then enough), and terminates
|
|
|
|
SILENT nix-build \
|
|
|
|
--arg failOnAllWarnings "$failOnAllWarnings" \
|
|
|
|
--arg buildStrictly "$buildStrictly" \
|
|
|
|
--arg checkUnusedPackages "$checkUnusedPackages" \
|
|
|
|
--arg doCoverage "$doCoverage" \
|
|
|
|
--arg doHaddock "$doHaddock" \
|
|
|
|
--arg doJailbreak "$doJailbreak" \
|
|
|
|
--arg doCheck "$doCheck" \
|
|
|
|
--arg doBenchmark "$doBenchmark" \
|
|
|
|
--arg enableExecutableProfiling "$enableExecutableProfiling" \
|
|
|
|
--arg enableLibraryProfiling "$enableLibraryProfiling" \
|
|
|
|
--arg buildFromSdist "$buildFromSdist" \
|
|
|
|
--arg buildStrictly "$buildStrictly" \
|
|
|
|
--arg disableOptimization "$disableOptimization" \
|
|
|
|
--arg buildStackProject "$buildStackProject" \
|
|
|
|
"$generateOptparseApplicativeCompletion" \
|
|
|
|
--arg allowInconsistentDependencies "$allowInconsistentDependencies" \
|
|
|
|
ghcjs \
|
|
|
|
"$@"
|
|
|
|
|
2020-05-28 01:00:14 +03:00
|
|
|
else
|
|
|
|
|
|
|
|
# NOTE: Normal GHC build
|
|
|
|
# NOTE: GHC sometimes produces logs so big - that Travis terminates builds, so multiple --quiet
|
|
|
|
nix-build \
|
|
|
|
--quiet --quiet \
|
|
|
|
--argstr compiler "$GHCVERSION" \
|
|
|
|
--arg failOnAllWarnings "$failOnAllWarnings" \
|
|
|
|
--arg buildStrictly "$buildStrictly" \
|
|
|
|
--arg checkUnusedPackages "$checkUnusedPackages" \
|
|
|
|
--arg doCoverage "$doCoverage" \
|
|
|
|
--arg doHaddock "$doHaddock" \
|
|
|
|
--arg doJailbreak "$doJailbreak" \
|
|
|
|
--arg doCheck "$doCheck" \
|
|
|
|
--arg doBenchmark "$doBenchmark" \
|
|
|
|
--arg enableExecutableProfiling "$enableExecutableProfiling" \
|
|
|
|
--arg enableLibraryProfiling "$enableLibraryProfiling" \
|
|
|
|
--arg buildFromSdist "$buildFromSdist" \
|
|
|
|
--arg buildStrictly "$buildStrictly" \
|
|
|
|
--arg disableOptimization "$disableOptimization" \
|
|
|
|
--arg buildStackProject "$buildStackProject" \
|
|
|
|
"$generateOptparseApplicativeCompletion" \
|
|
|
|
--arg allowInconsistentDependencies "$allowInconsistentDependencies" \
|
|
|
|
"$@"
|
|
|
|
|
|
|
|
fi
|
2020-05-28 00:57:48 +03:00
|
|
|
}
|
|
|
|
|
2020-05-28 00:57:13 +03:00
|
|
|
MAIN() {
|
|
|
|
|
|
|
|
# NOTE: Secrets are not shared to PRs from forks
|
|
|
|
# NOTE: nix-build | cachix push <name> - uploads binaries, runs&works only in the branches of the main repository, so for PRs - else case runs
|
|
|
|
|
|
|
|
if [ ! "$CACHIX_SIGNING_KEY" = "" ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
# NOTE: Build of the inside repo branch - enable push Cachix cache
|
|
|
|
BUILD_PROJECT | cachix push "$name"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# NOTE: Build of the side repo/PR - can not push Cachix cache
|
|
|
|
BUILD_PROJECT
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# NOTE: Run the entry function of the script
|
|
|
|
MAIN
|