Skip to content

CI: refactor CI setup config #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 23, 2020
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
111 changes: 57 additions & 54 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,91 @@ version: ~> 1.0

language: nix

sudo: required # 2020-05-26: NOTE: This mode is deprecated, but still offers 7.5 GB RAM instead of the default 4GB
sudo: required # 2020-05-26: This mode is deprecated, but still offers 7.5 GB RAM instead of the default 4GB

git:
quiet: true # NOTE: Do not log
quiet: true # Do not log
depth: 4 # NOTE: "The use of clone depth: 1 often results in a git error
# when a new commit has been pushed to a branch before the CI
# platform started cloning the intended commit."

# # 2020-05-26: NOTE: Currently newest macOS image
# osx_image: xcode11.4 # NOTE: Official Nix installer fails spectacularly on it.
# # 2020-05-26: Currently newest macOS image
# osx_image: xcode11.4 # Official Nix installer fails spectacularly on it.

env:
global:
# NOTE: This is secure CACHIX_SIGNING_KEY=val
# NOTE: This is secure CACHIX_SIGNING_KEY=val, it is only available on project internal branches, so Cachix would push only there
- secure: "dm6I+M4+V+C7QMTpcSADdKPE633SvmToXZrTbZ7miNDGmMN+/SfHeN2ybi1+PW6oViMlbPN/7J/aEfiGjSJI8vLk72Y4uCWGmpSb8TXZLu6+whnxtZzzW8+z4tsM4048QJg7CF3N/25U8thRFgs3DqUub1Sf3nG9LrNWdz6ZcDQ="
###
### NOTE: This configuration uses `build.sh` interface, which uses `default.nix` interface, which exposes the Nixpkgs Haskell Lib interface.
###
### Documentation of this settings is in `default.nix`,
### and the other part of keys explained in `build.sh`
### Documentation of this settings is mosly in `default.nix`, since most settings it Nixpkgs related
### and the other part of keys explained in `build.sh`, since those address external procedures aound the builds.
### Additional documentation is in Nixpkgs Haskell.lib: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/lib.nix
###
#
# - rev=nixos-unstable
# - NIX_PATH="nixpkgs=https://github.com/nixos/nixpkgs/archive/$rev.tar.gz"
- project='hnix'
# Enable all our tests in Cabal
- ALL_TESTS='yes'
- failOnAllWarnings='false'
- checkUnusedPackages='false'
- doCoverage='false'
- doHaddock='false'
- allowInconsistentDependencies='false'
- doJailbreak='false'
- doCheck='true'
- doBenchmark='false'
- enableExecutableProfiling='false'
- enableLibraryProfiling='false'
- sdistTarball='false'
- buildFromSdist='false'
- buildStrictly='false'
- failOnAllWarnings='false'
- enableDeadCodeElimination='false'
- disableOptimization='true'
- linkWithGold='false'
- enableLibraryProfiling='false'
- enableExecutableProfiling='false'
- doTracing='false'
- enableDWARFDebugging='false'
- doStrip='false'
- enableSharedLibraries='true'
- enableStaticLibraries='false'
- enableSharedExecutables='false'
- justStaticExecutables='false'
- enableSeparateBinOutput='false'
- checkUnusedPackages='false'
- doHaddock='false'
- doHyperlinkSource='false'
- doCoverage='false'
- doBenchmark='false'
- generateOptparseApplicativeCompletions='false'
- executableNamesToShellComplete='[ "hnix" ]'
- allowInconsistentDependencies='false'
#
- ghcjsTmpLogFile='/tmp/ghcjsTmpLogFile.log'
- ghcjsLogTailLength='10000'

# 2020-05-26: NOTE: Currently newest Travis dist Ubuntu 18.04 bionic
# NOTE: {os} x {jobs} + {jobs:include} - {jobs:exclude} = {build matrix}
# 2020-05-26: Currently newest Travis dist Ubuntu 18.04 bionic
# {os} x {jobs} + {jobs:include} - {jobs:exclude} = {build matrix}
jobs:
include:
- name: GHC 8.4.4, Linux
env:
- GHCVERSION='ghc844'
- compiler='ghc844'
- linkWithGold='true'
os: linux
dist: bionic
- name: GHC 8.6.5, Linux
env:
- GHCVERSION='ghc865'
- compiler='ghc865'
- linkWithGold='true'
os: linux
dist: bionic
- name: GHC 8.8.3, macOS, Strict
env:
- GHCVERSION='ghc883'
- compiler='ghc883'
- buildStrictly='true'
os: osx
- name: GHC 8.10.1, Linux, SDist, Optimize, Benchmark, Haddock, Shell Completions
env:
- GHCVERSION='ghc8101'
- compiler='ghc8101'
- buildFromSdist='true'
- linkWithGold='true'
- doHaddock='true'
- doHyperlinkSource='true'
- doBenchmark='true'
- disableOptimization='false'
- enableDeadCodeElimination='true'
Expand All @@ -89,67 +101,58 @@ jobs:
dist: bionic
- name: GHCJS, Linux
env:
- GHCVERSION='ghcjs'
- compiler='ghcjs'
os: linux
dist: bionic
allow_failures:
- env: GHCVERSION='ghcjs'
- env: compiler='ghcjs'

