Skip to content

CI workflow improvements #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 69 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
version: 2.1

orbs:
codecov: codecov/codecov@3
codecov: codecov/codecov@5

parameters:
cosign-version:
type: string
default: '2.5.0'
default: "2.5.2"

commands:
install-docker:
steps:
- run:
name: Install Docker
command: curl -sL https://get.docker.com | bash
install-binfmt:
steps:
- run:
name: Install Cross-Platform Emulators
command: docker run --privileged --rm tonistiigi/binfmt --install all
install-syft:
steps:
- run:
name: Install syft
command: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
install-cosign:
steps:
- run:
name: Install cosign
command: |
COSIGN_VERSION="v<< pipeline.parameters.cosign-version >>"
wget -q "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign-linux-amd64"
wget -q -O - "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign_checksums.txt" | grep -w cosign-linux-amd64 | sha256sum -c
install cosign-linux-amd64 /usr/local/bin/cosign
rm cosign-linux-amd64

executors:
node:
docker:
- image: node:22-slim
golangci-lint:
docker:
- image: golangci/golangci-lint:v2.1
- image: golangci/golangci-lint:v2.2
golang-previous:
docker:
- image: golang:1.23
@@ -60,6 +87,16 @@ jobs:
executor: << parameters.e >>
steps:
- checkout
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: Download Go modules
command: go mod download
- save_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- /go/pkg/mod
- run:
name: Build Source
command: go build ./...
@@ -75,28 +112,27 @@ jobs:
name: Run Unit Tests
command: go test -coverprofile cover.out -race ./...
- codecov/upload:
file: cover.out
files: cover.out

release-test:
executor: golang-latest
steps:
- checkout
- setup_remote_docker
- run:
name: Install Docker
command: curl -sL https://get.docker.com | bash
- run:
name: Install Cross-Platform Emulators
command: docker run --privileged --rm tonistiigi/binfmt --install all
- run:
name: Install syft
command: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
- run:
name: Install cosign
command: |
COSIGN_VERSION="v<< pipeline.parameters.cosign-version >>"
wget -q "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign-linux-amd64"
wget -q -O - "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign_checksums.txt" | grep -w cosign-linux-amd64 | sha256sum -c
- install-docker
- install-binfmt
- install-syft
- install-cosign
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: Download Go modules
command: go mod download
- save_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- /go/pkg/mod
- run:
name: Test Release
command: curl -sfL https://goreleaser.com/static/run | DISTRIBUTION=oss bash -s -- release --snapshot --skip publish
@@ -111,29 +147,26 @@ jobs:
command: |
apt-get update
apt-get install -y awscli
- run:
name: Install Docker
command: curl -sL https://get.docker.com | bash
- run:
name: Install Cross-Platform Emulators
command: docker run --privileged --rm tonistiigi/binfmt --install all
- install-docker
- install-binfmt
- run:
name: Authenticate with DockerHub
command: echo "${DOCKER_PASSWORD}" | docker login docker.io -u "${DOCKER_USERNAME}" --password-stdin
- run:
name: Install syft
command: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
- install-syft
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: Download Go modules
command: go mod download
- save_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- /go/pkg/mod
- run:
name: Publish Release
command: curl -sfL https://goreleaser.com/static/run | DISTRIBUTION=oss bash -s -- release
- run:
name: Install cosign
command: |
COSIGN_VERSION="v<< pipeline.parameters.cosign-version >>"
wget -q "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign-linux-amd64"
wget -q -O - "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign_checksums.txt" | grep -w cosign-linux-amd64 | sha256sum -c
install cosign-linux-amd64 /usr/local/bin/cosign
rm cosign-linux-amd64
- install-cosign
- run:
name: Attach attestations to image
command: |
@@ -147,8 +180,6 @@ jobs:
done

workflows:
version: 2

build-and-test:
jobs:
- lint-markdown
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -33,7 +33,12 @@ linters:
- unparam
- unused
- usetesting
- wsl
- wsl_v5
settings:
wsl_v5:
allow-first-in-block: true
allow-whole-block: false
branch-max-lines: 2
exclusions:
generated: lax
presets:
11 changes: 4 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -6,9 +6,6 @@ release:
changelog:
use: github-native

env:
- DOCKER_CLI_EXPERIMENTAL=enabled

gomod:
proxy: true
env:
@@ -63,16 +60,16 @@ builds:

archives:
- id: darwin-archives
builds:
ids:
- darwin-builds

- id: linux-archives
builds:
ids:
- linux-builds

- id: windows-archives
format: zip
builds:
formats: ['zip']
ids:
- windows-builds

dockers:
2 changes: 0 additions & 2 deletions client/build_context_test.go
Original file line number Diff line number Diff line change
@@ -196,7 +196,6 @@ func TestClient_UploadBuildContext(t *testing.T) {
}

digest, err := c.UploadBuildContext(context.Background(), tt.paths, optUploadBuildContextFS(fsys))

if got, want := err, tt.wantErr; !errors.Is(got, want) {
t.Errorf("got error %v, want %v", got, want)
}
@@ -271,7 +270,6 @@ func TestClient_DeleteBuildContext(t *testing.T) {
}

err = c.DeleteBuildContext(context.Background(), tt.digest)

if got, want := err, tt.wantErr; !errors.Is(got, want) {
t.Errorf("got error %v, want %v", got, want)
}
1 change: 0 additions & 1 deletion client/build_test.go
Original file line number Diff line number Diff line change
@@ -54,7 +54,6 @@ func TestSubmit(t *testing.T) {
bi, err := c.Submit(tt.ctx, strings.NewReader(""),
OptBuildLibraryRef(tt.libraryRef),
)

if got, want := err, tt.wantErr; !errors.Is(got, want) {
t.Fatalf("got error %v, want %v", got, want)
}
1 change: 0 additions & 1 deletion client/error_test.go
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ func TestHTTPError(t *testing.T) {
Code: tt.code,
err: tt.err,
}

if got, want := err.Code, tt.code; got != want {
t.Errorf("got code %v, want %v", got, want)
}
1 change: 1 addition & 0 deletions client/output.go
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ func (c *Client) GetOutput(ctx context.Context, buildID string, w io.Writer) err

go func() {
defer close(errChan)

errChan <- func() error {
for {
// Read from websocket
1 change: 0 additions & 1 deletion client/status_test.go
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@ func TestStatus(t *testing.T) {

// Call the handler
bi, err := c.GetStatus(tt.ctx, id)

if got, want := err, tt.wantErr; !errors.Is(got, want) {
t.Fatalf("got error %v, want %v", got, want)
}
1 change: 0 additions & 1 deletion client/version_test.go
Original file line number Diff line number Diff line change
@@ -114,7 +114,6 @@ func TestClient_GetVersion(t *testing.T) {
}

v, err := c.GetVersion(tt.ctx)

if got, want := err, tt.wantErr; !errors.Is(got, want) {
t.Fatalf("got error %v, want %v", got, want)
}