Skip to content
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

Building the most straightforward tests with GHC Bindist compiled with Hadrian #1842

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fda7977
Building the most strightforward tests with GHC Bindist compiled with…
GuillaumeGen Dec 6, 2022
6adb278
Use GHC 9.6.1 which is built with Hadrian
avdv Apr 28, 2023
988e08c
examples: Update primitive to version 0.8.0
avdv May 15, 2023
350908c
Update examples to use GHC 9.6.1 hadrian bindist
avdv May 15, 2023
c0f0f27
Fix `docdir` and pass `is_clang`
avdv May 15, 2023
99a3052
Pass `-f <ghc>` to runghc
avdv May 15, 2023
766c505
Add `libdir` to runfiles
avdv May 15, 2023
3f7864d
Fix srcs for _hadrian_bindist_settings
avdv May 15, 2023
0d9cfa8
Skip haskell_register_ghc_bindists call
avdv May 15, 2023
6b256e9
Make the `start` script work with GHC/Hadrian 9.6.1
avdv May 15, 2023
1df3881
Use GHC 9.6.1 for tests
avdv May 15, 2023
d303a1f
Fix includedir
avdv May 19, 2023
9dfdfdf
Update stackage snapshot
avdv May 19, 2023
693f7f6
Keep going
avdv May 19, 2023
aeed150
Fix more things
avdv May 19, 2023
7b381ad
Use GHC 9.2.5 again
avdv May 22, 2023
5a13d98
Difference between GHC 9.2 / 9.6 hadrian bindist
avdv May 22, 2023
9d6539e
examples: Use GHC 9.2.5
avdv May 22, 2023
cc3fcac
Revert "Update stackage snapshot"
avdv May 23, 2023
b3e9244
Add missing install.mk.in
avdv Jun 15, 2023
73cf49c
Fix docdir
avdv Jun 15, 2023
8808d51
Only build ubuntu bindists for the time being
avdv Jun 15, 2023
d501751
Revert "Fix more things"
avdv Jun 15, 2023
767346d
buildfier fix
avdv Jun 15, 2023
0ddac25
Move generated_*_filegroup to toolchain.bzl
avdv Jun 16, 2023
e66363b
Fix syntax error when setting arguments array
avdv Jun 16, 2023
bc8d384
Fix tools_path for original bindist
avdv Jun 20, 2023
dfedd37
Determine docdir dynamically
avdv Jun 20, 2023
a76f99c
Fix libdir and docdir path (it is relative to the bindist root)
avdv Jun 23, 2023
79752f5
ghc-check depends on ghc-paths:bin
avdv Jun 23, 2023
4ec556b
Skip running asterius tests
avdv Jun 26, 2023
979e554
Add hadrian bindist for macos and re-enable CI job
avdv Jun 26, 2023
5b527ad
Add hadrian bindist for macos to start script too
avdv Jun 26, 2023
cd703c7
Enable `--test_verbose_timeout_warnings` on CI
avdv Jun 26, 2023
1398da0
Fix libdir path for protoc
avdv Jun 27, 2023
4492ddd
Debug toolchain resolution
avdv Jun 27, 2023
e478033
Only enable test_verbose_timeout_warnings for tests
avdv Jun 27, 2023
b344d21
Debug toolchain resolution in start script
avdv Jun 27, 2023
efeec34
CI: Skip GHC 9.4.x for now
avdv Nov 3, 2023
97dfac2
Fix WORKSPACE setup for hadrian bindist
avdv Nov 3, 2023
c1e1916
Skip registering normal ghc bindists
avdv Nov 6, 2023
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
4 changes: 4 additions & 0 deletions .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ build:ci-common --symlink_prefix=bazel-ci-
build:ci-common --repository_cache=~/repo-cache/
build:ci-common --experimental_repository_cache_hardlinks

test:ci-common --test_verbose_timeout_warnings

# Use a remote cache during CI
build:ci-windows-bindist --bes_upload_mode=wait_for_upload_complete --bes_timeout=600s
# On Github CI for Windows, we see intermittent connection failures to BuildBuddy
Expand Down Expand Up @@ -102,6 +104,8 @@ build:linux-bindist --experimental_strict_action_env
build:macos-bindist --experimental_strict_action_env
build:windows-bindist --experimental_strict_action_env

build:macos-bindist --toolchain_resolution_debug='.*'

# Note [backward compatible options]
build:linux-bindist --incompatible_enable_cc_toolchain_resolution
build:macos-bindist --incompatible_enable_cc_toolchain_resolution
Expand Down
108 changes: 4 additions & 104 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,106 +10,6 @@ env:
cache-version: 0

