diff options
Diffstat (limited to 'third_party/bazel/rules_haskell/.circleci/config.yml')
-rw-r--r-- | third_party/bazel/rules_haskell/.circleci/config.yml | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/third_party/bazel/rules_haskell/.circleci/config.yml b/third_party/bazel/rules_haskell/.circleci/config.yml new file mode 100644 index 000000000000..1ec2b1fc0518 --- /dev/null +++ b/third_party/bazel/rules_haskell/.circleci/config.yml @@ -0,0 +1,188 @@ +version: 2 + +# NOTE: +# Disk cache: +# We don't want to keep old artifacts around so we always build from +# scratch on master builds and upload the new cache afterwards. Because +# Circle doesn't allow skipping a "restore_cache" we create a dummy +# "empty" cache that's only ever pulled on master. Alternatively we could +# ask Bazel to clean up old items (LRU style) but the documentation is +# very terse and I could not figure how to do it: +# https://docs.bazel.build/versions/master/remote-caching.html +# It also appears that there's ongoing work but the feature is not ready: +# https://github.com/bazelbuild/bazel/issues/5139 +# +# Currently the disk cache is only implemented for the Darwin builds, +# which were the slowest ones. There is no reason why a disk cache +# couldn't be used for the other jobs: I just haven't gotten around to +# doing it. + +jobs: + build-linux-ghc-bindist: + docker: + - image: debian + working_directory: ~/rules_haskell + resource_class: large + steps: + - checkout + - run: + name: Setup test environment + command: | + apt-get update + apt-get install -y wget gnupg golang make libgmp3-dev libtinfo-dev pkg-config zip g++ zlib1g-dev unzip python bash-completion locales + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen + locale-gen + wget "https://github.com/bazelbuild/bazel/releases/download/0.24.0/bazel_0.24.0-linux-x86_64.deb" + dpkg -i bazel_0.24.0-linux-x86_64.deb + echo "common:ci --build_tag_filters -requires_hackage,-requires_zlib,-requires_doctest,-requires_c2hs,-requires_threaded_rts,-dont_test_with_bindist" > .bazelrc.local + - run: + name: Build tests + command: | + bazel build --config ci //tests/... + - run: + name: Run tests + command: | + # Run the start script test. + # Doesn't use the test suite binary, because that depends on nixpkgs dependencies. + ./tests/run-start-script.sh + # TODO: enable all tests for bindists + # (this will require tests to both work with nixpkgs and hazel backends) + + # ATTN: when you change anything here, don’t forget to copy it to the build-darwin section + build-linux-nixpkgs: + docker: + - image: nixos/nix:2.1.3 + working_directory: ~/rules_haskell + resource_class: large + steps: + - checkout + - run: + name: System dependencies + command: | + set -e + apk --no-progress update + apk --no-progress add bash ca-certificates + + mkdir -p /etc/nix + # CircleCI and Nix sandboxing don't play nice. See + # https://discourse.nixos.org/t/nixos-on-ovh-kimsufi-cloning-builder-process-operation-not-permitted/1494/5 + echo "sandbox = false" > /etc/nix/nix.conf + # No builders and no local jobs ensures that everything has to come from a binary cache + # If we want to add packages that are not cached by the offical NixOS binary cache, + # we need to manually build them (e.g. `nix-build -A <dependency> --max-jobs <no-cpu-cores>`). + # This is a sanity check. + echo "builders =" >> /etc/nix/nix.conf + echo "max-jobs = 0" >> /etc/nix/nix.conf + - run: + name: Configure + command: | + echo "build:ci --host_platform=@io_tweag_rules_haskell//haskell/platforms:linux_x86_64_nixpkgs" > .bazelrc.local + - run: + name: Build tests + command: | + nix-shell --arg docTools false --pure --run \ + 'bazel build --config ci //tests/...' + - run: + name: Run tests + # bazel does not support recursive bazel call, so we + # cannot use bazel run here because the test runner uses + # bazel + command: | + nix-shell --arg docTools false --pure --run \ + 'bazel build --config ci //tests:run-tests' + # TODO(Profpatsch) re-add a nixpkgs startup script + # and enable this test again + nix-shell --arg docTools false --pure --run \ + './bazel-ci-bin/tests/run-tests --skip "/startup script/"' + nix-shell --arg docTools false --pure --run \ + 'bazel coverage //tests/... --config ci --build_tag_filters "coverage-compatible" --test_tag_filters "coverage-compatible" --test_output=all' + + build-darwin: + macos: + xcode: "9.0" + steps: + - checkout + - run: + name: Install Nix + command: | + curl https://nixos.org/nix/install | sh + + - run: + name: Install cachix + shell: /bin/bash -eilo pipefail + command: | + nix-env -iA cachix -f https://github.com/NixOS/nixpkgs/tarball/db557aab7b690f5e0e3348459f2e4dc8fd0d9298 + + - run: + name: Run cachix + shell: /bin/bash -eilo pipefail + command: | + cachix use tweag + cachix push tweag --watch-store + background: true + + - run: + name: Configure + command: | + mkdir -p ~/.cache/bazel/ + + echo "build:ci --host_platform=@io_tweag_rules_haskell//haskell/platforms:darwin_x86_64_nixpkgs" >> .bazelrc.local + echo "build:ci --disk_cache=~/.cache/bazel/" >> .bazelrc.local + echo "common:ci --test_tag_filters -dont_test_on_darwin" >> .bazelrc.local + + - restore_cache: + keys: # see note about 'Disk cache' + - v1-rules_haskell-empty-{{ .Branch }}- + - v1-rules_haskell-cache-{{ .Branch }}- + - v1-rules_haskell-cache-master- + + - run: + name: Build tests + shell: /bin/bash -eilo pipefail + command: | + nix-shell --arg docTools false --pure --run \ + 'bazel build --config ci //tests/...' + - run: + name: Run tests + shell: /bin/bash -eilo pipefail + command: | + + # Keep CI awake + while true; do echo "."; sleep 60; done & + + nix-shell --arg docTools false --pure --run \ + 'bazel build --config ci //tests:run-tests' + # XXX 2019-01-22 Disable start script checking on Darwin + # due to a clash between binutils and clang. + nix-shell --arg docTools false --pure --run \ + './bazel-ci-bin/tests/run-tests --skip "/startup script/"' + nix-shell --arg docTools false --pure --run \ + 'bazel coverage //tests/... --config ci --build_tag_filters "coverage-compatible" --test_tag_filters "coverage-compatible" --test_output=all' + + + # see note about 'Disk cache' + - save_cache: + key: v1-rules_haskell-cache-{{ .Branch }}-{{ .BuildNum }} + paths: + - ~/.cache/bazel/ + + - run: + name: Clean up cache + shell: /bin/bash -eilo pipefail + command: | + rm -rf ~/.cache/bazel/ + mkdir -p ~/.cache/bazel/ + + - save_cache: + key: v1-rules_haskell-empty-master-{{ .BuildNum }} + paths: + - ~/.cache/bazel/ + +workflows: + version: 2 + build: + jobs: + - build-linux-ghc-bindist + - build-linux-nixpkgs + - build-darwin: + context: org-global # for the cachix token |