Skip to content

Commit

Permalink
Migrate to mise for local/CI and bump versions
Browse files Browse the repository at this point in the history
Normally I wouldn't want to introduce an extra dependency in CI, but I
think this would be extremely easy to undo if it ever started to cause
problems. The main reason to use it in actions is to avoid declaring
tool versions in two places that need to be kept in sync.

The major benefit here is that for tools like golangci-lint and
goreleaser, we now use an official release binary rather than building
from source, which was never officially supported or recommended. Not
that it's caused problems yet, but better to play it safe.

This also has the benefit of ensuring that the version of golangci-lint
that runs in my editor is the same as the version the project wants me
to use.
  • Loading branch information
rliebz committed Jan 3, 2025
1 parent 3ed5638 commit 7208eb2
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 1,572 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.5"
- uses: jdx/mise-action@v2
- name: Release Dry Run
run: |
header='^## [0-9]+\.[0-9]+\.[0-9]+'
awk "/${header}/{if(!found){found=1;f=1}else{f=0}} f" CHANGELOG.md |
go run github.com/goreleaser/goreleaser --release-notes /dev/stdin
goreleaser --release-notes /dev/stdin
env:
GITHUB_TOKEN: ${{ secrets.GH_REPO_PAT }}

Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up
uses: actions/setup-go@v4
with:
go-version: "1.22.5"
- uses: jdx/mise-action@v2
- name: Build
run: go build -v ./...
- name: Test
Expand All @@ -36,29 +33,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.5"
- uses: jdx/mise-action@v2
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.59.1
install-mode: none

release:
name: Release Dry Run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.5"
- uses: jdx/mise-action@v2
- name: Release Dry Run
run: |
header='^## [0-9]+\.[0-9]+\.[0-9]+'
awk "/${header}/{if(!found){found=1;f=1}else{f=0}} f" CHANGELOG.md |
go run github.com/goreleaser/goreleaser --release-notes /dev/stdin --snapshot
goreleaser --release-notes /dev/stdin --snapshot
docs:
name: Docs Dry Run
Expand Down
7 changes: 4 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
version: 2
project_name: tusk
before:
hooks:
Expand All @@ -14,13 +15,13 @@ builds:
- darwin
- windows
goarch:
- 386
- "386"
- amd64
- arm
- arm64
ignore:
- goos: darwin
goarch: 386
goarch: "386"
archives:
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format: tar.gz
Expand All @@ -35,7 +36,7 @@ archives:
- appcli/completion/tusk.fish
- appcli/completion/_tusk
snapshot:
name_template: SNAPSHOT-{{ .Commit }}
version_template: SNAPSHOT-{{ .Commit }}
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
release:
Expand Down
4 changes: 4 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tools]
go = "1.22.5"
golangci-lint = "1.62.2"
goreleaser = "2.5.1"
26 changes: 10 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,16 @@ should be added in [docs/spec.md][spec.md].

## Setting Up a Development Environment

For local development, you will need Go version 1.11+ installed.
For local development, you will need Go and golangci-lint installed. The
easiest way to do this is with [mise](https://mise.jdx.dev/), but it is not
required.

Tusk uses go modules for dependency management, so make sure to clone the
project outside of the `GOPATH`. If that doesn't mean anything to you, you're
probably fine.
If it is not already on your path, you probably want to have the `GOBIN`
directory available for projects installed by `go install`. To do so, add the
following to your `.bash_profile` or `.zshrc`:

```bash
git clone https://github.com/rliebz/tusk.git
```

If it is not already on your path, you probably also want to have the `GOPATH`
binary directory available for projects installed by `go get` and `go install`.
To do so, add the following to your `.bash_profile` or `.zshrc`:

```bash
export PATH="$PATH:$(go env GOPATH)/bin"
export PATH="$PATH:$(go env GOBIN)"
```

To install Tusk:
Expand All @@ -61,7 +55,7 @@ against the development version installed locally. If you do not get `(devel)`
as the version, you may need to move your Go binary path earlier in your
`PATH`:

```bash
```console
$ tusk --version
(devel)
```
Expand All @@ -83,7 +77,7 @@ To run the unit tests:
tusk test
```

To run the full test suite, along with the linter:
To run the full test suite, along with golangci-lint:

```bash
tusk test -a
Expand All @@ -95,7 +89,7 @@ violation is necessary for your contribution, you can disable a specific linter
for that line:

```golang
cmd := exec.Command("sh", "-c", command) // nolint: gosec
cmd := exec.Command("sh", "-c", command) //nolint:gosec
```

[spec.md]: https://github.com/rliebz/tusk/blob/main/docs/spec.md
Loading

0 comments on commit 7208eb2

Please sign in to comment.