Skip to content

Commit

Permalink
feat: upgrade go to 1.20 to use coverage profiling for integration te…
Browse files Browse the repository at this point in the history
…sts. (#833)

Signed-off-by: Binbin Li <[email protected]>
  • Loading branch information
binbin-li authored May 19, 2023
1 parent 86a6789 commit 6ac7461
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: setup go environment
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: "1.19"
go-version: "1.20"
- name: Run tidy
run: go mod tidy
- name: Build CLI
Expand All @@ -47,7 +47,7 @@ jobs:
- name: setup go environment
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: "1.19"
go-version: "1.20"
- name: Run tidy
run: go mod tidy
- name: Build CLI
Expand All @@ -57,7 +57,9 @@ jobs:
- name: Test CLI
run: |
make install ratify-config install-bats
make test-e2e-cli
make test-e2e-cli GOCOVERDIR=${GITHUB_WORKSPACE}/test/e2e/.cover
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3

build_test_cli_oci_1_0:
name: "Build and run tests for CLI OCI 1.0"
Expand All @@ -70,7 +72,7 @@ jobs:
- name: setup go environment
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: "1.19"
go-version: "1.20"
- name: Run tidy
run: go mod tidy
- name: Build CLI
Expand All @@ -80,7 +82,9 @@ jobs:
- name: Test CLI
run: |
make install ratify-config install-bats
make test-e2e-cli IS_OCI_1_1=false LOCAL_REGISTRY_IMAGE=registry
make test-e2e-cli IS_OCI_1_1=false LOCAL_REGISTRY_IMAGE=registry GOCOVERDIR=${GITHUB_WORKSPACE}/test/e2e/.cover
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3

build_test_e2e:
name: "Build and run e2e Test"
Expand All @@ -95,10 +99,10 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.19
go-version: 1.20

- name: Bootstrap e2e
run: |
Expand Down Expand Up @@ -146,10 +150,10 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.19
go-version: 1.20

- name: Az CLI login
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: setup go environment
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: "1.19"
go-version: "1.20"
- name: Initialize CodeQL
uses: github/codeql-action/init@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # tag=v2.3.3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: 1.19
go-version: 1.20

- name: Goreleaser
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local_oras_cache/
.idea
__debug_bin
coverage.txt
test/e2e/coverage.txt

# generated directories
certs/
Expand Down
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ build: build-cli build-plugins

.PHONY: build-cli
build-cli: fmt vet
go build --ldflags="$(LDFLAGS)" \
go build --ldflags="$(LDFLAGS)" -cover \
-coverpkg=github.com/deislabs/ratify/pkg/...,github.com/deislabs/ratify/config/...,github.com/deislabs/ratify/cmd/... \
-o ./bin/${BINARY_NAME} ./cmd/${BINARY_NAME}

.PHONY: build-plugins
build-plugins:
go build -o ./bin/plugins/ ./plugins/verifier/cosign
go build -o ./bin/plugins/ ./plugins/verifier/licensechecker
go build -o ./bin/plugins/ ./plugins/verifier/sample
go build -o ./bin/plugins/ ./plugins/verifier/sbom
go build -o ./bin/plugins/ ./plugins/verifier/schemavalidator
go build -cover -coverpkg=github.com/deislabs/ratify/plugins/verifier/cosign/... -o ./bin/plugins/ ./plugins/verifier/cosign
go build -cover -coverpkg=github.com/deislabs/ratify/plugins/verifier/licensechecker/... -o ./bin/plugins/ ./plugins/verifier/licensechecker
go build -cover -coverpkg=github.com/deislabs/ratify/plugins/verifier/sample/... -o ./bin/plugins/ ./plugins/verifier/sample
go build -cover -coverpkg=github.com/deislabs/ratify/plugins/verifier/sbom/... -o ./bin/plugins/ ./plugins/verifier/sbom
go build -cover -coverpkg=github.com/deislabs/ratify/plugins/verifier/schemavalidator/... -o ./bin/plugins/ ./plugins/verifier/schemavalidator

.PHONY: install
install:
Expand Down Expand Up @@ -123,9 +124,11 @@ test-e2e:
bats -t ${BATS_TESTS_FILE}

.PHONY: test-e2e-cli

test-e2e-cli: e2e-dependencies e2e-create-local-registry e2e-notaryv2-setup e2e-notation-leaf-cert-setup e2e-cosign-setup e2e-licensechecker-setup e2e-sbom-setup e2e-schemavalidator-setup
rm ${GOCOVERDIR} -rf
mkdir ${GOCOVERDIR} -p
IS_OCI_1_1=${IS_OCI_1_1} RATIFY_DIR=${INSTALL_DIR} TEST_REGISTRY=${TEST_REGISTRY} ${GITHUB_WORKSPACE}/bin/bats -t ${BATS_CLI_TESTS_FILE}
go tool covdata textfmt -i=${GOCOVERDIR} -o test/e2e/coverage.txt

.PHONY: generate-certs
generate-certs:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/deislabs/ratify

go 1.19
go 1.20

// Accidentally published prior to 1.0.0 release
retract v1.1.0-alpha.1
Expand Down
2 changes: 1 addition & 1 deletion httpserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BUILDPLATFORM="linux/amd64"
ARG BUILDERIMAGE="golang:1.19"
ARG BUILDERIMAGE="golang:1.20"
ARG BASEIMAGE="gcr.io/distroless/static:nonroot"

FROM --platform=$BUILDPLATFORM $BUILDERIMAGE as builder
Expand Down

0 comments on commit 6ac7461

Please sign in to comment.