diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 74efcb5..a67bd15 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,10 +1,10 @@ { "name": "Go", - "image": "golang:1.21.1", + "image": "golang:1.22.0", "containerUser": "root", "features": { - "ghcr.io/devcontainers/features/common-utils:1": {}, - "ghcr.io/devcontainers/features/go:1": {"version": "none", "golangciLintVersion": "1.54.2"} + "ghcr.io/devcontainers/features/common-utils:2": {}, + "ghcr.io/devcontainers/features/go:1": {"version": "none", "golangciLintVersion": "1.56.2"} }, "runArgs": [ "--cap-add=SYS_PTRACE", diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 11aeddd..f98258a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ # All files * @mia-platform/sig-cli # Actions must also be checked by security -.github/actions @mia-platform/sig-cli @mia-platform/sig-security +.github/workflows @mia-platform/sig-cli @mia-platform/sig-security diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 03e0009..6e87a0a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -22,3 +22,9 @@ updates: interval: daily time: "07:00" timezone: Europe/Rome + +# keep up to date devcontainers +- package-ecosystem: devcontainers + directory: "/" + schedule: + interval: monthly diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1fe4c0f..6b80605 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,9 +14,7 @@ on: - examples/** env: - GO_VERSION: 1.21.1 - GORELEASER_VERSION: v1.21.2 - GO_CACHE: true + GORELEASER_VERSION: v1.24.0 jobs: lint: name: Lint Code @@ -29,14 +27,14 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod cache: false - name: Set golangci-lint Cache Key id: create-sha run: | echo "GOLANGCILINT_SHA=$(cat ./tools/GOLANGCI_LINT_VERSION | sha256sum - | awk '{ print $1 }')" >> $GITHUB_ENV - name: Setup golangci-lint Cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 with: path: | ./tools/bin @@ -47,20 +45,13 @@ jobs: run: make ci-lint GOLANGCI_LINT_MODE="github-actions" test: - name: Testing on ${{ matrix.os }} #and kubernetes ${{ matrix.k8s_version}} + name: Testing on ${{ matrix.os }} strategy: matrix: os: - ubuntu-latest - macos-latest - # k8s_version: - # - "1.25" - # - "1.26" - # - "1.27" - # - "1.28" runs-on: ${{ matrix.os }} - # env: - # ENVTEST_K8S_VERSION: ${{matrix.k8s_version}} steps: - name: Checkout Repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -69,8 +60,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} - cache: true + go-version-file: go.mod - name: Run Test Coverage run: make ci @@ -89,8 +79,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} - cache: true + go-version-file: go.mod - name: Setup Goreleaser uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: @@ -114,8 +103,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} - cache: true + go-version-file: go.mod - name: Setup Goreleaser uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: @@ -130,7 +118,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} - name: Upload Binaries Artifacts - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: name: artifacts path: bin/ @@ -145,7 +133,7 @@ jobs: with: show-progress: false - name: Download Binaries - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + uses: actions/download-artifact@87c55149d96e628cc2ef7e6fc2aab372015aec85 # v4.1.3 with: name: artifacts path: bin/ @@ -167,6 +155,6 @@ jobs: run: make docker-setup-multiarch - name: Setup Buildx Context id: buildx - uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + uses: docker/setup-buildx-action@0d103c3126aa41d772a8362f6aa67afac040f80c # v3.1.0 - name: Build Latest Image run: make ci-docker BUILDX_CONTEXT=${{ steps.buildx.outputs.name }} diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 29d4948..20d10e8 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -15,9 +15,12 @@ on: schedule: - cron: 0 5 * * 1 # Run every monday at 5 UTC +env: + GORELEASER_VERSION: v1.24.0 + jobs: codeql: - runs-on: ubuntu-latest + runs-on: macos-latest permissions: security-events: write steps: @@ -25,11 +28,20 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: show-progress: false + - name: Setup Golang + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version-file: go.mod + - name: Setup Goreleaser + uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 + with: + version: ${{ env.GORELEASER_VERSION }} + install-only: true - name: Initialize CodeQL - uses: github/codeql-action/init@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2 + uses: github/codeql-action/init@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 with: languages: go - name: Run Build run: make build - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2 + uses: github/codeql-action/analyze@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 diff --git a/.github/workflows/dependency-review.yaml b/.github/workflows/dependency-review.yaml index 759e788..747670e 100644 --- a/.github/workflows/dependency-review.yaml +++ b/.github/workflows/dependency-review.yaml @@ -21,7 +21,7 @@ jobs: with: show-progress: false - name: Dependency Review - uses: actions/dependency-review-action@4901385134134e04cec5fbe5ddfe3b2c5bd5d976 # v4.0.0 + uses: actions/dependency-review-action@9129d7d40b8c12c1ed0f60400d00c92d437adcce # v4.1.3 with: fail-on-scope: runtime,development,unknown comment-summary-in-pr: on-failure diff --git a/.go-version b/.go-version index 2844977..57807d6 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.21.1 +1.22.0 diff --git a/.golangci.yaml b/.golangci.yaml index c8a6b30..31cbc99 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,5 +1,8 @@ run: - deadline: 10m + timeout: 10m + build-tags: + - conformance + - integration linters: enable: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index bafda6f..7b4c5f0 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -7,7 +7,6 @@ builds: {{- .Arch }}/ {{- with .Arm }}v{{ . }}/{{ end }} {{- .ProjectName }} - no_unique_dist_dir: true env: - CGO_ENABLED=0 diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 630c819..04f7511 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -17,5 +17,8 @@ MD029: MD033: allowed_elements: - center + - picture + - source + - img MD046: style: fenced diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1d09d14..80d338e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: language: system pass_filenames: false - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-case-conflict name: Check filename case conflicts @@ -30,7 +30,7 @@ repos: name: Trims trailing whitespace args: [--markdown-linebreak-ext=md] # add exception for markdown linebreaks - repo: https://github.com/gitleaks/gitleaks - rev: v8.18.0 + rev: v8.18.2 hooks: - id: gitleaks name: Protect and discover secrets using Gitleaks diff --git a/go.mod b/go.mod index f8cf50e..2d1ea26 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mia-platform/vab -go 1.21 +go 1.22.0 require ( github.com/dchest/uniuri v1.2.0 diff --git a/internal/e2e/e2e_suite_test.go b/internal/e2e/e2e_suite_test.go index 1a82e8e..7937807 100644 --- a/internal/e2e/e2e_suite_test.go +++ b/internal/e2e/e2e_suite_test.go @@ -20,8 +20,8 @@ package e2e_test import ( "testing" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo" //revive:disable-line:dot-imports + . "github.com/onsi/gomega" //revive:disable-line:dot-imports ) func TestE2e(t *testing.T) { diff --git a/internal/e2e/e2e_test.go b/internal/e2e/e2e_test.go index 878afda..5c7c54f 100644 --- a/internal/e2e/e2e_test.go +++ b/internal/e2e/e2e_test.go @@ -28,8 +28,8 @@ import ( initProj "github.com/mia-platform/vab/pkg/init" "github.com/mia-platform/vab/pkg/logger" "github.com/mia-platform/vab/pkg/sync" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo" //revive:disable-line:dot-imports + . "github.com/onsi/gomega" //revive:disable-line:dot-imports v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" diff --git a/internal/git/walk-hack_test.go b/internal/git/walk-hack_test.go index 62ccd74..32541a1 100644 --- a/internal/git/walk-hack_test.go +++ b/internal/git/walk-hack_test.go @@ -29,7 +29,7 @@ import ( "github.com/go-git/go-billy/v5" "github.com/go-git/go-billy/v5/memfs" - . "gopkg.in/check.v1" + . "gopkg.in/check.v1" //revive:disable-line:dot-imports ) type WalkSuite struct{} @@ -40,19 +40,19 @@ var _ = Suite(&WalkSuite{}) func (s *WalkSuite) TestWalkCanSkipTopDirectory(c *C) { filesystem := memfs.New() - c.Assert(Walk(filesystem, "/root/that/does/not/exist", func(path string, info os.FileInfo, err error) error { return filepath.SkipDir }), IsNil) + c.Assert(Walk(filesystem, "/root/that/does/not/exist", func(_ string, _ os.FileInfo, _ error) error { return filepath.SkipDir }), IsNil) } func (s *WalkSuite) TestWalkReturnsAnErrorWhenRootDoesNotExist(c *C) { filesystem := memfs.New() - c.Assert(Walk(filesystem, "/root/that/does/not/exist", func(path string, info os.FileInfo, err error) error { return err }), NotNil) + c.Assert(Walk(filesystem, "/root/that/does/not/exist", func(_ string, _ os.FileInfo, err error) error { return err }), NotNil) } func (s *WalkSuite) TestWalkOnPlainFile(c *C) { filesystem := memfs.New() createFile(c, filesystem, "./README.md") discoveredPaths := []string{} - c.Assert(Walk(filesystem, "./README.md", func(path string, info os.FileInfo, err error) error { + c.Assert(Walk(filesystem, "./README.md", func(path string, _ os.FileInfo, _ error) error { discoveredPaths = append(discoveredPaths, path) return nil }), IsNil) @@ -64,7 +64,7 @@ func (s *WalkSuite) TestWalkOnExistingFolder(c *C) { createFile(c, filesystem, "path/to/some/subfolder/that/contain/file") createFile(c, filesystem, "path/to/some/file") discoveredPaths := []string{} - c.Assert(Walk(filesystem, "path", func(path string, info os.FileInfo, err error) error { + c.Assert(Walk(filesystem, "path", func(path string, _ os.FileInfo, _ error) error { discoveredPaths = append(discoveredPaths, path) return nil }), IsNil) @@ -83,7 +83,7 @@ func (s *WalkSuite) TestWalkCanSkipFolder(c *C) { createFile(c, filesystem, "path/to/some/subfolder/that/contain/file") createFile(c, filesystem, "path/to/some/file") discoveredPaths := []string{} - c.Assert(Walk(filesystem, "path", func(path string, info os.FileInfo, err error) error { + c.Assert(Walk(filesystem, "path", func(path string, _ os.FileInfo, _ error) error { discoveredPaths = append(discoveredPaths, path) if path == "path/to/some/subfolder" { return filepath.SkipDir @@ -105,7 +105,7 @@ func (s *WalkSuite) TestWalkStopsOnError(c *C) { createFile(c, filesystem, "path/to/some/subfolder/that/contain/file") createFile(c, filesystem, "path/to/some/file") discoveredPaths := []string{} - c.Assert(Walk(filesystem, "path", func(path string, info os.FileInfo, err error) error { + c.Assert(Walk(filesystem, "path", func(path string, _ os.FileInfo, _ error) error { discoveredPaths = append(discoveredPaths, path) if path == "path/to/some/subfolder" { return errors.New("uncaught error") @@ -137,7 +137,7 @@ func (s *WalkSuite) TestWalkForwardsStatErrors(c *C) { createFile(c, filesystem, "path/to/some/subfolder/that/contain/file") createFile(c, filesystem, "path/to/some/file") discoveredPaths := []string{} - c.Assert(Walk(filesystem, "path", func(path string, info os.FileInfo, err error) error { + c.Assert(Walk(filesystem, "path", func(path string, _ os.FileInfo, err error) error { discoveredPaths = append(discoveredPaths, path) if path == "path/to/some/subfolder" { c.Assert(err, NotNil) diff --git a/tools/DEEPCOPY_GEN_VERSION b/tools/DEEPCOPY_GEN_VERSION index 46e8233..678c94d 100644 --- a/tools/DEEPCOPY_GEN_VERSION +++ b/tools/DEEPCOPY_GEN_VERSION @@ -1 +1 @@ -v0.28.2 +v0.29.2 diff --git a/tools/ENVTEST_K8S_VERSION b/tools/ENVTEST_K8S_VERSION index b0c101e..e0250ea 100644 --- a/tools/ENVTEST_K8S_VERSION +++ b/tools/ENVTEST_K8S_VERSION @@ -1 +1 @@ -1.27 +1.28 diff --git a/tools/GOLANGCI_LINT_VERSION b/tools/GOLANGCI_LINT_VERSION index 22e8470..fe1df05 100644 --- a/tools/GOLANGCI_LINT_VERSION +++ b/tools/GOLANGCI_LINT_VERSION @@ -1 +1 @@ -v1.54.2 +v1.56.2 diff --git a/tools/GORELEASER_VERSION b/tools/GORELEASER_VERSION index fd79581..de8c3cf 100644 --- a/tools/GORELEASER_VERSION +++ b/tools/GORELEASER_VERSION @@ -1 +1 @@ -v1.21.2 +v1.24.0 diff --git a/tools/make/build.mk b/tools/make/build.mk index daf141b..00a2b02 100644 --- a/tools/make/build.mk +++ b/tools/make/build.mk @@ -63,12 +63,6 @@ go/build/multiarch: .PHONY: build-deps build-deps: -$(GORELEASER_PATH): $(TOOLS_DIR)/GORELEASER_VERSION - $(eval GORELEASER_VERSION:= $(shell cat $<)) - mkdir -p $(TOOLS_BIN) - $(info Installing goreleaser $(GORELEASER_VERSION) bin in $(TOOLS_BIN)) - GOBIN=$(TOOLS_BIN) go install github.com/goreleaser/goreleaser@$(GORELEASER_VERSION) - build-deps: $(GORELEASER_PATH) build: build-deps @@ -80,3 +74,9 @@ endif .PHONY: build build: go/build/$(GOOS)/$(GOARCH)/$(GOARM) + +$(TOOLS_BIN)/goreleaser: $(TOOLS_DIR)/GORELEASER_VERSION + $(eval GORELEASER_VERSION:= $(shell cat $<)) + mkdir -p $(TOOLS_BIN) + $(info Installing goreleaser $(GORELEASER_VERSION) bin in $(TOOLS_BIN)) + GOBIN=$(TOOLS_BIN) go install github.com/goreleaser/goreleaser@$(GORELEASER_VERSION) diff --git a/tools/make/lint.mk b/tools/make/lint.mk index f137ebc..8501683 100644 --- a/tools/make/lint.mk +++ b/tools/make/lint.mk @@ -33,10 +33,10 @@ lint-deps: lint: golangci-lint golangci-lint: $(GOLANGCI_PATH) $(info Running golangci-lint with .golangci.yaml config file...) - $(GOLANGCI_PATH) run --out-format=$(GOLANGCI_LINT_MODE) --config=.golangci.yaml --build-tags=conformance,integration + $(GOLANGCI_PATH) run --out-format=$(GOLANGCI_LINT_MODE) --config=.golangci.yaml lint-deps: $(GOLANGCI_PATH) -$(GOLANGCI_PATH): $(TOOLS_DIR)/GOLANGCI_LINT_VERSION +$(TOOLS_BIN)/golangci-lint: $(TOOLS_DIR)/GOLANGCI_LINT_VERSION $(eval GOLANGCI_LINT_VERSION:= $(shell cat $<)) mkdir -p $(TOOLS_BIN) $(info Installing golangci-lint $(GOLANGCI_LINT_VERSION) bin in $(TOOLS_BIN)) @@ -47,7 +47,7 @@ lint: gomod-lint gomod-lint: $(info Running go mod tidy) # Always keep this version to latest -1 version of Go - go mod tidy -compat=1.18 + go mod tidy -compat=1.20 .PHONY: ci-lint ci-lint: lint diff --git a/tools/make/test.mk b/tools/make/test.mk index fd20f85..e7f4ca2 100644 --- a/tools/make/test.mk +++ b/tools/make/test.mk @@ -32,7 +32,7 @@ test/unit: .PHONY: test/integration test/integration: $(info Running integration tests...) - KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test $(GO_TEST_DEBUG_FLAG) -tags=integration -race ./... + go test $(GO_TEST_DEBUG_FLAG) -tags=integration -race ./... .PHONY: test/coverage test/coverage: @@ -42,13 +42,13 @@ test/coverage: .PHONY: test/integration/coverage test/integration/coverage: $(info Running ci tests with coverage on...) - KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test -tags=integration -race -coverprofile=coverage.txt -covermode=atomic ./... + go test -tags=integration -race -coverprofile=coverage.txt -covermode=atomic ./... .PHONY: test/conformance test/conformance/setup test/conformance/teardown test/conformance/setup: test/conformance: $(info Running conformance tests...) - go test -tags=conformance -race $(GO_TEST_DEBUG_FLAG) $(CONFORMANCE_TEST_PATH) + go test -count=1 -tags=conformance -race $(GO_TEST_DEBUG_FLAG) $(CONFORMANCE_TEST_PATH) test/conformance/teardown: test/show/coverage: