Skip to content

chore: NOOP housekeeping of scripts/*.sh files#4042

Merged
dd-mergequeue[bot] merged 5 commits into
DataDog:mainfrom
mdb:mdb/shell-script-cleanup
Oct 14, 2025
Merged

chore: NOOP housekeeping of scripts/*.sh files#4042
dd-mergequeue[bot] merged 5 commits into
DataDog:mainfrom
mdb:mdb/shell-script-cleanup

Conversation

@mdb

@mdb mdb commented Oct 8, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

  • standardize scripts/*.sh on 2 space indentation
  • double quote various shell script vars to prevent globbing and wordsplitting and to satisfy shellcheck complaints

Thanks!

Motivation

  • Previously, these scripts had a mix of tabs/spaces, with inconsistent indentation. While not a functional problem, this made for kind of an icky developer experience.
  • Previously, these scripts were vulnerable to globbing and wordsplitting (plus, the shellcheck complaints create noise for contributors whose editors are integrated with shellcheck)

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

@mdb
mdb requested a review from a team as a code owner October 8, 2025 15:22

@genesor genesor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for handling this.

Comment thread scripts/ci_test_core.sh Outdated
export GOEXPERIMENT=synctest # TODO: remove once go1.25 is the minimum supported version

gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v -race -coverprofile=coverage.txt -covermode=atomic
gotestsum --junitfile "${TEST_RESULTS}/gotestsum-report.xml" -- "$PACKAGE_NAMES" -v -race -coverprofile=coverage.txt -covermode=atomic

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdb Quoting this leads to the following error:

malformed import path "github.com/DataDog/dd-trace-go/v2/appsec\ngithub.com/DataDog/dd-trace-go/v2/appsec/events\ngithub.com/DataDog/dd-trace-go/v2/civisibility\ngithub.com/DataDog/dd-trace-go/v2/contrib\ngithub.com/DataDog/dd-trace-go/v2/datastreams\ngithub.com/DataDog/dd-trace-go/v2/datastreams/options\ngithub.com/DataDog/dd-trace-go/v2/ddtrace\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/baggage\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/ext\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/internal\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/internal/tracerstats\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/mocktracer\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry\ngithub.com/DataDog/dd-trace-go/v2/ddtrace/tracer\ngithub.com/DataDog/dd-trace-go/v2/instrumentation...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darccio Ah, good call! I think the gotestsum invocations expect space-delimited package names. I've removed the double quotes encapsulating $PACKAGE_NAMES (and similar variables) in all the scripts/*.sh gotestsum invocations.

@mdb
mdb force-pushed the mdb/shell-script-cleanup branch from 4cb3103 to 26548b8 Compare October 9, 2025 16:17
@mdb
mdb requested a review from darccio October 9, 2025 16:20

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mdb added 2 commits October 10, 2025 17:00
This is a NOOP cosmetic change standardizing all `scripts/*.sh` shell
scripts on 2 space indentation.

Previously, these scripts had a mix of tabs/spaces, with inconsistent
indentation. While not a functional problem, this made for kind of an icky
developer exprience.

Signed-off-by: Mike Ball <[email protected]>
This is NOOP housekeeping. By double quoting shell variables:

- we protect against globbing and wordsplitting
- we satisfy common [shellcheck](https://www.shellcheck.net/) complaints against
  these scripts (this is particularly meaningful for contributors whose
  editors are integrated with `shellcheck`; for those contributors, the
  `shellcheck` complaints are noisy and impact developer experience)

Signed-off-by: Mike Ball <[email protected]>
@mdb
mdb force-pushed the mdb/shell-script-cleanup branch from 3463f5e to dbf4892 Compare October 10, 2025 21:00
@mdb

mdb commented Oct 11, 2025

Copy link
Copy Markdown
Contributor Author

@kakkoyun Thanks for the review!

We have https://github.com/DataDog/dd-trace-go/blob/main/scripts/format.sh#L66 for formatting. Do you think we can make sure we have correct rules for that step for making sure we have a unified format?

I think that's a great idea, though introduces a bit of scope creep beyond this PR's immediate intent. Is that something you'd like to see as part of this PR?

We should also add the shellcheck to our CI either as part of https://github.com/DataDog/dd-trace-go/blob/main/scripts/lint.sh or the https://github.com/DataDog/dd-trace-go/blob/main/Makefile

That's a great idea too. Is that something you feel should be part of this PR? If it influences your view: there's quite a few additional shellcheck complaints with the scripts/*.sh files; this PR merely addresses the low hanging fruit task of double quoting variables to prevent globbing/wordsplitting (in addition to replacing tabs w/ spaces)...and those other shellcheck complaints are a bit thornier to address (although, they could be allowlisted for now).

Update: I went ahead and added a step to run shellcheck during make lint; I added shellcheck disable= comments to all other pre-existing violations to avoid scope creep in this PR. Is that reasonable?

PS - I believe I addressed the failures previously seen in https://github.com/DataDog/dd-trace-go/actions/runs/18350929657 😄

@mdb
mdb requested a review from kakkoyun October 11, 2025 12:27
@kakkoyun

Copy link
Copy Markdown
Member

@kakkoyun Thanks for the review!

We have main/scripts/format.sh#L66 for formatting. Do you think we can make sure we have correct rules for that step for making sure we have a unified format?

I think that's a great idea, though introduces a bit of scope creep beyond this PR's immediate intent. Is that something you'd like to see as part of this PR?

We should also add the shellcheck to our CI either as part of main/scripts/lint.sh or the main/Makefile

That's a great idea too. Is that something you feel should be part of this PR? If it influences your view: there's quite a few additional shellcheck complaints with the scripts/*.sh files; this PR merely addresses the low hanging fruit task of double quoting variables to prevent globbing/wordsplitting (in addition to replacing tabs w/ spaces)...and those other shellcheck complaints are a bit thornier to address (although, they could be allowlisted for now).

Update: I went ahead and added a step to run shellcheck during make lint; I added shellcheck disable= comments to all other pre-existing violations to avoid scope creep in this PR. Is that reasonable?

PS - I believe I addressed the failures previously seen in DataDog/dd-trace-go/actions/runs/18350929657 😄

Since you are not changing anything functional, further changes should be okay.
The problem with introducing formatting without a CI to enforce them, someone will change it in subsequent PRs and it will slip through PRs. We should have automation and checks to enforce the changes.

I really appreciate you adding the shellcheck, let's make sure we keep with the standards down the line.

@kakkoyun

Copy link
Copy Markdown
Member

@mdb Let me know if you need help to push this PR through.

- ensure `make lint` runs [shellcheck](https://www.shellcheck.net/) against all `scripts/*.sh`
  files
- add `shellcheck disable=` directives for pre-existing shellcheck
  violations. Ideally, these are addressed over time and the `shellcheck
  disable` directives are removed. For now, they're left in place to
  avoid scope creep.

Signed-off-by: Mike Ball <[email protected]>
@mdb
mdb force-pushed the mdb/shell-script-cleanup branch from f31b3c2 to 66efab6 Compare October 13, 2025 17:31
@mdb

mdb commented Oct 14, 2025

Copy link
Copy Markdown
Contributor Author

Since you are not changing anything functional, further changes should be okay.

@kakkoyun Is that to say you would indeed like me to make scripts/format.sh enforce shell script formatting as part of this PR? Or shall I add that as a follow-up PR?

@mdb Let me know if you need help to push this PR through.

@kakkoyun Thanks! Would you mind re-running the GH Actions? I think I've pushed a change (again) addressing the last static check failures.

@kakkoyun

Copy link
Copy Markdown
Member

@kakkoyun Is that to say you would indeed like me to make scripts/format.sh enforce shell script formatting as part of this PR? Or shall I add that as a follow-up PR?

Yes, let's have it as part of this PR. Sorry for the confusion.

mdb added 2 commits October 14, 2025 08:57
`make format` now enforces consistent shell script formatting generally
inline with what's reflected in the repo.

This also commits the results of `make format` against the `scripts/*.sh` files

Signed-off-by: Mike Ball <[email protected]>
- add a `make format/shell` Make target for formatting shell scripts
- add a `check-shell-scripts` job to check shell scripts' formatting in CI during
  the Static Checks workflow

Signed-off-by: Mike Ball <[email protected]>
@mdb

mdb commented Oct 14, 2025

Copy link
Copy Markdown
Contributor Author

Yes, let's have it as part of this PR. Sorry for the confusion.

@kakkoyun No problem; I took a stab at adding the check to the "Static Checks" GH Actions workflow. How's that look?

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🫶

@kakkoyun

Copy link
Copy Markdown
Member

/merge

@dd-devflow-routing-codex

dd-devflow-routing-codex Bot commented Oct 14, 2025

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2025-10-14 13:32:59 UTC ℹ️ Start processing command /merge


2025-10-14 13:33:07 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-10-14 13:34:30 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 18m (p90).


2025-10-14 13:49:29 UTC ℹ️ MergeQueue: This merge request was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants