Skip to content

Commit

Permalink
[chore] adopt GCI to manage imports
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Jan 15, 2023
1 parent 09e2f9b commit 59406ce
Show file tree
Hide file tree
Showing 23 changed files with 35 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ jobs:
git diff --exit-code ':!*go.sum' || (echo 'Generated code is out of date, please run "make generate" and commit the changes in this PR.' && exit 1)
- name: Impi
run: make -j2 goimpi
- name: GCI
run: |
make -j2 gogci
git diff --exit-code || (echo 'Imports are not formatted properly, please run "make gogci" and commit the changes in this PR' && exit 1)
- name: MultimodVerify
run: make multimod-verify
- name: Components dropdown in issue templates
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ golint:
goimpi: install-tools
@$(MAKE) $(FOR_GROUP_TARGET) TARGET="impi"

.PHONY: gogci
gogci: install-tools
@$(MAKE) $(FOR_GROUP_TARGET) TARGET="gci"

.PHONY: goporto
goporto: install-tools
porto -w --include-internal --skip-dirs "^cmd$$" ./
Expand Down Expand Up @@ -218,6 +222,7 @@ install-tools:
cd $(TOOLS_MOD_DIR) && $(GOCMD) install go.opentelemetry.io/build-tools/multimod
cd $(TOOLS_MOD_DIR) && $(GOCMD) install github.com/jcchavezs/porto/cmd/porto
cd $(TOOLS_MOD_DIR) && $(GOCMD) install go.opentelemetry.io/build-tools/crosslink
cd $(TOOLS_MOD_DIR) && $(GOCMD) install github.com/daixiang0/gci

.PHONY: run
run:
Expand Down
6 changes: 6 additions & 0 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ MISSPELL=misspell -error
MISSPELL_CORRECTION=misspell -w
LINT=golangci-lint
IMPI=impi
GCI=gci
# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release
RUNNING_ON_GITHUB_ACTION=$(GITHUB_ACTIONS)
Expand Down Expand Up @@ -131,6 +132,7 @@ checklinks:
fmt:
gofmt -w -s ./
goimports -w -local github.com/open-telemetry/opentelemetry-collector-contrib ./
@$(GCI) write ./ -s standard -s default -s "prefix(github.com/open-telemetry/opentelemetry-collector-contrib)"

.PHONY: lint
lint: checklicense misspell
Expand All @@ -154,6 +156,10 @@ misspell-correction:
impi:
@$(IMPI) --local github.com/open-telemetry/opentelemetry-collector-contrib --scheme stdThirdPartyLocal ./...

.PHONY: gci
gci:
@$(GCI) write ./ -s standard -s default -s "prefix(github.com/open-telemetry/opentelemetry-collector-contrib)"

.PHONY: moddownload
moddownload:
$(GOCMD) mod download
Expand Down
1 change: 1 addition & 0 deletions exporter/azuremonitorexporter/time_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package azuremonitorexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuremonitorexporter"

// Contains code common to both trace and metrics exporters

import (
"fmt"
"time"
Expand Down
1 change: 1 addition & 0 deletions exporter/azuremonitorexporter/trace_to_envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package azuremonitorexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuremonitorexporter"

// Contains code common to both trace and metrics exporters

import (
"errors"
"net/url"
Expand Down
1 change: 1 addition & 0 deletions extension/storage/dbstorage/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// +build !windows

package dbstorage // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/dbstorage"

import (
"errors"
"testing"
Expand Down
3 changes: 1 addition & 2 deletions internal/coreinternal/attraction/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
package attraction // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/attraction"

import (
// #nosec
"crypto/sha1"
"crypto/sha1" // #nosec
"encoding/binary"
"encoding/hex"
"math"
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
github.com/client9/misspell v0.3.4
github.com/daixiang0/gci v0.9.0
github.com/golangci/golangci-lint v1.50.1
github.com/google/addlicense v1.1.0
github.com/jcchavezs/porto v0.4.0
Expand Down Expand Up @@ -49,7 +50,6 @@ require (
github.com/chavacava/garif v0.0.0-20220630083739-93517212f375 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/daixiang0/gci v0.8.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denis-tingaikin/go-header v0.4.3 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions internal/tools/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package tools // import "github.com/open-telemetry/opentelemetry-collector-contr

import (
_ "github.com/client9/misspell/cmd/misspell"
_ "github.com/daixiang0/gci"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/google/addlicense"
_ "github.com/jcchavezs/porto/cmd/porto"
Expand Down
1 change: 1 addition & 0 deletions pkg/ottl/contexts/ottlresource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package ottlresource // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlresource"

import (
"fmt"

Expand Down
1 change: 1 addition & 0 deletions pkg/ottl/grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package ottl // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"

import (
"encoding/hex"
"fmt"
Expand Down
1 change: 0 additions & 1 deletion pkg/stanza/adapter/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package adapter // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/adapter"

import (
// Register parsers and transformers for stanza-based log receivers
_ "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/output/file"
_ "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/output/stdout"
_ "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/csv"
Expand Down
1 change: 1 addition & 0 deletions processor/transformprocessor/internal/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package common // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/common"

import (
"fmt"
"strings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package cwmetricstream // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler/cwmetricstream"

import (
"fmt"
"strings"
Expand Down
1 change: 1 addition & 0 deletions receiver/azureeventhubreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package azureeventhubreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azureeventhubreceiver"

import (
"errors"
"fmt"
Expand Down
1 change: 1 addition & 0 deletions receiver/azureeventhubreceiver/persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package azureeventhubreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azureeventhubreceiver"

import (
"context"
"fmt"
Expand Down
1 change: 1 addition & 0 deletions receiver/azureeventhubreceiver/persister_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package azureeventhubreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azureeventhubreceiver"

import (
"context"
"errors"
Expand Down
1 change: 1 addition & 0 deletions receiver/nsxtreceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package nsxtreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nsxtreceiver"

import (
"context"
"encoding/json"
Expand Down
1 change: 1 addition & 0 deletions receiver/nsxtreceiver/client_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package nsxtreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nsxtreceiver"

import (
context "context"
testing "testing"
Expand Down
1 change: 1 addition & 0 deletions receiver/nsxtreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package nsxtreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nsxtreceiver"

import (
"context"
"fmt"
Expand Down
1 change: 1 addition & 0 deletions receiver/nsxtreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

package nsxtreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nsxtreceiver"

import (
"errors"
"fmt"
Expand Down
1 change: 1 addition & 0 deletions receiver/purefareceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package purefareceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver"

// This file implements Factory for Array scraper.

import (
"context"
"fmt"
Expand Down

0 comments on commit 59406ce

Please sign in to comment.