Skip to content

Commit

Permalink
feat: update to latest template
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiola committed Mar 1, 2024
1 parent 9030133 commit 4d2e666
Show file tree
Hide file tree
Showing 22 changed files with 75 additions and 64 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 10 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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/
Expand All @@ -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/
Expand All @@ -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 }}
18 changes: 15 additions & 3 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,33 @@ 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:
- name: Checkout repository
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
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.1
1.22.0
5 changes: 4 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
run:
deadline: 10m
timeout: 10m
build-tags:
- conformance
- integration

linters:
enable:
Expand Down
1 change: 0 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ builds:
{{- .Arch }}/
{{- with .Arm }}v{{ . }}/{{ end }}
{{- .ProjectName }}
no_unique_dist_dir: true
env:
- CGO_ENABLED=0
Expand Down
3 changes: 3 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ MD029:
MD033:
allowed_elements:
- center
- picture
- source
- img
MD046:
style: fenced
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
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/mia-platform/vab

go 1.21
go 1.22.0

require (
github.com/dchest/uniuri v1.2.0
Expand Down
4 changes: 2 additions & 2 deletions internal/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions internal/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions internal/git/walk-hack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/DEEPCOPY_GEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.28.2
v0.29.2
2 changes: 1 addition & 1 deletion tools/ENVTEST_K8S_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.27
1.28
2 changes: 1 addition & 1 deletion tools/GOLANGCI_LINT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.54.2
v1.56.2
2 changes: 1 addition & 1 deletion tools/GORELEASER_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.21.2
v1.24.0
12 changes: 6 additions & 6 deletions tools/make/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
6 changes: 3 additions & 3 deletions tools/make/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
Loading

0 comments on commit 4d2e666

Please sign in to comment.