Skip to content

Commit

Permalink
Use mise for sharing versions in CI and local dev (#17)
Browse files Browse the repository at this point in the history
Currently, versions for Go and related tools (e.g., golangci-lint) are
specified differently for CI and local development. Using mise
allows us to share the same config across environments.

Local development only uses latest, but we also want to test go1.22 on
CI so use mise environments to use a separate config for oldstable.

Start using mise tasks, moving the `lint` target from Makefile to mise.
  • Loading branch information
prashantv authored Jan 12, 2025
1 parent 4f792e1 commit 64c4283
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,28 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.22.x', '1.23.x']
mise-env: ['oldstable', 'stable']
env:
GO_NOT_LATEST: ${{ matrix.go-version != '1.23.x' }}
GO_NOT_LATEST: ${{ matrix.mise-env != 'stable' }}
MISE_ENV: ${{ matrix.mise-env }}

steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
with:
cache_key_prefix: mise-v0-${{ matrix.mise-env }}

- name: Set up Go ${{ matrix.go-version }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Verify Go version
run: go version

- name: Build
run: go build -v ./...
run: mise run build

- name: Test
run: go test -v ./...
run: mise run test

- name: Verify golden files
if: env.GO_NOT_LATEST == 'false'
Expand All @@ -42,12 +44,12 @@ jobs:
lint:
name: lint
runs-on: ubuntu-latest
env:
MISE_ENV: stable
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.23.x
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.63.4
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
with:
cache_key_prefix: mise-v0-stable
- name: lint
run: mise run lint
2 changes: 2 additions & 0 deletions .mise.oldstable.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
go = "1.22"
16 changes: 16 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tools]
go = "1.23"
golangci-lint = "v1.63.4"

[tasks.build]
description = "Build Go packages"
run = "go build ./..."

[tasks.test]
description = "Run Go tests"
run = "go test ./..."

[tasks.lint]
description = "Run golangci-lint"
run = "golangci-lint run ./..."

3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,3 @@ diff-testdata::
endef
$(foreach d,$(CMP_TEST_DIRS),$(eval $(call cmp_rule,$d)))

.PHONY: lint
lint:
golangci-lint run ./...

0 comments on commit 64c4283

Please sign in to comment.