Skip to content

Commit

Permalink
chore: add taskfiles to simplify development (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkongie authored Nov 20, 2024
1 parent 386ac05 commit 0351646
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 4 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
golang 1.22.9
golangci-lint 1.62.0
task 3.40.0
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ build: clean
@echo "\n\t$(C_GREEN)# Build binary $(BINARY)$(C_END)"
go build -trimpath -ldflags $(LDFLAGS) -o $(BIN_FOLDER)/$(BINARY) main.go

.PHONY: lint
lint:
$(SCRIPTS_F)/golangci_html_report.sh

.PHONY: release
release:
@echo "\n\t$(C_GREEN)# Creating release $(VERSION) $(C_END)"
Expand Down
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,40 @@
<a href="https://github.com/smartcontractkit/timelock-worker/tree/develop/docs/DEVELOPMENT.md">Development</a>
<br />
</div>

## Development

### Getting Started

Install the developments tools and dependencies to get started.

#### Install `asdf`

[asdf](https://asdf-vm.com/) is a tool version manager. All dependencies used for local development of this repo are
managed through `asdf`. To install `asdf`:

1. [Install asdf](https://asdf-vm.com/guide/getting-started.html)
2. Follow the instructions to ensure `asdf` is shimmed into your terminal or development environment

#### Install `task`

[task](https://github.com/go-task/task) is an alternative to `make` and is used to provide commands for everyday
development tasks. To install `task`:

1. Add the asdf task plugin: `asdf plugin add task`
2. Install `task` with `asdf install task`
3. Run `task -l` to see available commands

### Installing Dependencies

Now that you have `asdf` and `task` installed, you can install the dependencies for this repo:

```bash
task install:tools
```

### Linting

```shell
task lint
```
13 changes: 13 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://taskfile.dev

version: "3"

includes:
install:
taskfile: ./taskfiles/install/Taskfile.yml

lint:
taskfile: ./taskfiles/lint/Taskfile.yml

test:
taskfile: ./taskfiles/test/Taskfile.yml
11 changes: 11 additions & 0 deletions taskfiles/install/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

includes:
asdf:
taskfile: ./asdf.yml

tasks:
tools:
desc: Installs development tools
cmds:
- task: asdf:install
14 changes: 14 additions & 0 deletions taskfiles/install/asdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'

tasks:
install:
internal: true
desc: Installs the tools defined in asdf
dir: '{{.USER_WORKING_DIR}}'
cmds:
# Add all the plugins defined in .tool-versions by reading the first column for the plugin
# name and adding it to asdf
- awk '{print $1}' .tool-versions | xargs -I _ asdf plugin add _

# Install all the tools defined in .tool-versions
- asdf install
15 changes: 15 additions & 0 deletions taskfiles/lint/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

tasks:
default:
desc: "Run Go lint checks"
cmds:
- golangci-lint run
fix:
desc: "Fix Go lint issues"
cmds:
- |
echo "Fixing Go lint issues..."
gofmt -s -w .
goimports -w .
golangci-lint run --fix
18 changes: 18 additions & 0 deletions taskfiles/test/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'

tasks:
default:
desc: "Run the entire test suite"
cmds:
- go test {{.CLI_ARGS}} ./...

coverage:
desc: "Run the entire test suite with coverage"
cmds:
- go test -coverprofile=coverage.out -covermode count ./...
- go tool cover -html=coverage.out

race:
desc: "Run the entire test suite with race detection"
cmds:
- go test -race ./...

0 comments on commit 0351646

Please sign in to comment.