diff --git a/.circleci/config.yml b/.circleci/config.yml index 36ca134..14d64c3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ jobs: docker: - image: fpco/stack-build:lts auth: - username: bionikspoon + username: $DOCKERHUB_USERNAME password: $DOCKERHUB_PASSWORD working_directory: /app steps: @@ -41,8 +41,10 @@ jobs: - run: name: Type checks command: stack --no-terminal build --pedantic + when: always - run: name: Lint command: stack --no-terminal exec hlint -- --git --report=hlint.html + when: always - store_artifacts: path: hlint.html diff --git a/AdventOfCode2020.cabal b/AdventOfCode2020.cabal index b48d082..75666fb 100644 --- a/AdventOfCode2020.cabal +++ b/AdventOfCode2020.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 82c50a29206ade6a1f35a9b072bd93d96bb67d3042caabc93bee04517e67e2de +-- hash: 85cdf949abc33898fb68bc532705f9a48e78f9a291a1976961440d8cfebdd4e7 name: AdventOfCode2020 version: 2.0.2.0 diff --git a/README.md b/README.md index 2c5b090..0c8daec 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,81 @@ Solutions to adventofcode.com/2020 ```sh $ stack test --file-watch --fast ``` + +## Workflow + +### Start a new day Part 1 + +```sh +$ day 1 commit +``` + +`./bin/day 1 commit` Creates a workspace to solve a new day's problem. + +Steps + +- copies the Template directories and string replaces placeholder values +- fetches input the problem input and saves it to `./test/Day01/input.txt` +- fetches the problem statement, converts it to markdown, and saves it as + `./src/Day01/README.md` +- updates the `.cabal` file +- if `commit` is included + - creates a branch + - adds and commits the new files + - pushes the branch to origin + - opens a pull-request + +### Continue to Part 2 + +```sh +$ readme 1 +``` + +`./bin/readme 1` After solving part 1, get a new README with the full problem +statement including part 2. + +## Setup + +### Dependencies + +- [`direnv`](https://direnv.net/) - used to add project specific env variables +- `yarn global add @bionikspoon/html-to-md` +- `yarn global add prettier"` +- `go get github.com/ericchiang/pup"` +- https://hub.docker.com/ API key for Circle CI +- https://codecov.io/ project token for circle CI + +### Getting Started + +1. Create an `.envrc` + + ```sh + $ cp .envrc.sample .envrc + ``` + +1. Add a `SESSION_ID` to the `.envrc` + + - go to `https://adventofcode.com/` + - login + - Right click -> "Inspect" -> Click the "Application" tab -> Look for + "Storage -> Cookies -> https://adventofcode.com/" -> Copy the "session" + value + - Save the "session" value as `SESSION_ID` in `.envrc` + +1. Enable the `.envrc` file + + ```sh + $ direnv allow + ``` + +1. Add environment variables to [CircleCI](https://app.circleci.com/) + + - `CODECOV_TOKEN` + - `DOCKERHUB_PASSWORD` + - `DOCKERHUB_USERNAME` + +1. Setup `.hspec` + + ```sh + $ cp .hspec.sample .hspec + ``` diff --git a/bin/day b/bin/day index d8d7837..23bc452 100755 --- a/bin/day +++ b/bin/day @@ -41,6 +41,7 @@ log "Fetching README.md" log "Update Stack" +rm -v AdventOfCode2020.cabal stack setup if [ $# -eq 2 ] && [ "$2" = "commit" ] @@ -56,6 +57,12 @@ then log "Git Commit" git commit -v -m "Setup Day $D" + + log "Push Branch" + git push --verbose --set-upstream origin "$(git-branch-current 2> /dev/null)" + + log "Create Pull Request" + hub pull-request -m "Solve Day $D" fi diff --git a/bin/ghc b/bin/ghc new file mode 100755 index 0000000..891dfbf --- /dev/null +++ b/bin/ghc @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + + +stack exec ghc -- "$@" diff --git a/bin/hlint b/bin/hlint new file mode 100755 index 0000000..1e2184e --- /dev/null +++ b/bin/hlint @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + + +stack exec hlint -- "$@" diff --git a/bin/hspec-discover b/bin/hspec-discover new file mode 100755 index 0000000..3a11af0 --- /dev/null +++ b/bin/hspec-discover @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + + +stack exec hspec-discover -- "$@"