Skip to content

Commit

Permalink
Migrating Makefile to a Go-native taskfile
Browse files Browse the repository at this point in the history
Remove the `Makefile` and introduce `tasks.go`. A task-runner written in
Go. It's a lightweight task runner that only requires Go, thus removing
this project's dependency on GNU Make. I implemented it for this express
purpose.

Is it really necessary to remove the dependency on `make`? Perhaps not,
but I think it's an interesting approach to reducing the project's
prerequisites, and I like having as few prerequisites as possible. Also
the challange of building this was a fune one :)

Signed-off-by: Eric Cornelissen <ericornelissen@gmail.com>
  • Loading branch information
ericcornelissen committed May 11, 2024
1 parent 4d8aa5d commit f46b071
Show file tree
Hide file tree
Showing 15 changed files with 875 additions and 354 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ trim_trailing_whitespace=true
[Containerfile*]
indent_style=tab

[Makefile]
indent_style=tab

[*.css]
indent_size=2
indent_style=space
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
go-version-file: go.mod
- name: Audit
run: make audit-capabilities
run: go run tasks.go audit-capabilities
vulnerabilities:
name: Vulnerabilities
runs-on: ubuntu-22.04
Expand All @@ -39,4 +39,4 @@ jobs:
with:
go-version-file: go.mod
- name: Audit
run: make audit-vulnerabilities
run: go run tasks.go audit-vulnerabilities
28 changes: 15 additions & 13 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
go-version-file: go.mod
- name: Build binary
run: make build
run: go run tasks.go build
compliance:
name: Compliance
runs-on: ubuntu-22.04
Expand All @@ -33,7 +33,7 @@ jobs:
with:
go-version-file: go.mod
- name: Check compliance
run: make compliance
run: go run tasks.go compliance
container:
name: Container
runs-on: ubuntu-22.04
Expand All @@ -53,7 +53,7 @@ jobs:
with:
go-version-file: go.mod
- name: Build container with ${{ matrix.engine }}
run: make container
run: go run tasks.go container
env:
CONTAINER_ENGINE: ${{ matrix.engine }}
- name: Test run container with ${{ matrix.engine }}
Expand All @@ -66,8 +66,12 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Install Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: go.mod
- name: Build
run: make dev-img
run: go run tasks.go dev-img
format:
name: Format
runs-on: ubuntu-22.04
Expand All @@ -81,7 +85,7 @@ jobs:
with:
go-version-file: go.mod
- name: Check source code formatting
run: make fmt-check
run: go run tasks.go format-check
reproducible:
name: Reproducible build
runs-on: ubuntu-22.04
Expand All @@ -95,7 +99,7 @@ jobs:
with:
go-version-file: go.mod
- name: Check reproducibility
run: make reproducible
run: go run tasks.go reproducible
test-unit:
name: Unit test
runs-on: ubuntu-22.04
Expand All @@ -109,7 +113,7 @@ jobs:
with:
go-version-file: go.mod
- name: Run tests
run: make test-randomized
run: go run tasks.go test-randomized
test-dogfeed:
name: Dogfeed
runs-on: ubuntu-22.04
Expand All @@ -123,7 +127,7 @@ jobs:
with:
go-version-file: go.mod
- name: Run on this repository
run: make run
run: go run tasks.go dogfeed
test-mutation:
name: Mutation test
runs-on: ubuntu-22.04
Expand All @@ -137,7 +141,7 @@ jobs:
with:
go-version-file: go.mod
- name: Run mutation tests
run: make test-mutation
run: go run tasks.go test-mutation
vet:
name: Vet
runs-on: ubuntu-22.04
Expand All @@ -151,7 +155,7 @@ jobs:
with:
go-version-file: go.mod
- name: Vet source code
run: make vet
run: go run tasks.go vet
web:
name: Web
runs-on: ubuntu-22.04
Expand All @@ -165,6 +169,4 @@ jobs:
with:
go-version-file: go.mod
- name: Build web app
run: |
cd web
make build
run: go run tasks.go web-build
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
run: |
echo "version=${GITHUB_REF#refs/tags/}" >>"$GITHUB_OUTPUT"
- name: Compile
run: make release-compile
run: go run tasks.go build-all
- name: Create GitHub release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ jobs:
with:
go-version-file: go.mod
- name: Build
run: |
cd web
make build
run: go run tasks.go web-build
- name: Deploy
uses: JamesIves/github-pages-deploy-action@ec9c88baef04b842ca6f0a132fd61c762aa6c1b0 # v4.6.0
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ cmd/ades/**
!cmd/ades/*.go
!Containerfile
!Containerfile.dev
!Makefile
!go.mod
!go.sum
!schema.json
Expand Down
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@ If you decide to make a contribution, please read the [DCO] and use the followin

---

## Tasks

This project uses a custom Go-based task runner to run common tasks. To get started run:

```shell
go run tasks.go
```

For example, you can run one task as:

```shell
go run tasks.go verify
```

We recommend configuring the following command alias:

```shell
alias gask='go run tasks.go'
```

Which would allow you to run:

```shell
gask verify
```

---

## Adding a Rule

To add a rule you need to add some information and logic to the `rules.go` file, and corresponding
Expand Down
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ FROM docker.io/golang:1.22.0 AS build
WORKDIR /src

COPY cmd/ ./cmd/
COPY Makefile go.mod go.sum *.go ./
COPY go.mod go.sum *.go ./

RUN make build
RUN go run tasks.go build

# ---

Expand Down
4 changes: 3 additions & 1 deletion Containerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
FROM docker.io/golang:1.22.0-alpine3.19

RUN apk add --no-cache \
bash git make
bash git perl-utils zip \
&& \
echo "alias gask='go run tasks.go'" >~/.bashrc

WORKDIR /ades
COPY go.mod go.sum ./
Expand Down
Loading

0 comments on commit f46b071

Please sign in to comment.