Commit f18a9015 authored by Ben Gamari's avatar Ben Gamari 🐢

Merge branch 'core-lint' into 'master'

Allow additional arguments to be passed to GHC

See merge request ghc/head.hackage!4
parents d0112e7e 1512c1b9
Pipeline #8138 failed with stages
in 3 minutes and 31 seconds
......@@ -30,6 +30,10 @@ variables:
# ACCESS_TOKEN provided via protected environment variable
# EXTRA_HC_OPTS provided by GHC job. These are passed to via --ghc-options to
# GHC during the package builds. This is instantiated with, e.g., -dcore-lint
# during GHC validation builds.
build:
stage: test
......@@ -67,7 +71,8 @@ build:
- nix-build scripts/build-all.nix -j$CPUS
--no-build-output
-A buildDepends
--arg bindistTarball $GHC_TARBALL
--arg bindistTarball "$GHC_TARBALL"
--arg extraHcOpts "\"$EXTRA_HC_OPTS\""
- nix-store --export $(nix-store -qR --include-outputs $(nix-instantiate --quiet scripts/build-all.nix --arg bindistTarball $GHC_TARBALL -A buildDepends -A ghc)) > store.nar
- ret=0
- nix-build scripts/build-all.nix
......
......@@ -149,24 +149,27 @@ snapshots.
To run a similar build locally simply download a binary distribution from a
`x86_64-fedora27-linux` CI job and run:
```
$ nix build -f scripts/build-all.nix testedPackages \
--arg bindistTarball ./ghc-x86_64-fedora27-linux.tar.xz
$ export GHC_TARBALL=./ghc-x86_64-fedora27-linux.tar.xz
# for extra correctness assurance...
$ export EXTRA_HC_OPTS=-dcore-lint
$ scripts/build-nix.sh
```
This will build the set of packages defined by the `testedPackages` list in
`scripts/build-all.nix`.
After building `testedPackages` (allowing for failures) the CI job runs
After building `testedPackages` (allowing for failures) the script job runs
`scripts/summarize.py`, which produces a few artifacts:
* a JSON summary, which includes the full dependency graph as well as which
package builds failed
* a DOT graph showing the package depedencies and their build success
* a directory of build logs
* a JSON summary (`summary.json`) which includes the full dependency graph as
well as which package builds failed
* a DOT graph (`summary.dot`) showing the package depedencies and their build
success. This can be rendered with `scripts/render-graph.sh`.
* a directory (`./logs`) of build logs
You can run `scripts/summarize.py` locally with
Note that `build-nix.sh` can also be used to build packages not included in
`testedPackages`:
```
$ export GHC_TARBALL=./ghc-x86_64-fedora27-linux.tar.xz
$ python3 scripts/summarize.py
$ scripts/build-nix.sh pandoc
```
### Hackage repository
......
......@@ -4,7 +4,9 @@
# Expects to be run on x86_64.
# bindistTarball should be a fedora27 tarball.
{ bindistTarball }:
{ bindistTarball
, extraHcOpts ? ""
}:
let
# GHC from the given bindist.
......@@ -34,6 +36,7 @@ let
hyperlinkSource = false;
configureFlags = (drv.configureFlags or []) ++ [
"--ghc-options=-ddump-timings"
"--ghc-options=\"${extraHcOpts}\""
];
});
};
......
#!/bin/sh
# A convenient wrapper for build-all.nix.
if [ -z "$GHC_TARBALL" ]; then
echo '$GHC_TARBALL is not set; please set it.'
exit 1
fi
targets=$@
if [ -z "$targets" ]; then
targets=testedPackages
fi
echo "Building $targets with GHC options \"$EXTRA_HC_OPTS\"..."
nix build -f scripts/build-all.nix --keep-going testedPackages \
--arg bindistTarball $GHC_TARBALL
--arg extraHcOpts \"$EXTRA_HC_OPTS\"
echo "Build finished. Running summarize..."
python3 scripts/summarize.py
echo
echo "Build finished. I produced the following:"
echo " * summary.json: a summary of the build"
echo " * summary.dot: the dependency graph of packages I built"
echo " * logs/*: the build logs"
echo
......@@ -10,6 +10,7 @@ def read_summary():
summary = subprocess.check_output(
['nix', 'eval', '--json',
'--arg', 'bindistTarball', os.environ['GHC_TARBALL'],
'--arg', 'extraHcOpts', f"\"{os.environ.get('EXTRA_HC_OPTS', '')}\"",
'-f', 'scripts/build-all.nix',
'summary'],
encoding = 'UTF-8')
......@@ -78,10 +79,11 @@ def show_failures(summary, log_excerpt=100):
print('These packages failed to build:')
print()
for pkg in failed:
print('*', pkg['name'])
print(f"* {pkg['name']} ({pkg['drvPath']})")
print()
proc = subprocess.run(['nix', 'log', pkg['drvPath']],
proc = subprocess.run(['nix', 'log', '--quiet', pkg['drvPath']],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
encoding='UTF-8')
if proc.returncode != 0:
print(f' Error: Failed to fetch log')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment