Merge pull request #138317 from cdepillabout/merge-and-open-pr
haskell: Add a maintainer script for opening a new haskell-updates PR
This commit is contained in:
commit
9b31e5dece
2 changed files with 177 additions and 56 deletions
118
maintainers/scripts/haskell/merge-and-open-pr.sh
Executable file
118
maintainers/scripts/haskell/merge-and-open-pr.sh
Executable file
|
@ -0,0 +1,118 @@
|
||||||
|
#! /usr/bin/env nix-shell
|
||||||
|
#! nix-shell -i bash -p git gh -I nixpkgs=.
|
||||||
|
#
|
||||||
|
# Script to merge the currently open haskell-updates PR into master, bump the
|
||||||
|
# Stackage version and Hackage versions, and open the next haskell-updates PR.
|
||||||
|
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
# exit after printing first argument to this function
|
||||||
|
function die {
|
||||||
|
# echo the first argument
|
||||||
|
echo "ERROR: $1"
|
||||||
|
echo "Aborting!"
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function help {
|
||||||
|
echo "Usage: $0 HASKELL_UPDATES_PR_NUM"
|
||||||
|
echo "Merge the currently open haskell-updates PR into master, and open the next one."
|
||||||
|
echo
|
||||||
|
echo " -h, --help print this help"
|
||||||
|
echo " HASKELL_UPDATES_PR_NUM number of the currently open PR on NixOS/nixpkgs"
|
||||||
|
echo " for the haskell-updates branch"
|
||||||
|
echo
|
||||||
|
echo "Example:"
|
||||||
|
echo " \$ $0 137340"
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read in the current haskell-updates PR number from the command line.
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
key="$1"
|
||||||
|
|
||||||
|
case $key in
|
||||||
|
-h|--help)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
curr_haskell_updates_pr_num="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z "${curr_haskell_updates_pr_num-}" ]] ; then
|
||||||
|
die "You must pass the current haskell-updates PR number as the first argument to this script."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure you have gh authentication setup.
|
||||||
|
if ! gh auth status 2>/dev/null ; then
|
||||||
|
die "You must setup the \`gh\` command. Run \`gh auth login\`."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch nixpkgs to get an up-to-date origin/haskell-updates branch.
|
||||||
|
echo "Fetching origin..."
|
||||||
|
git fetch origin >/dev/null
|
||||||
|
|
||||||
|
# Make sure we are currently on a local haskell-updates branch.
|
||||||
|
curr_branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
if [[ "$curr_branch" != "haskell-updates" ]]; then
|
||||||
|
die "Current branch is not called \"haskell-updates\"."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure our local haskell-updates branch is on the same commit as
|
||||||
|
# origin/haskell-updates.
|
||||||
|
curr_branch_commit="$(git rev-parse haskell-updates)"
|
||||||
|
origin_haskell_updates_commit="$(git rev-parse origin/haskell-updates)"
|
||||||
|
if [[ "$curr_branch_commit" != "$origin_haskell_updates_commit" ]]; then
|
||||||
|
die "Current branch is not at the same commit as origin/haskell-updates"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Merge the current open haskell-updates PR.
|
||||||
|
echo "Merging https://github.com/NixOS/nixpkgs/pull/${curr_haskell_updates_pr_num}..."
|
||||||
|
gh pr merge --repo NixOS/nixpkgs --merge "$curr_haskell_updates_pr_num"
|
||||||
|
|
||||||
|
# Update stackage, Hackage hashes, and regenerate Haskell package set
|
||||||
|
echo "Updating Stackage..."
|
||||||
|
./maintainers/scripts/haskell/update-stackage.sh --do-commit
|
||||||
|
echo "Updating Hackage hashes..."
|
||||||
|
./maintainers/scripts/haskell/update-hackage.sh --do-commit
|
||||||
|
echo "Regenerating Hackage packages..."
|
||||||
|
./maintainers/scripts/haskell/regenerate-hackage-packages.sh --do-commit
|
||||||
|
|
||||||
|
# Push these new commits to the haskell-updates branch
|
||||||
|
echo "Pushing commits just created to the haskell-updates branch"
|
||||||
|
git push
|
||||||
|
|
||||||
|
# Open new PR
|
||||||
|
new_pr_body=$(cat <<EOF
|
||||||
|
### This Merge
|
||||||
|
|
||||||
|
This PR is the regular merge of the \`haskell-updates\` branch into \`master\`.
|
||||||
|
|
||||||
|
This branch is being continually built and tested by hydra at https://hydra.nixos.org/jobset/nixpkgs/haskell-updates.
|
||||||
|
|
||||||
|
We roughly aim to merge these \`haskell-updates\` PRs at least once every two weeks. See the @NixOS/haskell [team calendar](https://cloud.maralorn.de/apps/calendar/p/Mw5WLnzsP7fC4Zky) for who is currently in charge of this branch.
|
||||||
|
|
||||||
|
### haskellPackages Workflow Summary
|
||||||
|
|
||||||
|
Our workflow is currently described in [\`pkgs/development/haskell-modules/HACKING.md\`](https://github.com/NixOS/nixpkgs/blob/haskell-updates/pkgs/development/haskell-modules/HACKING.md).
|
||||||
|
|
||||||
|
The short version is this:
|
||||||
|
* We regularly update the Stackage and Hackage pins on \`haskell-updates\` (normally at the beginning of a merge window).
|
||||||
|
* The community fixes builds of Haskell packages on that branch.
|
||||||
|
* We aim at at least one merge of \`haskell-updates\` into \`master\` every two weeks.
|
||||||
|
* We only do the merge if the [\`mergeable\`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/mergeable) job is succeeding on hydra.
|
||||||
|
* If a [\`maintained\`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/maintained) package is still broken at the time of merge, we will only merge if the maintainer has been pinged 7 days in advance. (If you care about a Haskell package, become a maintainer!)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
This is the follow-up to #${curr_haskell_updates_pr_num}. Come to [#haskell:nixos.org](https://matrix.to/#/#haskell:nixos.org) if you have any questions.
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Opening a PR for the next haskell-updates merge cycle"
|
||||||
|
gh pr create --repo NixOS/nixpkgs --base master --head haskell-updates --title "haskellPackages: update stackage and hackage" --body "$new_pr_body"
|
|
@ -20,6 +20,10 @@ The workflow generally proceeds in three main steps:
|
||||||
|
|
||||||
Each of these steps is described in a separate section.
|
Each of these steps is described in a separate section.
|
||||||
|
|
||||||
|
There is a script that automates the workflow for merging the currently open
|
||||||
|
`haskell-updates` PR into `master` and opening the next PR. It is described
|
||||||
|
at the end of this document.
|
||||||
|
|
||||||
## Initial `haskell-updates` PR
|
## Initial `haskell-updates` PR
|
||||||
|
|
||||||
In this section we create the PR for merging `haskell-updates` into `master`.
|
In this section we create the PR for merging `haskell-updates` into `master`.
|
||||||
|
@ -46,39 +50,8 @@ In this section we create the PR for merging `haskell-updates` into `master`.
|
||||||
|
|
||||||
1. Push these commits to the `haskell-updates` branch of the NixOS/nixpkgs repository.
|
1. Push these commits to the `haskell-updates` branch of the NixOS/nixpkgs repository.
|
||||||
|
|
||||||
1. Open a PR on Nixpkgs merging `haskell-updates` into `master`.
|
1. Open a PR on Nixpkgs for merging `haskell-updates` into `master`. The recommended
|
||||||
|
PR title and body text are described in the `merge-and-open-pr.sh` section.
|
||||||
|
|
||||||
|
|
||||||
Use the title `haskellPackages: update stackage and hackage` and the following message body:
|
|
||||||
|
|
||||||
```markdown
|
|
||||||
### This Merge
|
|
||||||
|
|
||||||
This PR is the regular merge of the `haskell-updates` branch into `master`.
|
|
||||||
|
|
||||||
This branch is being continually built and tested by hydra at https://hydra.nixos.org/jobset/nixpkgs/haskell-updates.
|
|
||||||
|
|
||||||
I will aim to merge this PR **by 2021-TODO-TODO**. If I can merge it earlier, there might be successor PRs in that time window. As part of our rotation @TODO will continue these merges from 2021-TODO-TODO to 2021-TODO-TODO.
|
|
||||||
|
|
||||||
### haskellPackages Workflow Summary
|
|
||||||
|
|
||||||
Our workflow is currently described in
|
|
||||||
[`pkgs/development/haskell-modules/HACKING.md`](https://github.com/NixOS/nixpkgs/blob/haskell-updates/pkgs/development/haskell-modules/HACKING.md).
|
|
||||||
|
|
||||||
The short version is this:
|
|
||||||
* We regularly update the Stackage and Hackage pins on `haskell-updates` (normally at the beginning of a merge window).
|
|
||||||
* The community fixes builds of Haskell packages on that branch.
|
|
||||||
* We aim at at least one merge of `haskell-updates` into `master` every two weeks.
|
|
||||||
* We only do the merge if the [`mergeable`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/mergeable) job is succeeding on hydra.
|
|
||||||
* If a [`maintained`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/maintained) package is still broken at the time of merge, we will only merge if the maintainer has been pinged 7 days in advance. (If you care about a Haskell package, become a maintainer!)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
This is the follow-up to #TODO. Come to [#haskell:nixos.org](https://matrix.to/#/#haskell:nixos.org) if you have any questions.
|
|
||||||
```
|
|
||||||
|
|
||||||
Make sure to replace all TODO with the actual values.
|
|
||||||
|
|
||||||
## Notify Maintainers and Fix Broken Packages
|
## Notify Maintainers and Fix Broken Packages
|
||||||
|
|
||||||
|
@ -111,7 +84,7 @@ It may help contributors to try to keep the GitHub comment updated with the
|
||||||
most recent build report.
|
most recent build report.
|
||||||
|
|
||||||
Maintainers should be given at least 7 days to fix up their packages when they
|
Maintainers should be given at least 7 days to fix up their packages when they
|
||||||
break. If maintainers don't fix up their packages with 7 days, then they
|
break. If maintainers don't fix up their packages within 7 days, then they
|
||||||
may be marked broken before merging `haskell-updates` into `master`.
|
may be marked broken before merging `haskell-updates` into `master`.
|
||||||
|
|
||||||
### Fix Broken Packages
|
### Fix Broken Packages
|
||||||
|
@ -180,24 +153,6 @@ following will happen:
|
||||||
|
|
||||||
- All updated files will be committed.
|
- All updated files will be committed.
|
||||||
|
|
||||||
### Merge `master` into `haskell-updates`
|
|
||||||
|
|
||||||
You should occasionally merge the `master` branch into the `haskell-updates`
|
|
||||||
branch.
|
|
||||||
|
|
||||||
In an ideal world, when we merge `haskell-updates` into `master`, it would
|
|
||||||
cause few Hydra rebuilds on `master`. Ideally, the `nixos-unstable` channel
|
|
||||||
would never be prevented from progressing because of needing to wait for
|
|
||||||
rebuilding Haskell packages.
|
|
||||||
|
|
||||||
In order to make sure that there are a minimal number of rebuilds after merging
|
|
||||||
`haskell-updates` into `master`, `master` should occasionally be merged into
|
|
||||||
the `haskell-updates` branch.
|
|
||||||
|
|
||||||
This is especially important after `staging-next` is merged into `master`,
|
|
||||||
since there is a high chance that this will cause all the Haskell packages to
|
|
||||||
rebuild.
|
|
||||||
|
|
||||||
## Merge `haskell-updates` into `master`
|
## Merge `haskell-updates` into `master`
|
||||||
|
|
||||||
Now it is time to merge the `haskell-updates` PR you opened above.
|
Now it is time to merge the `haskell-updates` PR you opened above.
|
||||||
|
@ -241,12 +196,60 @@ When you've double-checked these points, go ahead and merge the `haskell-updates
|
||||||
After merging, **make sure not to delete the `haskell-updates` branch**, since it
|
After merging, **make sure not to delete the `haskell-updates` branch**, since it
|
||||||
causes all currently open Haskell-related pull-requests to be automatically closed on GitHub.
|
causes all currently open Haskell-related pull-requests to be automatically closed on GitHub.
|
||||||
|
|
||||||
|
## Script for Merging `haskell-updates` and Opening a New PR
|
||||||
|
|
||||||
|
There is a script that automates merging the current `haskell-updates` PR and
|
||||||
|
opening the next one. When you want to merge the currently open
|
||||||
|
`haskell-updates` PR, you can run the script with the following steps:
|
||||||
|
|
||||||
|
1. Make sure you have previously authenticated with the `gh` command. The
|
||||||
|
script uses the `gh` command to merge the current PR and open a new one.
|
||||||
|
You should only need to do this once.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ gh auth login
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Make sure you have correctly marked packages broken. One of the previous
|
||||||
|
sections explains how to do this.
|
||||||
|
|
||||||
|
1. Merge `master` into `haskell-updates` and make sure to push to the
|
||||||
|
`haskell-updates` branch. (This can be skipped if `master` has recently
|
||||||
|
been merged into `haskell-updates`.)
|
||||||
|
|
||||||
|
1. Go to https://hydra.nixos.org/jobset/nixpkgs/haskell-updates and force an
|
||||||
|
evaluation of the `haskell-updates` jobset. See one of the following
|
||||||
|
sections for how to do this. Make sure there are no evaluation errors. If
|
||||||
|
there are remaining evaluation errors, fix them before continuing with this
|
||||||
|
merge.
|
||||||
|
|
||||||
|
1. Run the script to merge `haskell-updates`:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ ./maintainers/scripts/haskell/merge-and-open-pr.sh PR_NUM_OF_CURRENT_HASKELL_UPDATES_PR
|
||||||
|
```
|
||||||
|
|
||||||
|
This does the following things:
|
||||||
|
|
||||||
|
1. Fetches `origin`, makes sure you currently have the `haskell-updates`
|
||||||
|
branch checked out, and makes sure your currently checked-out
|
||||||
|
`haskell-updates` branch is on the same commit as
|
||||||
|
`origin/haskell-updates`.
|
||||||
|
|
||||||
|
1. Merges the currently open `haskell-updates` PR.
|
||||||
|
|
||||||
|
1. Updates Stackage and Hackage snapshots. Regenerates the Haskell package set.
|
||||||
|
|
||||||
|
1. Pushes the commits updating Stackage and Hackage and opens a new
|
||||||
|
`haskell-updates` PR on Nixpkgs. If you'd like to do this by hand,
|
||||||
|
look in the script for the recommended PR title and body text.
|
||||||
|
|
||||||
## Update Hackage Version Information
|
## Update Hackage Version Information
|
||||||
|
|
||||||
After merging into `master` you can update what hackage displays as the current
|
After merging into `master` you can update what Hackage displays as the current
|
||||||
version in NixOS for every individual package.
|
version in NixOS for every individual package. To do this you run
|
||||||
To do this you run `maintainers/scripts/haskell/upload-nixos-package-list-to-hackage.sh`.
|
`maintainers/scripts/haskell/upload-nixos-package-list-to-hackage.sh`. See the
|
||||||
See the script for how to provide credentials. Once you have configured that
|
script for how to provide credentials. Once you have configured credentials,
|
||||||
running this takes only a few seconds.
|
running this takes only a few seconds.
|
||||||
|
|
||||||
## Additional Info
|
## Additional Info
|
||||||
|
|
Loading…
Reference in a new issue