Skip to content

Commit

Permalink
chore: Rework Makefile (#18)
Browse files Browse the repository at this point in the history
* chore: Rework Makefile
  • Loading branch information
sonjek authored Nov 17, 2024
1 parent 93f90ff commit 6a2c8e2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 31 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ jobs:
with:
go-version-file: go.mod
check-latest: true
- name: Install tools
run: make tools
- name: Run generate templ files
run: make generate
run: make generate-web
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v4
with:
Expand All @@ -52,10 +50,8 @@ jobs:
with:
go-version-file: go.mod
check-latest: true
- name: Install tools
run: make tools
- name: Run generate templ files
run: make generate
run: make generate-web
- name: Run tests
run: make test
build:
Expand All @@ -70,7 +66,5 @@ jobs:
with:
go-version-file: go.mod
check-latest: true
- name: Install tools
run: make tools
- name: Build
run: make build
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ linters-settings:
disabled: true
- name: cyclomatic
disabled: true
- name: max-public-structs
disabled: true
- name: unused-receiver
disabled: true
- name: unhandled-error
Expand Down
22 changes: 7 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ all: help

## build: Compile templ files and build application
.PHONY: build
build: get-deps generate
build: get-deps generate-web
CGO_ENABLED=0 go build -ldflags="-s -w -extldflags '-static'" -trimpath -o 'bin/app' ./cmd/app

## start: Build and start application
.PHONY: start
start: get-deps generate
start: get-deps generate-web
go run ./cmd/app

## build-docker: Build Docker container image with this app
Expand Down Expand Up @@ -48,24 +48,16 @@ tidy: check-go
get-deps: check-go
go mod download

## tools: Install github.com/a-h/templ/cmd/templ@latest
.PHONY: tools
tools: check-go
## generate-web: Compile templ files via github.com/a-h/templ/cmd/templ
.PHONY: generate-web
generate-web: check-go
go install github.com/a-h/templ/cmd/templ@latest

## get-air: Install live reload server github.com/cosmtrek/air@latest
.PHONY: get-air
get-air: check-go
go install github.com/cosmtrek/air@latest

## generate: Compile templ files
.PHONY: generate
generate:
~/go/bin/templ generate

## air: Build and start application in live reload mode via air
.PHONY: air
air: get-deps generate
air: get-deps generate-web
go install github.com/cosmtrek/air@latest
air

## check-go: Check that Go is installed
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ Available makefile actions:
Usage: make COMMAND

Commands:
help Display help
tools Install github.com/a-h/templ/cmd/templ@latest
get-deps Download go dependencies
generate Compile templ files
build Compile templ files and build application
start Build and start application
get-air Install live reload server github.com/cosmtrek/air@latest
air Build and start application in live reload mode via air
build-docker Build Docker container image with this app
run-docker Run Docker container image with this app
test Run unit tests
tidy Removes unused dependencies and adds missing ones
get-deps Download go dependencies
generate-web Compile templ files via github.com/a-h/templ/cmd/templ
air Build and start application in live reload mode via air
check-go Check that Go is installed
help Display help
```

## Local Development Setup

To get started, follow these steps:

1) Run `make tools` to install the necessary tools.
2) Run `make start` to download go dependencies, compile templ files, build application and finally start application.
1) Run `make start` to download go dependencies, compile templ files, build application and finally start application.
```sh
% make tools
go install github.com/a-h/templ/cmd/templ@latest
Expand Down

0 comments on commit 6a2c8e2

Please sign in to comment.