jobs:
test-nixpkgs:
name: Build & Test - Nixpkgs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.module }}-${{ matrix.bzlmod }}-${{ matrix.ghc }}-nixpkgs
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11]
module: [rules_haskell, rules_haskell_nix, rules_haskell_tests]
bzlmod: [true, false]
ghc:
- 9.2.5
- 9.4.5
exclude:
- module: rules_haskell_nix
bzlmod: false
# TODO: in a MODULE.bazel file we declare version specific dependencies, would need to use stack snapshot json
# and stack config per GHC version
- ghc: 9.4.5
bzlmod: true
runs-on: ${{ matrix.os }}
steps:
- if: ${{ matrix.os == 'ubuntu-latest' }}
run: |-
sudo swapoff -a
sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc
docker rmi $(docker images -q) -f
- uses: actions/checkout@v4
- name: Mount Bazel cache
uses: actions/cache@v3
with:
path: ~/repo-cache
key: repo-cache-${{ runner.os }}-nixpkgs-${{ env.cache-version }}
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=./nixpkgs/default.nix
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
extra-substituters = https://cache.iog.io
- name: Configure
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
run: |
# Avoid failures of the form `deadline exceeded after 14999958197ns DEADLINE_EXCEEDED`.
# See https://github.com/tweag/rules_haskell/issues/1498 and https://github.com/tweag/rules_haskell/pull/1692.
[[ ${{ runner.os }} == Linux ]] && sudo sysctl -w net.ipv4.tcp_keepalive_time=60
case ${{ runner.os }} in
macOS) BUILD_CONFIG=ci-macos-nixpkgs;;
Linux) BUILD_CONFIG=ci-linux-nixpkgs;;
esac
if [ -z "$BUILDBUDDY_API_KEY" ]; then
cache_setting='--noremote_upload_local_results'
else
cache_setting="--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY"
fi
cat >.bazelrc.local <<EOF
common --config=ci
build --config=$BUILD_CONFIG
build $cache_setting
common --enable_bzlmod=${{ matrix.bzlmod }}
EOF
cp .bazelrc.local rules_haskell_nix
cp .bazelrc.local rules_haskell_tests
cat >~/.netrc <<EOF
machine api.github.com
password ${{ secrets.GITHUB_TOKEN }}
EOF
- name: Check Bazel version
run: |
nix-shell --arg docTools false --argstr ghcVersion ${{ matrix.ghc }} --pure --run .ci/check-bazel-version
- name: Build & test - rules_haskell
if: matrix.module == 'rules_haskell'
run: |
nix-shell --arg docTools false --argstr ghcVersion ${{ matrix.ghc }} --pure --run '
set -euo pipefail
bazel test //...
bazel build //docs:api_html
bazel build //docs:guide_html
'
- name: Build & test - rules_haskell_nix
if: matrix.module == 'rules_haskell_nix'
run: |
nix-shell --arg docTools false --argstr ghcVersion ${{ matrix.ghc }} --pure --run '
set -euo pipefail
cd rules_haskell_nix
bazel test //...
'
- name: Build & test - rules_haskell_tests
if: matrix.module == 'rules_haskell_tests'
run: |
nix-shell --arg docTools false --argstr ghcVersion ${{ matrix.ghc }} --pure --run '
set -euo pipefail
cd rules_haskell_tests
./tests/run-start-script.sh --use-nix
bazel build //tests:run-tests
./bazel-ci-bin/tests/run-tests
bazel coverage //...
'

test-bindist:
name: Build & Test - bindist
concurrency:
Expand All @@ -118,12 +18,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
os: [ubuntu-latest, macos-latest]
module: [rules_haskell, rules_haskell_tests]
bzlmod: [true, false]
ghc:
- 9.2.5
- 9.4.5
#- 9.4.5
exclude:
# TODO: in a MODULE.bazel file we declare version specific dependencies, would need to use stack snapshot json
# and stack config per GHC version
Expand Down Expand Up @@ -209,7 +109,7 @@ jobs:
# On Windows `//...` expands to `/...`.
bazel test ///...
else
bazel test //...
bazel test --keep_going -- //...
fi

- name: Build & test - rules_haskell_tests
Expand All @@ -225,7 +125,7 @@ jobs:
# On Windows `//...` expands to `/...`.
bazel test ///...
else
bazel test //...
bazel test --keep_going -- //... -//tests/asterius/...
fi
# Test stack_snapshot pinning
# NOTE keep in sync with tests/RunTests.hs
Expand Down
42 changes: 41 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ load(
"haskell_register_ghc_bindists",
)

haskell_register_ghc_bindists(version = GHC_VERSION)
#haskell_register_ghc_bindists(version = GHC_VERSION)

