diff --git a/.circleci/config.yml b/.circleci/config.yml index 41a4100..cb13db2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,12 +1,39 @@ 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: @@ -14,7 +41,7 @@ executors: - 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 diff --git a/.golangci.yml b/.golangci.yml index 2a618c1..f801263 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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: diff --git a/.goreleaser.yml b/.goreleaser.yml index 1d0c483..2b05715 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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: diff --git a/client/build_context_test.go b/client/build_context_test.go index 6a644bb..9a169a4 100644 --- a/client/build_context_test.go +++ b/client/build_context_test.go @@ -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) } diff --git a/client/build_test.go b/client/build_test.go index 515cbdf..7216b10 100644 --- a/client/build_test.go +++ b/client/build_test.go @@ -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) } diff --git a/client/error_test.go b/client/error_test.go index 81b747a..c03fc7e 100644 --- a/client/error_test.go +++ b/client/error_test.go @@ -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) } diff --git a/client/output.go b/client/output.go index 4b1c965..94a49e8 100644 --- a/client/output.go +++ b/client/output.go @@ -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 diff --git a/client/status_test.go b/client/status_test.go index c6dee07..552ff25 100644 --- a/client/status_test.go +++ b/client/status_test.go @@ -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) } diff --git a/client/version_test.go b/client/version_test.go index d196ad6..d2cec5c 100644 --- a/client/version_test.go +++ b/client/version_test.go @@ -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) }