Skip to content

Commit

Permalink
Add CI workflow and some more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chokoswitch committed May 9, 2024
1 parent 391fafa commit f543257
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI
on:
push:
branches:
- main
tags:
- "*"
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-13
- macos-14
- ubuntu-22.04
- windows-2022
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.work
cache-dependency-path: "**/go.sum"

- name: run checks
run: go run build check
27 changes: 27 additions & 0 deletions RATIONALE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Notable rationale of go-build

## Use goyek

We do not use Makefile, probably the most common tool for builds in Go, because
it is tedious to do complex tasks and hard to make cross-platform.

We have used [Mage](https://magefile.org/) in other projects and it works well -
for projects that currently use Makefile, it can be easier to convince members
to migrate to it vs goyek. It has some quirks though.

For further details, see goyek's [explanation](https://github.com/goyek/goyek?tab=readme-ov-file#alternatives)
which is fair and follows our thoughts.

## Use gofumpt

We prefer to have less bikeshedding in code reviews, and this includes formatting.
While this isn't as prevalent in the Go ecosystem yet, it is common practice in others
such as NodeJS. Where possible, we will prefer auto-formatting that enforces as much
structure as possible. It's automatic, so why not?

## Use gci

We believe there is significant stylistic benefit in having consistent import
ordering and grouping, something the Go standard goimports [cannot do](https://github.com/golang/go/issues/20818).
Both gci and gosimports are great tools for this, and we choose gci because it
is also integrated with golangci-lint, making it simpler to verify in CI.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ a Go workspace to keep build-specific libraries like goyek out of your standard
modules file, or remove the go.mod / go.sum files to include it as a normal
package.

Using the folder `build` is a goyek convention, but any folder name will work,
i.e. if you already use `build` for transient artifacts. Note that these tasks
use `out` for transient artifacts.

A list of all tasks can be seen with `go run ./build -h`. The commonly used tasks
will likely be:

Expand Down
4 changes: 4 additions & 0 deletions go-build.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"settings": {
"editor.tabSize": 2,
"eslint.workingDirectories": [{ "mode": "auto" }],
"[github-actions-workflow]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"gopls": {
"formatting.gofumpt": true
},
Expand Down

0 comments on commit f543257

Please sign in to comment.