From 34e5a3ecbd2be501bc1b60d2e082385fcddee9ed Mon Sep 17 00:00:00 2001 From: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> Date: Fri, 17 May 2024 03:04:01 +0530 Subject: [PATCH 1/2] Bump go, golangci-lint and github actions Signed-off-by: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> --- .github/workflows/golangci-lint.yml | 10 +++++----- .github/workflows/release.yml | 6 +++--- .github/workflows/test-gh.yml | 16 +++++++--------- .github/workflows/trivy-scan.yml | 3 ++- go.mod | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 19ebb16c..ecb71337 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -13,15 +13,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: 1.22.2 - - uses: actions/checkout@v2 + go-version: '1.22' + - uses: actions/checkout@v4 with: fetch-depth: '0' - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: - version: v1.54 + version: v1.58 args: -v diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3fb9386..2bf50f77 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,13 +13,13 @@ jobs: id-token: write steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: 1.22.2 + go-version: '1.22' - name: Set up Cosign uses: sigstore/cosign-installer@v3 - name: Retrieve version diff --git a/.github/workflows/test-gh.yml b/.github/workflows/test-gh.yml index ef52c81f..6400452a 100644 --- a/.github/workflows/test-gh.yml +++ b/.github/workflows/test-gh.yml @@ -11,19 +11,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.x - uses: actions/setup-go@v1 + uses: actions/setup-go@v5 with: - go-version: 1.22.2 + go-version: '1.22' - name: Check out code into the Go module directory - uses: actions/checkout@v1 + uses: actions/checkout@v4 with: path: src/github.com/${{ github.repository }} + fetch-depth: 0 - name: Run Tests env: VENDIR_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -e -x - export GOPATH=$(echo `pwd`/../../../../) + export GOPATH=$(pwd) # Delete default installed helm sudo rm `which helm` @@ -31,11 +32,6 @@ jobs: mkdir -p /tmp/bin export PATH=/tmp/bin:$PATH - # imgpkg - wget -O- https://github.com/k14s/imgpkg/releases/download/v0.7.0/imgpkg-linux-amd64 > /tmp/bin/imgpkg && \ - echo "bb90881c2c03cad4d50b2f0881d1330d341a37bb55bd8fff50bf228f7cfcf3d2 /tmp/bin/imgpkg" | shasum -c - && \ - chmod +x /tmp/bin/imgpkg - # helm 2 wget -O- https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz > /tmp/helm2.tgz && \ echo "f3bec3c7c55f6a9eb9e6586b8c503f370af92fe987fcbf741f37707606d70296 /tmp/helm2.tgz" | shasum -c - && \ @@ -48,6 +44,8 @@ jobs: mkdir /tmp/helm3-unpacked && tar -C /tmp/helm3-unpacked -xzvf /tmp/helm3.tgz && \ mv /tmp/helm3-unpacked/linux-amd64/helm /tmp/bin/helm3 + cd "src/github.com/${{ github.repository }}" + export VENDIR_E2E_HELM2_BINARY=helm2 export VENDIR_E2E_HELM3_BINARY=helm3 diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index 73674847..fd5e6b5f 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -1,6 +1,7 @@ name: Trivy CVE Dependency Scanner on: + workflow_dispatch: schedule: - cron: '0 0 * * *' @@ -10,7 +11,7 @@ jobs: with: repo: carvel-dev/vendir tool: vendir - goVersion: 1.22.2 + goVersion: '1.22' secrets: githubToken: ${{ secrets.GITHUB_TOKEN }} slackWebhookURL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/go.mod b/go.mod index e11935c1..2fde3909 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module carvel.dev/vendir -go 1.22 +go 1.22.3 require ( carvel.dev/imgpkg v0.42.0 From 183d6f1dbc8c2a217b27de117b81e88170851c26 Mon Sep 17 00:00:00 2001 From: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> Date: Fri, 17 May 2024 03:08:41 +0530 Subject: [PATCH 2/2] Fix linter issues Signed-off-by: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> --- .golangci.yml | 5 +++++ pkg/vendir/directory/staging_dir.go | 2 +- pkg/vendir/directory/symlink.go | 2 +- test/e2e/concurrent_processes_test.go | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index bac4ae04..8e285001 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,6 +14,11 @@ linters-settings: regexp: copyright-year: 20[0-9][0-9] template-path: code-header-template.txt + revive: + enable-all: true + rules: + - name: dot-imports + disabled: true issues: max-issues-per-linter: 0 max-same-issues: 0 diff --git a/pkg/vendir/directory/staging_dir.go b/pkg/vendir/directory/staging_dir.go index fbae9777..d223f1c0 100644 --- a/pkg/vendir/directory/staging_dir.go +++ b/pkg/vendir/directory/staging_dir.go @@ -77,7 +77,7 @@ func (d StagingDir) CopyExistingFiles(rootDir string, stagingPath string, ignore // Consider WalkDir in the future for efficiency (Go 1.16) // Walk root path above to determine files that can be ignored - err := filepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(rootPath, func(path string, _ os.FileInfo, err error) error { if err != nil { return err } diff --git a/pkg/vendir/directory/symlink.go b/pkg/vendir/directory/symlink.go index f101cd82..f899805b 100644 --- a/pkg/vendir/directory/symlink.go +++ b/pkg/vendir/directory/symlink.go @@ -18,7 +18,7 @@ func ValidateSymlinks(path string) error { return err } rootSegments := strings.Split(absRoot, string(os.PathSeparator)) - return filepath.WalkDir(path, func(path string, info fs.DirEntry, err error) error { + return filepath.WalkDir(path, func(path string, info fs.DirEntry, _ error) error { if info.Type()&os.ModeSymlink == os.ModeSymlink { resolvedPath, err := filepath.EvalSymlinks(path) if err != nil { diff --git a/test/e2e/concurrent_processes_test.go b/test/e2e/concurrent_processes_test.go index 3ceaa858..c5d96f66 100644 --- a/test/e2e/concurrent_processes_test.go +++ b/test/e2e/concurrent_processes_test.go @@ -39,7 +39,7 @@ directories: wg := sync.WaitGroup{} for i := 0; i < processes; i++ { wg.Add(1) - go func(n int, t *testing.T, wg *sync.WaitGroup) { + go func(n int, _ *testing.T, wg *sync.WaitGroup) { defer wg.Done() // RunWithOpts invokes t.Fatal on error vendir.RunWithOpts(