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

Add codespell to CI #5683

Merged
merged 14 commits into from
May 30, 2024
3 changes: 3 additions & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ot
dmathieu marked this conversation as resolved.
Show resolved Hide resolved
fo
dmathieu marked this conversation as resolved.
Show resolved Hide resolved

10 changes: 10 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://github.com/codespell-project/codespell
[codespell]
builtin = clear,rare,informal
check-filenames =
check-hidden =
ignore-words = .codespellignore
interactive = 1
skip = .git,go.mod,go.sum,go.work,go.work.sum,semconv,venv,.tools
uri-ignore-words-list = *
write =
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/owner.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Module: [e.g. go.opentelemetry.io/contrib/zpages]

[member of the OpenTelemetry organization]: https://github.com/open-telemetry/community/blob/main/community-membership.md#member

### Relvant experience
### Relevant experience

List any PRs/Issues you have interacted with in this repository for this module.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This action requires that any PR targeting the main branch should touch at
# least one CHANGELOG file. If a CHANGELOG entry is not required, or if
# performing maintance on the Changelog, add either \"[chore]\" to the title of
# performing maintenance on the Changelog, add either \"[chore]\" to the title of
# the pull request or add the \"Skip Changelog\" label to disable this action.

name: changelog
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
go-version: ["~1.22.3", "~1.21.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
# GitHub Actions does not support arm* architectures on default
# runners. It is possible to acomplish this with a self-hosted runner
# runners. It is possible to accomplish this with a self-hosted runner
# if we want to add this in the future:
# https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow
arch: ["386", amd64]
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: codespell
on:
push:
branches:
- main
pull_request:
jobs:
codespell:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Codespell
run: make codespell
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Thumbs.db

.tools/
venv/
.idea/
.vscode/
*.iml
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ linters-settings:
- name: constant-logical-expr
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
# TODO (#2877) reenable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
# TODO (#2877) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
- name: context-as-argument
disabled: true
arguments:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ A pull request is considered ready to merge when the following criteria are meet
Any Maintainer can merge the pull request once it is ready to merge.

[^1]: The `go.opentelemetry.io/contrib/instrgen` module is exempt from the two approvals and one day requirement.
Only one approval is needed to merge a Pull Request for that module and there is no minimum amout of time required for the PR to be open before merging.
Only one approval is needed to merge a Pull Request for that module and there is no minimum amount of time required for the PR to be open before merging.
This exemption is to be removed when that package makes its first tagged release.

### Draft Pull Requests
Expand Down
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,39 @@ $(GOVULNCHECK): PACKAGE=golang.org/x/vuln/cmd/govulncheck

tools: $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(MULTIMOD) $(CROSSLINK) $(GOTMPL) $(GORELEASE) $(GOJSONSCHEMA) $(GOVULNCHECK)

# Virtualized python tools via docker

# The directory where the virtual environment is created.
VENVDIR := venv

# The directory where the python tools are installed.
PYTOOLS := $(VENVDIR)/bin

# The pip executable in the virtual environment.
PIP := $(PYTOOLS)/pip

# The directory in the docker image where the current directory is mounted.
WORKDIR := /workdir

# The python image to use for the virtual environment.
PYTHONIMAGE := python:3.11.3-slim-bullseye

# Run the python image with the current directory mounted.
DOCKERPY := docker run --rm -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)

# Create a virtual environment for Python tools.
$(PYTOOLS):
# The `--upgrade` flag is needed to ensure that the virtual environment is
# created with the latest pip version.
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip"

# Install python packages into the virtual environment.
$(PYTOOLS)/%: $(PYTOOLS)
@$(DOCKERPY) $(PIP) install -r requirements.txt

CODESPELL = $(PYTOOLS)/codespell
$(CODESPELL): PACKAGE=codespell

# Generate

.PHONY: generate
Expand Down Expand Up @@ -315,3 +348,7 @@ genjsonschema: genjsonschema-cleanup $(GOJSONSCHEMA)
mv ${GENERATED_CONFIG}.tmp ${GENERATED_CONFIG}
$(MAKE) lint
$(MAKE) genjsonschema-cleanup

.PHONY: codespell
codespell: $(CODESPELL)
@$(DOCKERPY) $(CODESPELL)
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ go.opentelemetry.io/otel packages are compatible with the contrib repository.
Follow the following steps to verify the changes.

1. Pick the GIT SHA on the [main branch](https://github.com/open-telemetry/opentelemetry-go/commits/main) that you want to verify.
2. Run the following command to update the OTel depencies with the GIT SHA picked in step 1.
2. Run the following command to update the OTel dependencies with the GIT SHA picked in step 1.

```sh
export GITSHA=<the GIT SHA you want to verify>
Expand Down
2 changes: 1 addition & 1 deletion config/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func prometheusReader(ctx context.Context, prometheusConfig *Prometheus) (sdkmet
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg}))
server := http.Server{
// Timeouts are necessary to make a server resilent to attacks, but ListenAndServe doesn't set any.
// Timeouts are necessary to make a server resilient to attacks, but ListenAndServe doesn't set any.
// We use values from this example: https://blog.cloudflare.com/exposing-go-on-the-internet/#:~:text=There%20are%20three%20main%20timeouts
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/ecs/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestLogsAttributesAlternatePartition(t *testing.T) {
ContainerARN: "arn:arn-partition:arn-svc:arn-region:arn-account:arn-resource",
}
actualAttributes, err := detector.getLogsAttributes(containerMetadata)
assert.NoError(t, err, "failure with nonstandard partitition")
assert.NoError(t, err, "failure with nonstandard partition")

expectedAttributes := []attribute.KeyValue{
semconv.AWSLogGroupNames(containerMetadata.LogOptions.AwsLogsGroup),
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

// Package contrib is a collection of extensions for the opentelemetry-go
// project. It provides 3rd parth resource detectors, propagators, samplers,
// project. It provides 3rd party resource detectors, propagators, samplers,
// bridges, and instrumentation as submodules.
package contrib // import "go.opentelemetry.io/contrib"
4 changes: 2 additions & 2 deletions exporters/autoexport/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func WithFallbackMetricReader(metricReaderFactory func(ctx context.Context) (met
// Use [WithFallbackMetricReader] option to change the returned exporter
// when OTEL_METRICS_EXPORTER is unset or empty.
//
// Use [IsNoneMetricReader] to check if the retured exporter is a "no operation" exporter.
// Use [IsNoneMetricReader] to check if the returned exporter is a "no operation" exporter.
func NewMetricReader(ctx context.Context, opts ...MetricOption) (metric.Reader, error) {
return metricsSignal.create(ctx, opts...)
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func init() {
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg}))
server := http.Server{
// Timeouts are necessary to make a server resilent to attacks, but ListenAndServe doesn't set any.
// Timeouts are necessary to make a server resilient to attacks, but ListenAndServe doesn't set any.
// We use values from this example: https://blog.cloudflare.com/exposing-go-on-the-internet/#:~:text=There%20are%20three%20main%20timeouts
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion exporters/autoexport/spans.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func WithFallbackSpanExporter(spanExporterFactory func(ctx context.Context) (tra
// Use [WithFallbackSpanExporter] option to change the returned exporter
// when OTEL_TRACES_EXPORTER is unset or empty.
//
// Use [IsNoneSpanExporter] to check if the retured exporter is a "no operation" exporter.
// Use [IsNoneSpanExporter] to check if the returned exporter is a "no operation" exporter.
func NewSpanExporter(ctx context.Context, opts ...SpanOption) (trace.SpanExporter, error) {
return tracesSignal.create(ctx, opts...)
}
Expand Down
2 changes: 1 addition & 1 deletion instrgen/lib/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"golang.org/x/tools/go/packages"
)

// PackageAnalysis analyze all package set accrding to passed
// PackageAnalysis analyze all package set according to passed
// pattern. It requires an information about path, pattern,
// root functions - entry points, function declarations,
// and so on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type mockHTTPRequest struct {
func mockEventToCarrier(eventJSON []byte) propagation.TextMapCarrier{
var request mockHTTPRequest
_ = json.unmarshal(eventJSON, &request)
return propogation.HeaderCarrier{someHeaderKey: []string{request.Headers[someHeaderKey]}}
return propagation.HeaderCarrier{someHeaderKey: []string{request.Headers[someHeaderKey]}}
}

type mockPropagator struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (l *listener) Accept() (net.Conn, error) {
return conn, nil
}

// WaitForConn will wait indefintely for a connection to be estabilished with
// WaitForConn will wait indefintely for a connection to be established with
// the listener before returning.
func (l *listener) WaitForConn() {
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package test // import "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws/test"

// Version is the current release version of the AWS intstrumentation test module.
// Version is the current release version of the AWS instrumentation test module.
func Version() string {
return "0.52.0"
// This string is updated by the pre_release.sh script during release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func WithTracerProvider(provider oteltrace.TracerProvider) Option {
})
}

// WithPublicEndpointFn runs with every request, and allows conditionnally
// WithPublicEndpointFn runs with every request, and allows conditionally
// configuring the Handler to link the span with an incoming span context. If
// this option is not provided or returns false, then the association is a
// child association instead of a link.
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/github.com/gorilla/mux/otelmux/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func WithPublicEndpoint() Option {
})
}

// WithPublicEndpointFn runs with every request, and allows conditionnally
// WithPublicEndpointFn runs with every request, and allows conditionally
// configuring the Handler to link the span with an incoming span context. If
// this option is not provided or returns false, then the association is a
// child association instead of a link.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// Package otelmongo instruments go.mongodb.org/mongo-driver/mongo.
//
// This package is compatable with v0.2.0 of
// This package is compatible with v0.2.0 of
// go.mongodb.org/mongo-driver/mongo.
//
// `NewMonitor` will return an event.CommandMonitor which is used to trace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (m *monitor) Finished(evt *event.CommandFinishedEvent, err error) {
span.End()
}

// TODO sanitize values where possible, then reenable `db.statement` span attributes default.
// TODO sanitize values where possible, then re-enable `db.statement` span attributes default.
// TODO limit maximum size.
func sanitizeCommand(command bson.Raw) string {
b, _ := bson.MarshalExtJSON(command, false, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
type InterceptorFilter func(*InterceptorInfo) bool

// Filter is a predicate used to determine whether a given request in
// should be instrumented by the attatched RPC tag info.
// should be instrumented by the attached RPC tag info.
// A Filter must return true if the request should be instrumented.
type Filter func(*stats.RPCTagInfo) bool

Expand Down
2 changes: 1 addition & 1 deletion instrumentation/net/http/otelhttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// DefaultClient is the default Client and is used by Get, Head, Post and PostForm.
// Please be careful of intitialization order - for example, if you change
// Please be careful of initialization order - for example, if you change
// the global propagator, the DefaultClient might still be using the old one.
var DefaultClient = &http.Client{Transport: NewTransport(http.DefaultTransport)}

Expand Down
2 changes: 1 addition & 1 deletion instrumentation/net/http/otelhttp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func WithPublicEndpoint() Option {
})
}

// WithPublicEndpointFn runs with every request, and allows conditionnally
// WithPublicEndpointFn runs with every request, and allows conditionally
// configuring the Handler to link the span with an incoming span context. If
// this option is not provided or returns false, then the association is a
// child association instead of a link.
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type runtime struct {

// config contains optional settings for reporting runtime metrics.
type config struct {
// MinimumReadMemStatsInterval sets the mininum interval
// MinimumReadMemStatsInterval sets the minimum interval
// between calls to runtime.ReadMemStats(). Negative values
// are ignored.
MinimumReadMemStatsInterval time.Duration
Expand Down
2 changes: 1 addition & 1 deletion propagators/autoprop/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestRegistryConcurrentSafe(t *testing.T) {
assert.NotPanics(t, func() {
v, ok := r.load(propName)
assert.True(t, ok, "missing propagator in registry")
assert.Equal(t, noop, v, "wrong propagator retuned")
assert.Equal(t, noop, v, "wrong propagator returned")
})
}()

Expand Down
2 changes: 1 addition & 1 deletion propagators/b3/b3_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ var injectInvalidHeaderGenerator = []injectTest{
var injectInvalidHeader []injectTest

func init() {
// Preform a test for each invalid injectTest with all combinations of
// Perform a test for each invalid injectTest with all combinations of
// encoding values.
injectInvalidHeader = make([]injectTest, 0, len(injectInvalidHeaderGenerator)*4)
allHeaders := []string{
Expand Down
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"matchManagers": ["gomod"],
"matchDepTypes": ["indirect"],
"enabled": false
},
{
"matchManagers": ["pip"],
"packageNames": ["codespell"],
"enabled": true
}
]
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
codespell==2.3.0
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion samplers/aws/xray/internal/reservoir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestResetQuotaUsageRotation(t *testing.T) {
nowTime: 1500000001,
}

// take() should be true since ununsed quota is available
// take() should be true since unused quota is available
assert.True(t, r.take(clock.now(), false, 1.0))
}

Expand Down