diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7107bb727..5632159ea 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -38,23 +38,8 @@ jobs: with: go-version-file: ${{ github.workspace }}/go.mod - - name: Initialize dependencies and linters - run: make init - - - name: Diff - run: | - make format - git diff --exit-code - - name: Test run: | TEST_MONGODB_IMAGE=${{ matrix.image }} make test-cluster make test-race make test-cluster-clean - - - name: Run checks/linters - run: | - # use GITHUB_TOKEN because only it has access to GitHub Checks API - bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check - bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review - make check-license diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..1fc1c1996 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +name: Lint + +on: + schedule: + # run every Sunday + - cron: '0 13 * * 0' + push: + branches: + - main + - release-0.1x + tags: + - v[0-9]+.[0-9]+.[0-9]+* + pull_request: + +jobs: + lint: + name: Lint Check + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: ${{ github.workspace }}/go.mod + + - name: Initialize dependencies and linters + run: make init + + - name: Diff + run: | + make format + git diff --exit-code + - name: Run checks/linters + run: | + # use GITHUB_TOKEN because only it has access to GitHub Checks API + bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check + bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review + make check-license diff --git a/exporter/v1_compatibility_test.go b/exporter/v1_compatibility_test.go index de7910849..6dcbff713 100644 --- a/exporter/v1_compatibility_test.go +++ b/exporter/v1_compatibility_test.go @@ -18,7 +18,7 @@ package exporter import ( "context" "encoding/json" - "io/ioutil" + "os" "path/filepath" "sort" "strings" @@ -100,7 +100,7 @@ func TestMakeLockMetric(t *testing.T) { } func TestAddLocksMetrics(t *testing.T) { - buf, err := ioutil.ReadFile(filepath.Join("testdata/", "locks.json")) + buf, err := os.ReadFile(filepath.Join("testdata/", "locks.json")) assert.NoError(t, err) var m bson.M @@ -163,7 +163,7 @@ func TestSumMetrics(t *testing.T) { testCase := tt t.Run(tt.name, func(t *testing.T) { - buf, err := ioutil.ReadFile(filepath.Join("testdata/", "get_diagnostic_data.json")) + buf, err := os.ReadFile(filepath.Join("testdata/", "get_diagnostic_data.json")) assert.NoError(t, err) var m bson.M diff --git a/internal/tu/testutils.go b/internal/tu/testutils.go index d576c5f31..ce138ab3f 100644 --- a/internal/tu/testutils.go +++ b/internal/tu/testutils.go @@ -20,7 +20,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net" "os" "os/exec" @@ -139,7 +138,7 @@ func TestClient(ctx context.Context, port string, t *testing.T) *mongo.Client { // LoadJSON loads a file and returns the result of unmarshaling it into a bson.M structure. func LoadJSON(filename string) (bson.M, error) { - buf, err := ioutil.ReadFile(filepath.Clean(filename)) + buf, err := os.ReadFile(filepath.Clean(filename)) if err != nil { return nil, err }