diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5e4fc315deb..dd586259af2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,4 @@ -# File generated by "make dependabot-generate"; DO NOT EDIT. - +# File generated by dbotconf; DO NOT EDIT. version: 2 updates: - package-ecosystem: github-actions @@ -7,286 +6,286 @@ updates: labels: - dependencies - actions - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: / labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /bridge/opencensus labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /bridge/opencensus/test labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /bridge/opentracing labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/fib labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/jaeger labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/namedtracer labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/opencensus labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/otel-collector labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/passthrough labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/prometheus labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /example/zipkin labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/jaeger labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/otlp/internal/retry labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/otlp/otlpmetric labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/otlp/otlpmetric/otlpmetricgrpc labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/otlp/otlpmetric/otlpmetrichttp labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/otlp/otlptrace labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/otlp/otlptrace/otlptracegrpc labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/otlp/otlptrace/otlptracehttp labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/prometheus labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/stdout/stdoutmetric labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/stdout/stdouttrace labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /exporters/zipkin labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /internal/tools labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /metric labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /schema labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /sdk labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /sdk/export/metric labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /sdk/metric labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday - package-ecosystem: gomod directory: /trace labels: - dependencies - go - - "Skip Changelog" + - Skip Changelog schedule: - day: sunday interval: weekly + day: sunday diff --git a/Makefile b/Makefile index bcb3a6d8629..1b80eb72adf 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ CROSSLINK = $(TOOLS)/crosslink $(TOOLS)/crosslink: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/crosslink DBOTCONF = $(TOOLS)/dbotconf -$(TOOLS)/dbotconf: PACKAGE=go.opentelemetry.io/otel/$(TOOLS_MOD_DIR)/dbotconf +$(TOOLS)/dbotconf: PACKAGE=go.opentelemetry.io/build-tools/dbotconf GOLANGCI_LINT = $(TOOLS)/golangci-lint $(TOOLS)/golangci-lint: PACKAGE=github.com/golangci/golangci-lint/cmd/golangci-lint @@ -178,26 +178,14 @@ license-check: exit 1; \ fi -DEPENDABOT_PATH=./.github/dependabot.yml +DEPENDABOT_CONFIG = .github/dependabot.yml .PHONY: dependabot-check -dependabot-check: - @result=$$( \ - for f in $$( find . -type f -name go.mod -exec dirname {} \; | sed 's/^.//' ); \ - do grep -q "directory: \+$$f" $(DEPENDABOT_PATH) \ - || echo "$$f"; \ - done; \ - ); \ - if [ -n "$$result" ]; then \ - echo "missing dependabot entry:"; echo "$$result"; \ - echo "new modules need to be added to the $(DEPENDABOT_PATH) file"; \ - echo "(run: make dependabot-generate)"; \ - exit 1; \ - fi +dependabot-check: | $(DBOTCONF) + @$(DBOTCONF) verify $(DEPENDABOT_CONFIG) || echo "(run: make dependabot-generate)" .PHONY: dependabot-generate -dependabot-generate: $(DBOTCONF) - @echo "gerating dependabot configuration"; \ - $(DBOTCONF) +dependabot-generate: | $(DBOTCONF) + @$(DBOTCONF) generate > $(DEPENDABOT_CONFIG) .PHONY: check-clean-work-tree check-clean-work-tree: diff --git a/internal/tools/dbotconf/dbotconf.go b/internal/tools/dbotconf/dbotconf.go deleted file mode 100644 index a81a3a83fb9..00000000000 --- a/internal/tools/dbotconf/dbotconf.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// 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 provides a utility to generate a complete dependabot -// configuration for a repository with multiple Go modules. -package main - -import ( - "flag" - "fmt" - "log" - "os" - "path/filepath" - "sort" - "strings" - "text/template" - - "go.opentelemetry.io/otel/internal/tools" - "golang.org/x/mod/modfile" -) - -var configPtr = flag.String("config", "./.github/dependabot.yml", "dependabot configuration path") - -const configTemplate = `# File generated by "make dependabot-generate"; DO NOT EDIT. - -version: 2 -updates: - - package-ecosystem: github-actions - directory: / - labels: - - dependencies - - actions - - "Skip Changelog" - schedule: - day: sunday - interval: weekly -{{- range .}} - - package-ecosystem: gomod - directory: {{.}} - labels: - - dependencies - - go - - "Skip Changelog" - schedule: - day: sunday - interval: weekly -{{- end}} -` - -func gomodDirectories(basePath string, mods []*modfile.File) []string { - var dirs []string - for _, m := range mods { - targetPath := filepath.Dir(m.Syntax.Name) - relPath := strings.TrimPrefix(targetPath, basePath) - if relPath == "" { - relPath = "/" - } - dirs = append(dirs, relPath) - } - sort.Strings(dirs) - return dirs -} - -func generate(path string) error { - tpl, err := template.New("dependabot.yml").Parse(configTemplate) - if err != nil { - return fmt.Errorf("parse template: %w", err) - } - - root, err := tools.FindRepoRoot() - if err != nil { - return fmt.Errorf("find repo root: %w", err) - } - - mods, err := root.FindModules() - if err != nil { - return fmt.Errorf("list modules: %w", err) - } - data := gomodDirectories(string(root), mods) - - f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) - if err != nil { - return err - } - if err = tpl.Execute(f, data); err != nil { - // Best effort. - _ = f.Close() - return fmt.Errorf("rendering template: %w", err) - } - if err = f.Close(); err != nil { - return fmt.Errorf("closing %s: %w", path, err) - } - return nil -} - -func main() { - flag.Parse() - if err := generate(*configPtr); err != nil { - log.Fatalf("failed to generate dependabot configuration: %v", err) - } -} diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 9ce202b9249..78aee63e85e 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -9,6 +9,7 @@ require ( github.com/itchyny/gojq v0.12.7 github.com/jcchavezs/porto v0.4.0 github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad + go.opentelemetry.io/build-tools/dbotconf v0.0.0-20220321164008-b8e03aff061a go.opentelemetry.io/build-tools/multimod v0.0.0-20210920164323-2ceabab23375 go.opentelemetry.io/build-tools/semconvgen v0.0.0-20210920164323-2ceabab23375 golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 diff --git a/internal/tools/go.sum b/internal/tools/go.sum index a579c8d18e7..5f1e09c9329 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -812,8 +812,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/sylvia7788/contextcheck v1.0.4 h1:MsiVqROAdr0efZc/fOCt0c235qm9XJqHtWwM+2h2B04= @@ -894,8 +895,11 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/build-tools v0.0.0-20210719163622-92017e64f35b h1:tFMjUqEDGM2F82663yYidqTluwEJmmihk/AXr19J7rI= go.opentelemetry.io/build-tools v0.0.0-20210719163622-92017e64f35b/go.mod h1:zZRrJN8qdwDdPNkCEyww4SW54mM1Da0v9H3TyQet9T4= +go.opentelemetry.io/build-tools v0.0.0-20220304161722-feb5ff5848f1 h1:R/LC1WK1TDCbS2ANSeI2XcKrO5Ym6tx1YCUo+AaiFoE= +go.opentelemetry.io/build-tools v0.0.0-20220304161722-feb5ff5848f1/go.mod h1:qO4vrNgLf0V5FHckLNwEw2CfBTaL8w6pKDm3bF6nhMk= +go.opentelemetry.io/build-tools/dbotconf v0.0.0-20220321164008-b8e03aff061a h1:VCNW72z+YKDAH8O5y+WmMuj2Jlgd+ZG5Abk9xTGw6dQ= +go.opentelemetry.io/build-tools/dbotconf v0.0.0-20220321164008-b8e03aff061a/go.mod h1:/X2uGFIoHCUyQiBqL6pY6AEU2j8q1e+EMWhZlCsY5dk= go.opentelemetry.io/build-tools/multimod v0.0.0-20210920164323-2ceabab23375 h1:5zVDNFcOwiMee9Qm8sH08iw+9cJZk+l/Y3mVa2D/zmM= go.opentelemetry.io/build-tools/multimod v0.0.0-20210920164323-2ceabab23375/go.mod h1:mPh1L/tfTGyVNnSQOTlTSi2CBpci13Ft8jE4Glik2es= go.opentelemetry.io/build-tools/semconvgen v0.0.0-20210920164323-2ceabab23375 h1:EaeArFokiObXc/jkX0Ck3u2d6lWDmeWdEPy2IdlF6iw= diff --git a/internal/tools/tools.go b/internal/tools/tools.go index 2966e7bfd26..53b4a545b23 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -24,6 +24,7 @@ import ( _ "github.com/itchyny/gojq" _ "github.com/jcchavezs/porto/cmd/porto" _ "github.com/wadey/gocovmerge" + _ "go.opentelemetry.io/build-tools/dbotconf" _ "go.opentelemetry.io/build-tools/multimod" _ "go.opentelemetry.io/build-tools/semconvgen" _ "golang.org/x/tools/cmd/stringer"