load(
"@rules_haskell//haskell/asterius:repositories.bzl",
Expand All @@ -86,6 +86,46 @@ load("@rules_haskell_npm//:repositories.bzl", "npm_repositories")

npm_repositories()

load(
"@rules_haskell//haskell:ghc_bindist_hadrian.bzl",
"haskell_register_ghc_bindists_hadrian",
)

test_ghcopts = [
"-XStandaloneDeriving", # Flag used at compile time
"-threaded", # Flag used at link time
# Used by `tests/repl-flags`
"-DTESTS_TOOLCHAIN_COMPILER_FLAGS",
# this is the default, so it does not harm other tests
"-XNoOverloadedStrings",
]

test_cabalopts = [
# Used by `tests/cabal-toolchain-flags`
"--ghc-option=-DTESTS_TOOLCHAIN_CABALOPTS",
"--haddock-option=--optghc=-DTESTS_TOOLCHAIN_CABALOPTS",
]

haskell_register_ghc_bindists_hadrian(
cabalopts = test_cabalopts,
ghcopts = test_ghcopts,
sha256 = "9dea9123cd53c0d48e72de68480492eaacc2e0bf487a3cd3dfa3ce18729aa3e4",
strip_prefix = "ghc-9.2.5-x86_64-unknown-linux",
target = "x86_64-unknown-linux",
url = "https://github.com/avdv/testproject/releases/download/ghc-9.2.5/ghc-9.2.5-x86_64-unknown-linux.tar.xz",
version = "9.2.5",
)

haskell_register_ghc_bindists_hadrian(
cabalopts = test_cabalopts,
ghcopts = test_ghcopts,
sha256 = "55c6a09d00aac69efd03112bd5fcf9a50f87060b1feb6c81f8698752bf164536",
strip_prefix = "ghc-9.2.5-x86_64-apple-darwin",
target = "x86_64-apple-darwin",
url = "https://github.com/avdv/testproject/releases/download/ghc-9.2.5/ghc-9.2.5-x86_64-apple-darwin.tar.xz",
version = "9.2.5",
)

register_toolchains(
"//tests:protobuf-toolchain",
"//tests:protobuf-toolchain-osx_arm64",
Expand Down
55 changes: 50 additions & 5 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,55 @@ load("@rules_haskell//haskell:repositories.bzl", "rules_haskell_dependencies")

rules_haskell_dependencies()

load("@rules_haskell//haskell:nixpkgs.bzl", "haskell_register_ghc_nixpkgs")
load(
"@rules_haskell//haskell:ghc_bindist_hadrian.bzl",
"haskell_register_ghc_bindists_hadrian",
)

haskell_register_ghc_nixpkgs(
attribute_path = "haskell.compiler.ghc925",
repository = "@rules_haskell//nixpkgs:default.nix",
# FIXME copied from non_module_deps_1.bzl
test_ghcopts = [
"-XStandaloneDeriving", # Flag used at compile time
"-threaded", # Flag used at link time
# Used by `tests/repl-flags`
"-DTESTS_TOOLCHAIN_COMPILER_FLAGS",
# this is the default, so it does not harm other tests
"-XNoOverloadedStrings",
]

test_haddock_flags = ["-U"]

test_repl_ghci_args = [
# The repl test will need this flag, but set by the local
# `repl_ghci_args`.
"-UTESTS_TOOLCHAIN_REPL_FLAGS",
# The repl test will need OverloadedString
"-XOverloadedStrings",
]

test_cabalopts = [
# Used by `tests/cabal-toolchain-flags`
"--ghc-option=-DTESTS_TOOLCHAIN_CABALOPTS",
"--haddock-option=--optghc=-DTESTS_TOOLCHAIN_CABALOPTS",
] + ([
# To avoid ghcide linking errors with heapsize on Windows of the form
#
# unknown symbol `heap_view_closurePtrs'
#
# See https://github.com/haskell/ghcide/pull/954
"--disable-library-for-ghci",
] if False else [])

# load(
# "@rules_haskell//:non_module_deps_1.bzl", "test_cabalopts", "test_ghcopts"
# )

haskell_register_ghc_bindists_hadrian(
cabalopts = test_cabalopts,
ghcopts = test_ghcopts,
sha256 = "9dea9123cd53c0d48e72de68480492eaacc2e0bf487a3cd3dfa3ce18729aa3e4",
strip_prefix = "ghc-9.2.5-x86_64-unknown-linux",
target = "x86_64-unknown-linux",
url = "https://github.com/avdv/testproject/releases/download/ghc-9.2.5/ghc-9.2.5-x86_64-unknown-linux.tar.xz",
version = "9.2.5",
)

Expand Down Expand Up @@ -65,7 +109,6 @@ stack_snapshot(
"-pkg-config",
],
},
local_snapshot = "@rules_haskell//:stackage_snapshot.yaml",
packages = [
"base",
"bytestring",
Expand All @@ -76,6 +119,8 @@ stack_snapshot(
"text",
"text-show",
],
#local_snapshot = "@rules_haskell//:stackage_snapshot.yaml",
snapshot = "nightly-2023-05-12",
# This example uses an unpinned version of stack_snapshot, meaning that stack is invoked on every build.
# To switch to pinned stackage dependencies, run `bazel run @stackage-unpinned//:pin` and
# uncomment the following line.
Expand Down
6 changes: 6 additions & 0 deletions examples/primitive/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ load(

haskell_toolchain_library(name = "base")

haskell_toolchain_library(name = "deepseq")

haskell_toolchain_library(name = "ghc-prim")

haskell_toolchain_library(name = "rts")

haskell_toolchain_library(name = "template-haskell")

cc_library(
name = "memops",
srcs = ["cbits/primitive-memops.c"],
Expand All @@ -28,8 +32,10 @@ haskell_library(
visibility = ["//visibility:public"],
deps = [
":base",
":deepseq",
":ghc-prim",
":memops",
":template-haskell",
"//transformers",
],
)
Expand Down
Loading
Loading