Skip to content

Commit

Permalink
merge w/ main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed Dec 24, 2023
2 parents 761c022 + 35b471e commit ab4dad6
Show file tree
Hide file tree
Showing 14 changed files with 1,682 additions and 12 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

name: Nix

on:
push:
branches:
- main
pull_request:
schedule:
- cron: '0 1 * * *'


jobs:
nix-build-unstable:
runs-on: ubuntu-latest

steps:
- name: Install Nix
uses: cachix/install-nix-action@v24
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: nix build

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ harmony-npm.tar.gz
.*.swp
*.idr~

result
25 changes: 21 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ idris2-version = $(shell $(idris2) --version | sed -En 's/Idris 2, version ([^-]
idris2-build = $(shell $(idris2) --version | sed -En 's/Idris 2, version [^-]+(.*)/\1/p')
idris2-minor-version = $(shell echo ${idris2-version} | sed -En 's/0\.(.*)\../\1/p')

.PHONY: all build install package publish clean version
.PHONY: all build nix-build install package publish clean version

all: build

depends/idris-adds-${idris-adds-version}:
mkdir -p depends/idris-adds-${idris-adds-version}
mkdir -p build/deps
ifeq ($(IDRIS_ADDS_SRC),)
cd build/deps && \
if [ ! -d ./idris-adds ]; then \
git clone https://github.com/mattpolzin/idris-adds.git; \
Expand All @@ -28,6 +29,14 @@ depends/idris-adds-${idris-adds-version}:
git checkout ${idris-adds-version} && \
make && \
cp -R ./build/ttc/* ../../../depends/idris-adds-${idris-adds-version}/
else
cd build/deps && \
cp -R $(IDRIS_ADDS_SRC) ./idris-adds && \
chmod -R +rw ./idris-adds && \
cd idris-adds && \
make && \
cp -R ./build/ttc/* ../../../depends/idris-adds-${idris-adds-version}/
endif

depends/elab-util-${idris-elab-util-version}:
mkdir -p depends/elab-util-${idris-elab-util-version}
Expand Down Expand Up @@ -77,26 +86,34 @@ depends/json-${idris-json-version}: depends/elab-util-${idris-elab-util-version}
IDRIS2_PACKAGE_PATH="$IDRIS2_PACKAGE_PATH:../../../depends" $(idris2) --build json.ipkg && \
cp -R ./build/ttc/* ../../../depends/json-${idris-json-version}/

node_modules:
./node_modules/: package.json
npm install

build: node_modules depends/idris-adds-${idris-adds-version} depends/json-${idris-json-version}
build: ./node_modules/ depends/idris-adds-${idris-adds-version} depends/json-${idris-json-version}
IDRIS2_DATA=./support $(idris2) --build harmony.ipkg
@if [[ ${idris2-minor-version} -gt 6 ]] || [[ "${idris2-build}" != '' ]]; then \
cp ./build/exec/harmony ./harmony; \
else \
echo "#!/usr/bin/env node\n" > ./harmony; \
echo "#!/usr/bin/env node" > ./harmony; \
cat ./build/exec/harmony >> ./harmony; \
fi
@chmod +x ./harmony

harmony: build

node2nix ?= nix run nixpkgs\#node2nix

nix-build:
${MAKE} clean
$(node2nix) -- --composition node2nix.nix # -l # <- can't use -l for lockfile because lockfile version 3 not supported yet.
nix build .

version:
@(if [[ "${v}" == '' ]]; then echo "please set the 'v' variable."; exit 1; fi)
sed -I '' "s/version = .*/version = ${v}/" ./harmony.ipkg
sed -I '' "s/appVersion = \".*\"/appVersion = \"${v}\"/" ./src/AppVersion.idr
sed -I '' "s/\"version\": \".*\"/\"version\": \"${v}\"/" ./package.json
sed -I '' "s/version = \".*\";/version = \"${v}\";/" ./default.nix

package: build
./version-check.sh
Expand Down
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
# Harmony
Harmony is a small tool that helps teams keep GitHub reviews running smoothly. It takes the work out of picking someone from a pool of developers to review a new PR. Harmony does this by heuristically determining who on a particular GitHub Team has the least current/recent review workload.

Harmony offers a heuristic for PR assignments that is different than GitHub's round robin or weighted algorithms, but Harmony can also work well even if your team uses GitHub's automatic PR assignments ([see below](#deferring-to-github)).

## Dependencies
### Runtime
Running Harmony only requires NodeJS 14+ (and a local installation of `git`).
Running Harmony requires NodeJS 14+ (and a local installation of `git`) or alternatively Nix with flakes enabled.

If you'd like to try Harmony out without even "installing" it and you have Nix installed with flakes enabled, you can run it as `nix run github:mattpolzin/harmony`.

### Build time
Building the latest commits of Harmony requires a HEAD build of the Idris 2 compiler. Each release page also indicates the version of Idris 2 that particular release will build against.

Expand All @@ -29,6 +34,18 @@ You can install Harmony via npm directly by running `npm install -g @mattpolzin/
### GitHub Release
You can install any Harmony release by downloading the `harmony-npm.tar.gz` file from the GitHub Release page, unzipping it, and running `npm install --global`.

### Nix Flake
You can add Harmony to your Flake inputs as follows:
```nix
inputs = {
...
harmony.url = "github:mattpolzin/harmony";
harmony.inputs.nixpkgs.follows = "nixpkgs";
};
```

Then, in your outputs, bring Harmony into a package install list as `harmony.packages.<system>.harmony`.

### From Source
The build script assumes a HEAD build of Idris 2 is installed on your system. For an alternative, see the [Docker Build](#docker-build) instructions below.

Expand Down Expand Up @@ -130,14 +147,15 @@ If `harmony config assignUsers` is `True` (defualt) then harmony will pick someo

You can also require that specific additional users (on top of the one Harmony will pick for you) are assigned to the PR. You do this by specifying those users' logins prefixed with '+' as arguments to Harmony.

You can optionally apply any number of labels to the PR at the same time as assigning reviewers by prefixing the labels with '#'.

#### Deferring to GitHub
If your team has GitHub set up to auto-assign individuals when a team is requested for review, you probably want to tell harmony not to also pick someone using its heuristics. You can run the following `config` commands to tell harmony to assign a team but not also pick an individual from that team:
```shell
harmony config assignTeams true
harmony config assignUsers false
```

You can optionally apply any number of labels to the PR at the same time as assigning reviewers by prefixing the labels with '#'.

#### Examples
Assign the most available reviewer from the "developers" GitHub Team:
```shell
Expand All @@ -155,7 +173,7 @@ harmony assign web +carl001 +emmaham
```

### Contribute
Running `harmony contribute` will print the URI of the oldest PR waiting for your review. If you are not requested for review on any PRs, Harmony will suggest a PR that you are not assigned to.
Running `harmony contribute` will print the URI of the oldest non-draft PR waiting for your review. If you are not requested for review on any PRs, Harmony will suggest a PR that you are not assigned to.

You can skip PRs and retrieve the next-oldest one by passing a dash followed by the number to skip (e.g. `-2` to skip the two oldest waiting PRs).

Expand Down Expand Up @@ -197,6 +215,8 @@ Running `harmony whoami` will print information about the currently configured a
### Reflect
Running `harmony reflect` will show a summary of your review requests and authored pull requests.

![Reflect Screenshot](./docs/images/reflect.png)

### List
Running `harmony list <team>` will list the members of the given GitHub Team.

Expand Down
46 changes: 46 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{ stdenv, lib, callPackage, fetchFromGitHub, idris2, makeWrapper, nodejs }:
let
nodeDependencies = (callPackage ./node2nix.nix { inherit nodejs; }).nodeDependencies;
idrisAddsVersion = "0.3.0";
idrisAddsSrc = fetchFromGitHub {
owner = "mattpolzin";
repo = "idris-adds";
rev = "${idrisAddsVersion}";
hash = "sha256-OSu381nUNZqFJs4HzmMxGda60k7xsa1GulQq7kU/R2o=";
};
in
stdenv.mkDerivation {
pname = "harmony";
version = "2.6.2";

nativeBuildInputs = [ idris2 makeWrapper ];
buildInputs = [ nodejs ];

src = ./.;

buildPhase = ''
runHook preBuild
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
export PATH="${nodeDependencies}/bin:$PATH"
export IDRIS_ADDS_SRC="${idrisAddsSrc}"
make build
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp harmony $out/bin/
wrapProgram $out/bin/harmony \
--prefix PATH : ${lib.makeBinPath [ nodeDependencies ]} \
--prefix NODE_PATH : ${nodeDependencies}/lib/node_modules
runHook postInstall
'';

}
Binary file added docs/images/reflect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
description = "Harmony GitHub collaboration tool";

inputs = {
nixpkgs.url = github:NixOS/nixpkgs;
};

outputs = { self, nixpkgs }:
let
lib = nixpkgs.lib;
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
in
{
packages = forAllSystems (system:
{
harmony = with nixpkgs.legacyPackages.${system};
callPackage ./default.nix {};

default = self.packages.${system}.harmony;
}
);
};
}
2 changes: 1 addition & 1 deletion harmony.ipkg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT"
-- sourceloc =
-- bugtracker =

langversion >= 0.6.0
langversion >= 0.7.0

depends = contrib
, idris-adds >= 0.3.0
Expand Down
Loading

0 comments on commit ab4dad6

Please sign in to comment.