-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
80 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,59 +23,3 @@ jobs: | |
run: go version | ||
- run: go mod tidy | ||
- run: go test ./... | ||
|
||
lint: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
go-version: [ '1.23' ] | ||
defaults: | ||
run: | ||
working-directory: generator | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
cache-dependency-path: | | ||
generator/go.sum | ||
- name: Display Go version | ||
run: go version | ||
- run: go mod tidy | ||
- run: go fmt ./... | ||
- run: go vet ./... | ||
- run: | | ||
# unparam does not seem to have releases. Using `latest` sounds risky. | ||
go get mvdan.cc/unparam@57a3b4290ba3724102fdbbe72314f2b782d4bef5 | ||
go run mvdan.cc/unparam ./... | ||
- name: Run `staticcheck` | ||
uses: dominikh/[email protected] | ||
with: | ||
install-go: false | ||
cache-key: ${{ matrix.go-version }} | ||
working-directory: generator | ||
- name: Detect Changes | ||
run: git diff --exit-code | ||
|
||
vuln: | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
go-version: [ '1.23' ] | ||
defaults: | ||
run: | ||
working-directory: generator | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
cache-dependency-path: | | ||
generator/go.sum | ||
- name: Display Go version | ||
run: go version | ||
- run: | | ||
go get golang.org/x/vuln/cmd/[email protected] | ||
go run golang.org/x/vuln/cmd/govulncheck ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"errors" | ||
"os/exec" | ||
"testing" | ||
|
||
"mvdan.cc/unparam/check" | ||
) | ||
|
||
func TestStaticCheck(t *testing.T) { | ||
rungo(t, "run", "honnef.co/go/tools/cmd/[email protected]", "./...") | ||
} | ||
|
||
func TestUnparam(t *testing.T) { | ||
warns, err := check.UnusedParams(false, false, false, "./...") | ||
if err != nil { | ||
t.Fatalf("check.UnusedParams: %v", err) | ||
} | ||
for _, warn := range warns { | ||
t.Error(warn) | ||
} | ||
} | ||
|
||
func TestVet(t *testing.T) { | ||
rungo(t, "vet", "-all", "./...") | ||
} | ||
|
||
func TestGoModTidy(t *testing.T) { | ||
rungo(t, "mod", "tidy") | ||
} | ||
|
||
func TestGoFmt(t *testing.T) { | ||
rungo(t, "fmt") | ||
} | ||
|
||
func TestGovulncheck(t *testing.T) { | ||
rungo(t, "run", "golang.org/x/vuln/cmd/[email protected]", "./...") | ||
} | ||
|
||
func rungo(t *testing.T, args ...string) { | ||
t.Helper() | ||
|
||
cmd := exec.Command("go", args...) | ||
if output, err := cmd.CombinedOutput(); err != nil { | ||
if ee := (*exec.ExitError)(nil); errors.As(err, &ee) && len(ee.Stderr) > 0 { | ||
t.Fatalf("%v: %v\n%s", cmd, err, ee.Stderr) | ||
} | ||
t.Fatalf("%v: %v\n%s", cmd, err, output) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters