diff --git a/.buildkite/Dockerfile b/.buildkite/Dockerfile deleted file mode 100644 index d2ba209e..00000000 --- a/.buildkite/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM golang:1.26.1@sha256:c42e4d75186af6a44eb4159dcfac758ef1c05a7011a0052fe8a8df016d8e8fb9 - -COPY --from=goreleaser/goreleaser-pro:v2.14.3@sha256:086a121392cc9995517316ad6502a75c7b5a55d95a521938a556c7d3c352ec7e /usr/bin/goreleaser /usr/local/bin/goreleaser -COPY --from=golangci/golangci-lint:v2.11.3@sha256:e838e8ab68aaefe83e2408691510867ade9329c0e0b895a3fb35eb93d1c2a4ba /usr/bin/golangci-lint /usr/local/bin/golangci-lint -COPY --from=ghcr.io/ko-build/ko:fc0e4c0582f0801600929b5aaf6981aabdf47148 /ko-app/ko /usr/local/bin/ko diff --git a/.buildkite/docker-compose.yaml b/.buildkite/docker-compose.yaml deleted file mode 100644 index 7226559f..00000000 --- a/.buildkite/docker-compose.yaml +++ /dev/null @@ -1,21 +0,0 @@ -services: - golangci-lint: - image: golangci/golangci-lint:v2.11.3 - working_dir: /app - volumes: - - ..:/app - - ~/.cache/golangci-lint/v1.54.1:/root/.cache - goreleaser: - build: - context: . - environment: - - BUILDKITE_AGENT_JOB_API_SOCKET - - BUILDKITE_AGENT_JOB_API_TOKEN - - POSTHOG_API_KEY - - DOCKERHUB_USER - - DOCKERHUB_PASSWORD - working_dir: /go/src/github.com/buildkite/cli - volumes: - - ..:/go/src/github.com/buildkite/cli - - ${BUILDKITE_AGENT_JOB_API_SOCKET}:${BUILDKITE_AGENT_JOB_API_SOCKET} - - /var/run/docker.sock:/var/run/docker.sock diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command new file mode 100755 index 00000000..79a6dc20 --- /dev/null +++ b/.buildkite/hooks/pre-command @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +checkout_path="${BUILDKITE_BUILD_CHECKOUT_PATH:-$(pwd)}" +cache_root="${checkout_path}/.buildkite/cache-volume" + +mkdir -p \ + "${cache_root}/go/build" \ + "${cache_root}/go/pkg/mod" \ + "${cache_root}/golangci-lint" + +export GOCACHE="${cache_root}/go/build" +export GOMODCACHE="${cache_root}/go/pkg/mod" +export GOLANGCI_LINT_CACHE="${cache_root}/golangci-lint" + +# CI pins tool versions in mise.toml/mise.lock, but the go: backend used for +# go-cover-treemap does not support locked-mode URLs. Skip the GitHub API-backed +# attestation/SLSA checks instead so reruns do not fail on unauthenticated rate +# limits inside the mise plugin. +export MISE_AQUA_GITHUB_ATTESTATIONS=false +export MISE_AQUA_SLSA=false +export MISE_GITHUB_ATTESTATIONS=false +export MISE_GITHUB_GITHUB_ATTESTATIONS=false +export MISE_GITHUB_SLSA=false +export MISE_SLSA=false diff --git a/.buildkite/pipeline.release.yml b/.buildkite/pipeline.release.yml index 3e958fd3..f2c8de86 100644 --- a/.buildkite/pipeline.release.yml +++ b/.buildkite/pipeline.release.yml @@ -1,6 +1,11 @@ agents: queue: hosted +x-mise-plugin: &mise_plugin + buildkite-plugins/mise#v1.1.1: ~ + +cache: ".buildkite/cache-volume" + steps: - label: ":terminal: build ({{matrix}})" matrix: @@ -12,23 +17,9 @@ steps: secrets: - POSTHOG_API_KEY - OAUTH_CLIENT_ID + command: 'GOOS="{{matrix}}" .buildkite/release.sh release --clean --split' plugins: - - docker-compose#v5.12.1: - command: - - .buildkite/release.sh - - release - - --clean - - --split - config: .buildkite/docker-compose.yaml - entrypoint: /bin/sh - env: - - GOOS={{matrix}} - - POSTHOG_API_KEY - - OAUTH_CLIENT_ID - mount-buildkite-agent: true - run: goreleaser - shell: false - tty: true + - *mise_plugin - wait @@ -36,20 +27,11 @@ steps: matrix: - "deb" - "rpm" + command: '.buildkite/upload-packages.sh "{{matrix}}"' plugins: - artifacts#v1.9.4: download: - dist/linux/* - - docker-compose#v5.12.1: - command: - - .buildkite/upload-packages.sh - - "{{matrix}}" - config: .buildkite/docker-compose.yaml - entrypoint: /bin/sh - mount-buildkite-agent: true - run: goreleaser - shell: false - tty: true - label: ":rocket: :github: release" artifact_paths: @@ -74,20 +56,5 @@ steps: - artifacts#v1.9.4: download: - dist/**/* - - docker-compose#v5.12.1: - command: - - .buildkite/release.sh - - continue - - --merge - config: .buildkite/docker-compose.yaml - entrypoint: /bin/sh - env: - - GITHUB_TOKEN - - DOCKERHUB_USER - - DOCKERHUB_PASSWORD - - POSTHOG_API_KEY - - OAUTH_CLIENT_ID - mount-buildkite-agent: true - run: goreleaser - shell: false - tty: true + - *mise_plugin + command: '.buildkite/release.sh continue --merge' diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index cd74397c..3dd34f6f 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,28 +1,30 @@ agents: queue: hosted +x-mise-plugin: &mise_plugin + buildkite-plugins/mise#v1.1.1: ~ + +cache: ".buildkite/cache-volume" + steps: - name: ":golangci-lint: lint" - command: golangci-lint run --verbose --timeout 3m + command: 'golangci-lint run --verbose --timeout 3m' plugins: - - docker-compose#v5.12.1: - config: .buildkite/docker-compose.yaml - run: golangci-lint - tty: true + - *mise_plugin - name: ":go: test" + key: test artifact_paths: - cover-tree.svg commands: + # Hosted agents inject org/token env that breaks config-precedence tests, + # so clear those variables in the command shell right before go test. + - unset BUILDKITE_ORGANIZATION_SLUG BUILDKITE_API_TOKEN - go test -coverprofile cover.out ./... - - go run github.com/nikolaydubina/go-cover-treemap@latest -coverprofile cover.out > cover-tree.svg + - go-cover-treemap -coverprofile cover.out > cover-tree.svg - echo '
Coverage tree mapTest coverage tree map
' | buildkite-agent annotate --style "info" plugins: - - docker-compose#v5.12.1: - config: .buildkite/docker-compose.yaml - run: golangci-lint - tty: true - mount-buildkite-agent: true + - *mise_plugin - wait @@ -36,24 +38,9 @@ steps: secrets: - POSTHOG_API_KEY - OAUTH_CLIENT_ID + command: 'GOOS="{{matrix}}" .buildkite/release.sh release --clean --snapshot --split' plugins: - - docker-compose#v5.12.1: - command: - - .buildkite/release.sh - - release - - --clean - - --snapshot - - --split - config: .buildkite/docker-compose.yaml - entrypoint: /bin/sh - env: - - GOOS={{matrix}} - - POSTHOG_API_KEY - - OAUTH_CLIENT_ID - mount-buildkite-agent: true - run: goreleaser - shell: false - tty: true + - *mise_plugin - input: ":package: Create a release?" prompt: "Select the release type" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f3eb2b7..9d1cbec8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,6 @@ To get started with contributing, please follow these steps: * Lint with `mise run lint`. * Make sure the tests pass with `mise run test`. * Run `mise run generate` after GraphQL changes. If you need to refresh `schema.graphql`, set `BUILDKITE_GRAPHQL_TOKEN` first. - * If you prefer the containerized lint setup, `docker-compose -f .buildkite/docker-compose.yaml run golangci-lint golangci-lint run` still works. 7. Commit your changes and push them to your forked repository. 8. Submit a pull request with a detailed description of your changes and links to any relevant issues. diff --git a/README.md b/README.md index 3088d05f..1a73fd2a 100644 --- a/README.md +++ b/README.md @@ -43,5 +43,6 @@ mise run generate go run main.go --help ``` -`mise.toml` pins Go `1.26.1` to match the current release build image. The -module itself remains compatible with Go `1.25.0` as declared in `go.mod`. +`mise.toml` pins the shared toolchain, including the release helpers used in +CI. The module itself remains compatible with Go `1.25.0` as declared in +`go.mod`. diff --git a/mise.lock b/mise.lock new file mode 100644 index 00000000..05f1cc17 --- /dev/null +++ b/mise.lock @@ -0,0 +1,39 @@ +[[tools."aqua:mvdan/gofumpt"]] +version = "0.9.2" +backend = "aqua:mvdan/gofumpt" +"platforms.linux-x64" = { checksum = "sha256:72cf61b12fef91eab6df6db4a4284f30616b5ead330112e28a1fa1cb15e57339", url = "https://github.com/mvdan/gofumpt/releases/download/v0.9.2/gofumpt_v0.9.2_linux_amd64"} +"platforms.macos-arm64" = { checksum = "sha256:c241fb742599a6cb0563d7377f59def65d451b23dd718dbc6ddf4ab5e695e8f1", url = "https://github.com/mvdan/gofumpt/releases/download/v0.9.2/gofumpt_v0.9.2_darwin_arm64"} + +[[tools."github:goreleaser/goreleaser-pro"]] +version = "2.14.3" +backend = "github:goreleaser/goreleaser-pro" +"platforms.linux-x64" = { checksum = "sha256:a6a7ba86950db98b1e7d18ac189bf43237645f9ef5ca89a66a56308c45f29b73", url = "https://github.com/goreleaser/goreleaser-pro/releases/download/v2.14.3/goreleaser-pro_Linux_x86_64.tar.gz", url_api = "https://api.github.com/repos/goreleaser/goreleaser-pro/releases/assets/370146679"} +"platforms.macos-arm64" = { checksum = "sha256:c616cb4dd73c1d49f41dd23160a7b5a8092e45e40735f98fc02173611a8dfcbb", url = "https://github.com/goreleaser/goreleaser-pro/releases/download/v2.14.3/goreleaser-pro_Darwin_arm64.tar.gz", url_api = "https://api.github.com/repos/goreleaser/goreleaser-pro/releases/assets/370146635"} + +[[tools.go]] +version = "1.26.1" +backend = "core:go" +"platforms.linux-x64" = { checksum = "sha256:031f088e5d955bab8657ede27ad4e3bc5b7c1ba281f05f245bcc304f327c987a", url = "https://dl.google.com/go/go1.26.1.linux-amd64.tar.gz"} +"platforms.macos-arm64" = { checksum = "sha256:353df43a7811ce284c8938b5f3c7df40b7bfb6f56cb165b150bc40b5e2dd541f", url = "https://dl.google.com/go/go1.26.1.darwin-arm64.tar.gz"} + +[[tools."go:github.com/nikolaydubina/go-cover-treemap"]] +version = "1.5.1" +backend = "go:github.com/nikolaydubina/go-cover-treemap" + +[[tools.golangci-lint]] +version = "2.11.3" +backend = "aqua:golangci/golangci-lint" +"platforms.linux-x64" = { checksum = "sha256:87bb8cddbcc825d5778b64e8a91b46c0526b247f4e2f2904dea74ec7450475d1", url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-linux-amd64.tar.gz"} +"platforms.macos-arm64" = { checksum = "sha256:30ee39979c516b9d1adca289a3f93429d130c4c0fda5e57d637850894221f6cc", url = "https://github.com/golangci/golangci-lint/releases/download/v2.11.3/golangci-lint-2.11.3-darwin-arm64.tar.gz"} + +[[tools.ko]] +version = "0.18.1" +backend = "aqua:ko-build/ko" +"platforms.linux-x64" = { checksum = "sha256:048ab11818089a43b7b74bc554494a79a3fd0d9822c061142e5cd3cf8b30cb27", url = "https://github.com/ko-build/ko/releases/download/v0.18.1/ko_0.18.1_Linux_x86_64.tar.gz"} +"platforms.macos-arm64" = { checksum = "sha256:752a639e0fbc013a35a43974b5ed87e7008bc2aee4952dfd2cc19f0013205492", url = "https://github.com/ko-build/ko/releases/download/v0.18.1/ko_0.18.1_Darwin_arm64.tar.gz"} + +[[tools.lefthook]] +version = "2.1.4" +backend = "aqua:evilmartians/lefthook" +"platforms.linux-x64" = { checksum = "sha256:991a11fb98c853dbecf7de3fe7f4b5648872f4279ac2b50ef3302f0a058c99bd", url = "https://github.com/evilmartians/lefthook/releases/download/v2.1.4/lefthook_2.1.4_Linux_x86_64.gz"} +"platforms.macos-arm64" = { checksum = "sha256:41fa330710344f66683edb2ee19dfd531e9469bebf7c89ef8e201263565c12ad", url = "https://github.com/evilmartians/lefthook/releases/download/v2.1.4/lefthook_2.1.4_MacOS_arm64.gz"} diff --git a/mise.toml b/mise.toml index b626bf3c..3b8169eb 100644 --- a/mise.toml +++ b/mise.toml @@ -1,11 +1,17 @@ # Pinned local toolchain for contributors. The Go version matches the -# repository's current release build image; the module minimum stays in go.mod. +# CI and release toolchain; the module minimum stays in go.mod. +[settings] +experimental = true +lockfile = true + [tools] go = "1.26.1" golangci-lint = "2.11.3" lefthook = "2.1.4" "aqua:mvdan/gofumpt" = "0.9.2" -"aqua:goreleaser/goreleaser" = "2.14.3" +"go:github.com/nikolaydubina/go-cover-treemap" = "1.5.1" +"github:goreleaser/goreleaser-pro" = "2.14.3" +ko = "0.18.1" [tasks.format] description = "Format Go files with gofumpt"