before_script:
- sudo mount -o remount,exec,size=4G,mode=755 /run/user || true
- sudo mkdir -p /etc/nix
- echo "trusted-users = root $USER" | sudo tee -a /etc/nix/nix.conf
#
# NOTE: Update Nix and Nix packages, Cachix requires that
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then nix upgrade-nix; fi
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then sudo nix upgrade-nix; fi
#
# NOTE: macOS service restart
# HACK: Because Nix can not update its daemon itself between 2.0 -> 2.2:
# 1. https://github.com/NixOS/nix/issues/3125#issuecomment-539667327
# 2. https://github.com/NixOS/nix/issues/3125#issuecomment-539771768
# Since Nix on macOS has problems restarting the service:
# Force the real disable, get target file from the symlink, unlink symlink, copy file, and reload service
- |
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then true && \
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist && \
export NIX_SERVICE_FILE=$(readlink /Library/LaunchDaemons/org.nixos.nix-daemon.plist) && \
sudo unlink /Library/LaunchDaemons/org.nixos.nix-daemon.plist && \
sudo cp -f "$NIX_SERVICE_FILE" /Library/LaunchDaemons/org.nixos.nix-daemon.plist && \
sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist && \
sudo launchctl kickstart -k system/org.nixos.nix-daemon && \
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then true && \
sudo systemctl stop nix-daemon.service && \
sudo systemctl daemon-reload && \
sudo systemctl start nix-daemon.service && \
true; fi
# # macOS service restart
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then sudo launchctl kickstart -k system/org.nixos.nix-daemon; fi
# update on Linux
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then nix-channel --update && nix-env -iA nixpkgs.nix; fi
# update on macOS
# 2020-06-24: HACK: Do not ask why different commands on Linux and macOS. IDK, wished they we the same. These are the only commands that worked on according platforms right after the fresh Nix installer rollout.
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then sudo nix upgrade-nix; fi

script:
#
#
# NOTE: Install Cachix client using Nix:
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then nix-env -iA cachix -f https://cachix.org/api/v1/install; fi
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then sudo nix-env -iA cachix -f https://cachix.org/api/v1/install; fi
# Install Cachix client using Nix:
- if [ "${TRAVIS_OS_NAME}" = "linux" ] || [ "${TRAVIS_OS_NAME}" = "osx" ]; then nix-env -iA cachix -f https://cachix.org/api/v1/install; fi
- cachix use "$project"
# NOTE: If key is set - use Cachix push, else - proceed without it
# If key is set - use Cachix push, else - proceed without it
- if [ ! "$CACHIX_SIGNING_KEY" = "" ]; then cachix push "$project" --watch-store& fi
# NOTE: Brush timeout for previous daemon to start
#
#
# NOTE: Normal GHC build
- if [ ! "$GHCVERSION" = 'ghcjs' ]; then ./build.sh; fi
- if [ ! "$compiler" = 'ghcjs' ]; then ./build.sh; fi
#
#
# NOTE: GHCJS build
# HACK: Travis terminates GHCJS because of very huge log,
# so `SILENT` mode for it was created
# and travis_wait 50 to wait on no outputs (otherwise Travis terminates build in 10 minutes as stale)
# and `bash` wrapper so Travis parses `travis_wait` => `if; then; fi` line
- travis_wait 50 bash -c 'if [ "$GHCVERSION" = "ghcjs" ]; then ./build.sh; fi'
- travis_wait 50 bash -c 'if [ "$compiler" = "ghcjs" ]; then ./build.sh; fi'
# NOTE: For GHCJS dump the last $ghcjsLogTailLength lines into CI out to see
# Since build runs inside `travis_wait` - it was impossible to output log from it
- if [ "$GHCVERSION" = "ghcjs" ]; then tail -n "$ghcjsLogTailLength" "$ghcjsTmpLogFile" && rm "$ghcjsTmpLogFile"; fi
- if [ "$compiler" = "ghcjs" ]; then tail -n "$ghcjsLogTailLength" "$ghcjsTmpLogFile" && rm "$ghcjsTmpLogFile"; fi
#
#


