Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mage: check that links are live in the OTel README #5443

Merged
merged 18 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions dev-tools/mage/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// It checks the file permissions of python test cases and YAML files.
// It checks .go source files using 'go vet'.
func Check() error {
fmt.Println(">> check: Checking source code for common problems") //nolint:forbidigo // it's ok to use fmt.println in mage
fmt.Println(">> check: Checking source code for common problems")

mg.Deps(GoVet, CheckYAMLNotExecutable, devtools.CheckNoChanges)

Expand Down Expand Up @@ -69,7 +69,7 @@ func GoVet() error {

// CheckLicenseHeaders checks license headers in .go files.
func CheckLicenseHeaders() error {
fmt.Println(">> fmt - go-licenser: Checking for missing headers") //nolint:forbidigo // it's ok to use fmt.println in mage
fmt.Println(">> fmt - go-licenser: Checking for missing headers")
mg.Deps(InstallGoLicenser)

licenser := gotool.Licenser
Expand All @@ -79,3 +79,16 @@ func CheckLicenseHeaders() error {
)

}

// CheckLinksInFileAreLive checks if all links in a file are live.
func CheckLinksInFileAreLive(filename string) func() error {
return func() error {
fmt.Printf(">> check: Checking for invalid links in %q\n", filename)
mg.Deps(InstallGoLinkCheck)

linkcheck := gotool.LinkCheck
return linkcheck(
linkcheck.Path(filename),
)
}
}
21 changes: 21 additions & 0 deletions dev-tools/mage/gotool/linkcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package gotool

import (
"github.com/magefile/mage/sh"
)

type goLinkCheck func(opts ...ArgOpt) error

// LinkCheck runs `link-patrol` to verify links in files and provides optionals for adding command line arguments.
var LinkCheck goLinkCheck = runGoLinkCheck

func runGoLinkCheck(opts ...ArgOpt) error {
args := buildArgs(opts).build()
return sh.RunV("link-patrol", args...)
}

func (goLinkCheck) Path(path string) ArgOpt { return flagArgIf("-f", path) }
10 changes: 10 additions & 0 deletions dev-tools/mage/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
var (
// GoLicenserImportPath controls the import path used to install go-licenser.
GoLicenserImportPath = "github.com/elastic/go-licenser"

// GoLinkCheckImportPath controls the import path used to install the link check tool
GoLinkCheckImportPath = "github.com/rednafi/link-patrol/cmd/link-patrol"
)

// InstallVendored uses go get to install a command from its vendored source
Expand All @@ -28,3 +31,10 @@ func InstallGoLicenser() error {
gotool.Install.Package(GoLicenserImportPath),
)
}

// InstallGoLinkCheck target installs the link check tool
func InstallGoLinkCheck() error {
return gotool.Install(
gotool.Install.Package(GoLinkCheckImportPath),
)
}
36 changes: 22 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ require (
github.com/elastic/go-ucfg v0.8.8
github.com/elastic/mock-es v0.0.0-20240712014503-e5b47ece0015
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.9.0
github.com/fatih/color v1.16.0
github.com/fatih/color v1.17.0
github.com/fsnotify/fsnotify v1.7.0
github.com/go-viper/mapstructure/v2 v2.1.0
github.com/gofrs/flock v0.8.1
github.com/gofrs/flock v0.12.1
github.com/gofrs/uuid/v5 v5.2.0
github.com/google/go-cmp v0.6.0
github.com/google/pprof v0.0.0-20240711041743-f6c9dda6c6da
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8
github.com/gorilla/mux v1.8.1
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95
github.com/jaypipes/ghw v0.12.0
Expand All @@ -45,6 +45,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.108.0
github.com/otiai10/copy v1.14.0
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
github.com/rednafi/link-patrol v0.0.0-20240826150821-057643e74d4d
github.com/rs/zerolog v1.27.0
github.com/sajari/regression v1.0.1
github.com/schollz/progressbar/v3 v3.13.1
Expand All @@ -61,13 +62,13 @@ require (
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.108.1
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.26.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/sync v0.8.0
golang.org/x/sys v0.24.0
golang.org/x/term v0.23.0
golang.org/x/text v0.17.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.23.0
golang.org/x/time v0.6.0
golang.org/x/tools v0.24.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
gopkg.in/ini.v1 v1.67.0
Expand Down Expand Up @@ -125,8 +126,8 @@ require (
)

require (
cloud.google.com/go/auth v0.7.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/auth v0.8.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect
Expand All @@ -149,6 +150,7 @@ require (
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
Expand Down Expand Up @@ -198,11 +200,11 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/gophercloud/gophercloud v1.13.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
Expand Down Expand Up @@ -265,6 +267,8 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo/v2 v2.20.0 // indirect
github.com/onsi/gomega v1.34.1 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.108.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.108.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.108.0 // indirect
Expand Down Expand Up @@ -300,6 +304,7 @@ require (
github.com/prometheus/prometheus v0.54.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rs/cors v1.11.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/shirou/gopsutil/v4 v4.24.7 // indirect
Expand All @@ -308,10 +313,13 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 // indirect
github.com/urfave/cli/v2 v2.27.4 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/vultr/govultr/v2 v2.17.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yuin/goldmark v1.7.4 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.elastic.co/apm/module/apmhttp/v2 v2.6.0 // indirect
go.elastic.co/apm/module/apmzap/v2 v2.6.0 // indirect
Expand Down Expand Up @@ -367,13 +375,13 @@ require (
go.starlark.net v0.0.0-20221205180719-3fd0dac74452 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
google.golang.org/api v0.188.0 // indirect
google.golang.org/api v0.192.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
Expand Down
Loading