alan-turing-institute / whatwhat

A reimagining of nowwhat in OCaml
MIT License
0 stars 0 forks source link
hut23 hut23-1206

WhatWhat

whatwhat is an OCaml command-line tool to help monitor project status and allocations in the Research Engineering Group, aka Hut23. It is the successor to NowWhat (F#) and WhatNow (Racket); the latter contains an illuminating backbrief describing the history of project allocations in REG.

Brew install WhatWhat

The simplest way to use whatwhat is to brew install it. It is hosted in our local Hut23 tap. You will need to run the following commands:

brew update
brew tap alan-turing-institute/hut23
brew install alan-turing-institute/hut23/whatwhat

This is likely to install whatwhat from the pre-compiled Homebrew bottle (associated with a GitHub release), which will make the installation quicker. However, if there is not a bottle that matches your computer build it will automatically build from the source.

Once you have installed it, you will need to create a secrets.json file to store your personal access tokens, which you can do by running whatwhat init then populating the file with your github and forecast tokens.

These tokens can be found here:

whatwhat should now work, the following examples can get you started.

For extensive usage options, do whatwhat --help, or whatwhat <COMMAND> --help for the subcommands.

Lookup table for GitHub usernames

whatwhat attempts to match people's full names on Forecast with GitHub usernames. It is quite successful at doing this, but there are a few edge cases where people's GitHub profiles do not have enough data. To get around this, you can manually add a mapping inside the file ~/.config/whatwhat/users. Each line in this file should look like:

{Full name on Forecast}:{GitHub username}

(without the curly braces). If whatwhat's automatic username detection is turning up false positives for a person, you can also override it by entering their info in this file.

Developers Contents

  1. Setting up OCaml on macOS
  2. Installation and configuration
  3. Usage
  4. Resources for getting started with OCaml
  5. New Tags and Releases

Setting up OCaml on macOS

opam is the OCaml package manager, which can be installed using Homebrew. It installs all packages into ~/.opam. Most online instructions suggest that you need to run eval $(opam env), but with the invocation of opam init below you should not need to.

brew install opam
opam init --shell-setup -y
opam install dune utop odig ocaml-lsp-server ocamlformat -y

Setup for some editors (others can be set up in an analogous way):

Installation and configuration

First, check that you have the dune executable available on your $PATH:

which dune

dune is the 'official' OCaml build system, and is used throughout this README.

git clone git@github.com:alan-turing-institute/whatwhat.git
cd whatwhat
make install-deps
dune build

The make install-deps command takes care of installing project dependencies. See the wiki for more explanation of what goes on inside there.

dune places all its build artifacts in the _build folder. If you got to this point without errors, you should be able to run (the local version of) whatwhat:

dune exec -- whatwhat

It will most likely complain about a missing configuration or missing secret. To get around this, you will have to set up two files, one containing secrets and one containing other non-sensitive info.

Secrets

Put this in ~/.config/whatwhat/secrets.json (and make sure that it is not stored in source control, e.g. in your personal dotfiles / config!):

{
    "githubToken"    : "<yours here>",
    "githubBotToken" : "<get from the Shared Drive>",
    "forecastToken"  : "<yours here>",
    "slackToken"     : "<get from the Shared Drive>"
}

Configuration

Separately, place this in ~/.config/whatwhat/config.json:

{
    "githubProjectName"    : "Project Tracker",
    "githubProjectColumns" : ["Active", "Awaiting start", "Finding people", "Awaiting go/no-go"],
    "forecastId"           : "<yours here>",
    "githubRepoName"       : "Hut23",
    "githubRepoOwner"      : "alan-turing-institute"
}

You shouldn't need to change any of the other settings here.

Lookup table for GitHub usernames

whatwhat attempts to match people's full names on Forecast with GitHub usernames. It is quite successful at doing this, but there are a few edge cases where people's GitHub profiles do not have enough data. To get around this, you can manually add a mapping inside the file ~/.config/whatwhat/users. Each line in this file should look like:

{Full name on Forecast}:{GitHub username}

(without the curly braces). If whatwhat's automatic username detection is turning up false positives for a person, you can also override it by entering their info in this file.

Usage

Note that, to compile and execute the source code in your working directory, whatwhat should always be run using dune exec -- whatwhat [options]. Just running whatwhat [options] will use the installed version inside ~/.opam (if it exists). (You can create a shell alias if you're lazy: something like alias dew='dune exec -- whatwhat').

The following examples can get you started. For extensive usage options, do dune exec -- whatwhat --help, or dune exec -- whatwhat <COMMAND> --help for the subcommands.

Documentation

Online documentation for the main branch of whatwhat can be viewed at:

https://alan-turing-institute.github.io/whatwhat/whatwhat/index.html

Documentation is written using odoc syntax. To build documentation locally, there are a couple of options:

  1. make dunedoc

    Uses dune to build docs based on the development version of whatwhat (i.e. the actual source code on your computer). This documentation does not contain links to types, functions, etc. from other modules, and the build process can emit a few spurious warnings (see #64).

  2. make odigdoc

    Uses odig to build docs based on the installed version of whatwhat (i.e. the version inside ~/.opam). This documentation does link to that of other modules. However, you do have to install whatwhat first before this can be done; the Makefile takes care of this automatically.

See the Documentation wiki page for more description of what's going on with these commands.

Resources for getting started with OCaml

Official

Learning and getting started

Books and documentation

New Tags and Releases

When you make changes to the whatwhat code, the Homebrew tap of whatwhat needs to be updated. To do this, run dune exec update_whatwhat from the top level of the git repository. It takes a few minutes to run.

If it fails for any reason, fix the underlying error, then just rerun it and increment the version number one more time.

The update process used to be manual. It involved the following steps, which are saved here for posterity:

Steps for manually updating Homebrew release 1. Update the `version` in the `dune-project` file and commit that. 1. Create a new git tag using `git tag -a vX.Y.Z -m vX.Y.Z` (replace X, Y, Z with the appropriate numbers. 1. To push the tag to the repo, run `git push` followed by `git push --tags` 1. Edit the `whatwhat.rb` file in the [homebrew-hut23](https://github.com/alan-turing-institute/homebrew-hut23/) repo. In this instance, you only need to edit the line beginning `url "...", tag "vX.Y.Z", revision "..."`. Change the `tag` string to the new version number, and replace the revision string with the *full* git commit SHA corresponding to the tag you just added. You can obtain this from the output of `git log`. Commit SHA This single step used to be done via a GitHub Action. The action yaml has since been removed from the repository, but you can see the [file in a previous commit here](https://github.com/alan-turing-institute/whatwhat/blob/68ebc36d55864baccaedab7ea928ad722493907a/.github/workflows/bump-brew-formula.yaml). 1. In the terminal navigate to a custom directory. You now need to type `brew update` to make sure you have the latest `whatwhat` formula. If you already have `whatwhat` brew installed, you'll need to uninstall it `brew uninstall whatwhat`. Then type ```sh brew install --build-bottle --verbose whatwhat brew bottle whatwhat --no-rebuild ``` This will create a bottle (a prebuilt binary) in that directory and will print a new `bottle do` block to your terminal 1. Copy that code snippet, go to the [ruby file](https://github.com/alan-turing-institute/homebrew-hut23/blob/main/whatwhat.rb) in the [homebrew-hut23](https://github.com/alan-turing-institute/homebrew-hut23/) and paste it to overwrite the previous `bottle do` instructions. 1. Commit the changes to main 1. Rename the bottle file to remove one of the dashes (i.e. from `whatwhat--` to `whatwhat-`) 1. Going back to the [whatwhat repo](https://github.com/alan-turing-institute/whatwhat/) go to releases -> tags tab and click on the latest tag. 1. Click create release from tag 1. Upload the binary from your computer 1. Click 'publish release' 1. Copy the url of the release and paste this as the first line within `bottle do` in the [ruby file](https://github.com/alan-turing-institute/homebrew-hut23/blob/main/whatwhat.rb), in the form of `root_url "https://github.com/alan-turing-institute/whatwhat/releases/download/"`. Note this should be the same as the url, but with 'download' rather than 'tag'. Make sure you commit this change. 1. This should now work - users will now be able to `brew install` the latest version of Whatwhat.