# NOTE: Track the commits on this repo branches + cron rechecks build
# Track the commits on this repo branches + cron rechecks build
branches:
only:
- master
Expand All @@ -159,8 +162,8 @@ notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/b0312b18473340459d3e
# NOTE: Be silent about CI, until some PR started to pass CI succesfully.
# Be silent about CI, until some PR started to pass CI succesfully.
on_success: change
# NOTE: `master` status in on the front page badge.
# `master` status in on the front page badge.
on_failure: never
on_start: never
25 changes: 10 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -Eexuo pipefail


# NOTE: If var not imported - set to the default value
GHCVERSION=${GHCVERSION:-'ghc8101'}
compiler=${compiler:-'ghc8101'}
# NOTE: Nix by default uses nixpkgs-unstable channel
# Setup for Nixpkgs revision:
# `rev` vals in order of freshness -> cache & stability:
Expand Down Expand Up @@ -63,8 +63,6 @@ doTracing=${doTracing:-'false'}
enableDWARFDebugging=${enableDWARFDebugging:-'false'}
# Strip results from all debugging symbols
doStrip=${doStrip:-'false'}
# Generate hyperlinked source code for documentation using HsColour, and have Haddock documentation link to it.
doHyperlinkSource=${doHyperlinkSource:-'false'}
# Nixpkgs expects shared libraries
enableSharedLibraries=${enableSharedLibraries:-'true'}
# Ability to make static libraries
Expand All @@ -79,6 +77,8 @@ enableSeparateBinOutput=${enableSeparateBinOutput:-'false'}
checkUnusedPackages=${checkUnusedPackages:-'false'}
# Generation and installation of haddock API documentation
doHaddock=${doHaddock:-'false'}
# Generate hyperlinked source code for documentation using HsColour, and have Haddock documentation link to it.
doHyperlinkSource=${doHyperlinkSource:-'false'}
# Generation and installation of a coverage report. See https://wiki.haskell.org/Haskell_program_coverage
doCoverage=${doCoverage:-'false'}
# doBenchmark: Dependency checking + compilation and execution for benchmarks listed in the package description file.
Expand Down Expand Up @@ -137,7 +137,7 @@ BUILD_PROJECT(){

IFS=$'\n\t'

if [ "$GHCVERSION" = "ghcjs" ]
if [ "$compiler" = "ghcjs" ]
then

# NOTE: GHCJS build
Expand Down Expand Up @@ -176,15 +176,15 @@ if [ "$GHCVERSION" = "ghcjs" ]
--arg generateOptparseApplicativeCompletions "$generateOptparseApplicativeCompletions" \
--arg executableNamesToShellComplete "$executableNamesToShellComplete" \
--arg withHoogle "$withHoogle" \
ghcjs
"$compiler"

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" \
--argstr compiler "$compiler" \
--arg allowInconsistentDependencies "$allowInconsistentDependencies" \
--arg doJailbreak "$doJailbreak" \
--arg doCheck "$doCheck" \
Expand Down Expand Up @@ -219,16 +219,11 @@ fi
MAIN() {


# 2020-06-01: NOTE: Nix installer installs old Nix version that has bugs that prevented importing Nixpks repository channels, updating to latest Nix since it does not have that bug
# NOTE: Overall it is useful to have in CI test builds the latest stable Nix
# NOTE: User-run update for Linux setup
nix upgrade-nix || true
# NOTE: Superuser update for macOS setup
sudo nix upgrade-nix || true

# NOTE: Make channels current
nix-channel --update || true
sudo nix-channel --update || true
# NOTE: User-run Linux setup old update command, or superuser update for macOS setup
# 2020-06-24: HACK: Do not ask why different commands on Linux and macOS. IDK, wished they we the same. These are the only commands that worked on according platforms right after the fresh Nix installer rollout.
(nix-channel --update && nix-env -iA nixpkgs.nix) || (sudo nix upgrade-nix)



# NOTE: Secrets are not shared to PRs from forks
Expand Down
4 changes: 3 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ compiler ? "ghc883"
{
# Compiler in a form ghc8101 == GHC 8.10.1, just remove spaces and dots
compiler ? "ghc883"

# This settings expose most of the Nixpkgs Haskell.lib API: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/lib.nix

Expand Down