From d87113ddff45d71febda962ae76730492e8e4a5f Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Fri, 26 Jun 2026 07:42:04 -0500 Subject: [PATCH] ci: modernize repo to use justfile --- .copywrite.hcl | 12 ------ .github/dependabot.yaml | 12 +++++- .github/workflows/ci.yaml | 55 ++++++++++--------------- .github/workflows/scripts/golangci.yaml | 43 +++++++++++++++++++ .gitignore | 14 +++++++ .golangci.yaml | 12 ------ Justfile | 45 ++++++++++++++++++++ Makefile | 12 ------ go.mod | 6 +-- go.sum | 8 ++-- 10 files changed, 140 insertions(+), 79 deletions(-) delete mode 100644 .copywrite.hcl create mode 100644 .github/workflows/scripts/golangci.yaml create mode 100644 .gitignore delete mode 100644 .golangci.yaml create mode 100644 Justfile delete mode 100644 Makefile diff --git a/.copywrite.hcl b/.copywrite.hcl deleted file mode 100644 index 87af51d..0000000 --- a/.copywrite.hcl +++ /dev/null @@ -1,12 +0,0 @@ -schema_version = 1 - -project { - license = "MPL-2.0" - copyright_holder = "The M1CPU Authors" - copyright_year = 2022 - header_ignore = [ - ".golangci.yaml", - ".copywrite.hcl", - ".github/**", - ] -} diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index b5501e3..44db944 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -1,7 +1,15 @@ version: 2 updates: - - package-ecosystem: gomod - directory: "/" + - package-ecosystem: "github-actions" + directories: + - "/" + schedule: + interval: "monthly" + labels: + - "dependencies" + - package-ecosystem: "gomod" + directories: + - "/" schedule: interval: "monthly" labels: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b7b4ba4..bbf5077 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,41 +1,28 @@ name: Run CI Tests -on: [push] +on: + pull_request: + paths-ignore: + - 'README.md' + - 'LICENSE' + push: + branches: + - 'main' jobs: - run-copywrite: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - uses: hashicorp/setup-copywrite@v1.1.2 - - name: verify copyright - run: | - copywrite headers --plan - run-lint: - runs-on: [macos-latest] - steps: - - uses: actions/checkout@v3 - - uses: hashicorp/setup-golang@v1 - with: - version-file: go.mod - - name: GolangCI-Lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.52.2 - skip-cache: true run-tests: - strategy: - fail-fast: false - matrix: - os: - - macos-11 - - macos-12 - - ubuntu-22.04 - runs-on: ${{matrix.os}} + timeout-minutes: 5 + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v3 - - uses: hashicorp/setup-golang@v1 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 + - uses: actions/setup-go@v6 with: - version-file: go.mod + cache: true + go-version-file: go.mod + - name: Show System + run: | + uname -a + just sysinfo - name: Run Go Test run: | - make vet - make test + just init tidy lint tests + diff --git a/.github/workflows/scripts/golangci.yaml b/.github/workflows/scripts/golangci.yaml new file mode 100644 index 0000000..a44689c --- /dev/null +++ b/.github/workflows/scripts/golangci.yaml @@ -0,0 +1,43 @@ +version: "2" +linters: + enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - copyloopvar + - dogsled + - dupword + - durationcheck + - errname + - errorlint + - exhaustive + - gochecknoinits + - gocritic + - makezero + - misspell + - musttag + - nilnil + - noctx + - perfsprint + - prealloc + - predeclared + - reassign + - revive + - rowserrcheck + - sqlclosecheck + - tagalign + - usetesting + - whitespace + settings: + exhaustive: + default-signifies-exhaustive: true + exclusions: + generated: lax + presets: + - comments +formatters: + enable: + - gofmt + exclusions: + generated: lax diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3727f8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*~ +~* + +# OS files +**/.DS_Store + +# Go workspace file +go.work +go.work.sum + +# Local source and binary files +.src/ +.bin/ + diff --git a/.golangci.yaml b/.golangci.yaml deleted file mode 100644 index dc6fefb..0000000 --- a/.golangci.yaml +++ /dev/null @@ -1,12 +0,0 @@ -run: - timeout: 5m -linters: - enable: - - gofmt - - errcheck - - errname - - errorlint - - bodyclose - - durationcheck - - whitespace - diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..76e5bad --- /dev/null +++ b/Justfile @@ -0,0 +1,45 @@ +set shell := ["bash", "-u", "-c"] + +export scripts := ".github/workflows/scripts" +export GOBIN := `echo $PWD/.bin` + +# show available commands +[private] +default: + @just --list + +# tidy up Go modules +[group('build')] +tidy: + go mod tidy + +# run tests across source tree +[group('testing')] +tests: + go test -v -race -count=1 ./... + +# run specific unit test +[group('testing')] +[no-cd] +test unit: + go test -v -count=1 -race -run {{unit}} 2>/dev/null + +# apply go vet command on source tree +[group('lint')] +vet: + go vet ./... + +# apply golangci-lint linters on source tree +[group('lint')] +lint: vet + $GOBIN/golangci-lint run --config {{scripts}}/golangci.yaml + +# show host system information +[group('build')] +@sysinfo: + echo "{{os()/arch()}} {{num_cpus()}}c" + +# locally install build dependencies +[group('build')] +init: + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4 diff --git a/Makefile b/Makefile deleted file mode 100644 index 28d7863..0000000 --- a/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -SHELL = bash - -default: test - -.PHONY: test -test: - @echo "--> Running Tests ..." - @go test -v -race ./... - -vet: - @echo "--> Vet Go sources ..." - @go vet ./... diff --git a/go.mod b/go.mod index e5ac114..02e31b3 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/shoenig/go-m1cpu -go 1.20 +go 1.26 -require github.com/shoenig/test v1.7.0 +require github.com/shoenig/test v1.13.2 -require github.com/google/go-cmp v0.6.0 // indirect +require github.com/google/go-cmp v0.7.0 // indirect diff --git a/go.sum b/go.sum index a223e19..f8c868e 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/shoenig/test v1.7.0 h1:eWcHtTXa6QLnBvm0jgEabMRN/uJ4DMV3M8xUGgRkZmk= -github.com/shoenig/test v1.7.0/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/shoenig/test v1.13.2 h1:SaGxHxg7xkRuKuNtuFmHf0LgNGaAgcBT7HN4WHCKfqU= +github.com/shoenig/test v1.13.2/go.mod h1:MKmiRyEeuFl8y9PCoThaRDgYQZeWBhRQlH99poXz5LI=