Skip to content

Commit

Permalink
Fix haskell language server tooling (#14)
Browse files Browse the repository at this point in the history
* Always run type checks and lint command

* Add local forwards to stack commands

* Remove .cabal file in new day script

* Update cabal hash

* Add setup instructions
  • Loading branch information
manuphatak authored Dec 8, 2020
1 parent d1cbbfe commit 44586d8
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
docker:
- image: fpco/stack-build:lts
auth:
username: bionikspoon
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
working_directory: /app
steps:
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion AdventOfCode2020.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
7 changes: 7 additions & 0 deletions bin/day
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ log "Fetching README.md"


log "Update Stack"
rm -v AdventOfCode2020.cabal
stack setup

if [ $# -eq 2 ] && [ "$2" = "commit" ]
Expand All @@ -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


Expand Down
5 changes: 5 additions & 0 deletions bin/ghc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail


stack exec ghc -- "$@"
5 changes: 5 additions & 0 deletions bin/hlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail


stack exec hlint -- "$@"
5 changes: 5 additions & 0 deletions bin/hspec-discover
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail


stack exec hspec-discover -- "$@"

0 comments on commit 44586d8

Please sign in to comment.