From 85c9b10d1f98fac75cb6655f3c643812291db836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Suszy=C5=84ski?= Date: Mon, 25 Mar 2024 14:54:22 +0100 Subject: [PATCH] Use knative/client-pkg#164 --- .github/workflows/lints.yml | 18 ++++++++++++------ .github/workflows/security.yml | 2 +- .github/workflows/test.yml | 4 ++-- go.mod | 4 ++-- go.sum | 8 ++++---- tests/example/.golangci.yml | 9 --------- tests/project_build_test.go | 30 +++++++++++++++++++++++------- 7 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml index 9daa14e..2fca6cb 100644 --- a/.github/workflows/lints.yml +++ b/.github/workflows/lints.yml @@ -6,14 +6,21 @@ on: branches: - master pull_request: + +env: + FORCE_COLOR: true + jobs: golangci: name: Golangci runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + cache: false + - uses: golangci/golangci-lint-action@v4 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.55.2 @@ -21,9 +28,8 @@ jobs: name: EditorConfig runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: ECLint - uses: snow-actions/eclint@v1.0.1 + - uses: actions/checkout@v4 + - uses: snow-actions/eclint@v1.0.1 with: args: check diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 0c724e7..e86d5c3 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Run Snyk to check for vulnerabilities uses: snyk/actions/golang@master diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a90669..4fd329d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,13 +23,13 @@ jobs: steps: - name: Set up Go ${{ matrix.go-version }} - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} id: go - name: Check out code into the Go module directory - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Test unit run: go run gotest.tools/gotestsum@latest diff --git a/go.mod b/go.mod index 96d0de9..eba0586 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/blang/semver/v4 v4.0.0 - github.com/cardil/ghet v0.0.1-0.20240322174403-1901c4fe21ac + github.com/cardil/ghet v0.0.1-0.20240326133720-fccab8f3066e github.com/fatih/color v1.16.0 github.com/google/go-containerregistry v0.19.1 github.com/google/ko v0.15.2 @@ -193,7 +193,7 @@ require ( k8s.io/apimachinery v0.29.3 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/utils v0.0.0-20240310230437-4693a0247e57 // indirect - knative.dev/client-pkg v0.0.0-20240322171749-cf1573f93631 // indirect + knative.dev/client-pkg v0.0.0-20240326133606-ca64d2dc74eb // indirect knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kind v0.22.0 // indirect diff --git a/go.sum b/go.sum index a0406d0..bf08abc 100644 --- a/go.sum +++ b/go.sum @@ -114,8 +114,8 @@ github.com/bodgit/sevenzip v1.5.0 h1:QESwnPUnhqftOgbi6wIiWm1WEkrT4puHukt5a2psEcw github.com/bodgit/sevenzip v1.5.0/go.mod h1:+E74G6pfBX8IMaVybsKMgGTTTBcbHU8ssPTJ9mLUr38= github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4= github.com/bodgit/windows v1.0.1/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM= -github.com/cardil/ghet v0.0.1-0.20240322174403-1901c4fe21ac h1:J6clysTPmIXMLYNh5Vu+x3qNiMTXKibibYz4dO/tiT8= -github.com/cardil/ghet v0.0.1-0.20240322174403-1901c4fe21ac/go.mod h1:INmHFxuHn5LmjkjmR9aCqa6msghwM/4q5He/vYlucfY= +github.com/cardil/ghet v0.0.1-0.20240326133720-fccab8f3066e h1:ijvKajl7Hv/H3k2J9PyXsDlwDcxt98T/lRoT7G2eizk= +github.com/cardil/ghet v0.0.1-0.20240326133720-fccab8f3066e/go.mod h1:GMYQeYWhSM+R11LaHHocV/9d/JZcG1+XVUDzm5nbtrc= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -799,8 +799,8 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY= k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/client-pkg v0.0.0-20240322171749-cf1573f93631 h1:LRwjoTbqyruGECvQZyGQE3k5clxwmgCQEt5HcWTUz2Y= -knative.dev/client-pkg v0.0.0-20240322171749-cf1573f93631/go.mod h1:CODwMfQexBzzgB2fv9hYF1+FZfrYc9TF3B26GxW69zQ= +knative.dev/client-pkg v0.0.0-20240326133606-ca64d2dc74eb h1:GXMlA9qA1b/a1eRBgMhfdmFqLyv17DdjaOnaH/ZFBU0= +knative.dev/client-pkg v0.0.0-20240326133606-ca64d2dc74eb/go.mod h1:+wx9/SVVGLte1JRcULet7kKnnUmgPzG1vQpD8E4DwVs= knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c h1:d8GmDhObjnH/iKrazsNjgLuuEnxLiFE/QSaeFY337cw= knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c/go.mod h1:RfDXq7Rf7UmGCEdAiJZPpBRuh7dX73T8clniFt2zEAA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/tests/example/.golangci.yml b/tests/example/.golangci.yml index 43a8231..93e6233 100644 --- a/tests/example/.golangci.yml +++ b/tests/example/.golangci.yml @@ -36,12 +36,3 @@ issues: - path: _test\.go linters: - wrapcheck - - -linters-settings: - gomoddirectives: - # List of allowed `replace` directives. Default is empty. - replace-allow-list: - # FIXME: remove after https://github.com/google/ko/issues/476 - - github.com/google/ko - - knative.dev/client-pkg diff --git a/tests/project_build_test.go b/tests/project_build_test.go index 65c61e8..f025268 100644 --- a/tests/project_build_test.go +++ b/tests/project_build_test.go @@ -17,25 +17,41 @@ func TestProjectBuild(t *testing.T) { if testing.Short() { t.Skip("short tests only") } - execCmd(t, "./example", "./mage", "clean", "build") - execCmd(t, "./example/build/_output/bin", fmt.Sprintf("./other-%s-%s", - runtime.GOOS, runtime.GOARCH)) + c := mkCmd("./example", "./mage", "clean", "build") + assertCommandStarted(t, c) + assertCommandSucceded(t, c) + c = mkCmd("./example/build/_output/bin", + fmt.Sprintf("./other-%s-%s", runtime.GOOS, runtime.GOARCH)) + assertCommandStarted(t, c) + assertCommandSucceded(t, c) } -func execCmd(tb testing.TB, dir, name string, args ...string) { - tb.Helper() +func mkCmd(dir, name string, args ...string) *exec.Cmd { c := exec.Command(name, args...) c.Env = append( - env(filterOutByName{names: []string{"GOOS"}}), + env(filterOutByName{names: []string{"GOOS", "GOARCH", "GOARM"}}), "GOTRACEBACK=all", ) c.Dir = dir c.Stdout = os.Stdout c.Stderr = os.Stderr + return c +} + +func assertCommandStarted(tb testing.TB, c *exec.Cmd) { + tb.Helper() assert.NilError(tb, c.Start()) tb.Logf("Started `%q` with pid %d", - append([]string{name}, args...), + append([]string{c.Path}, c.Args...), c.Process.Pid) + tb.Log("Process env:") + for _, e := range c.Env { + tb.Logf(" * %s", e) + } +} + +func assertCommandSucceded(tb testing.TB, c *exec.Cmd) { + tb.Helper() assert.NilError(tb, c.Wait()) }