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

Misc. operability tweaks for clang-format #5422

Merged
merged 6 commits into from
Jan 10, 2025
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
2 changes: 1 addition & 1 deletion scripts/ci/check_formatting_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set -e pipefail
ls -la
sudo ./scripts/install-clangformat.sh

src=$GITHUB_WORKSPACE
src=$(dirname $0)/../..
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turns out CI invokes this with source not with bash, and when you source a script, its $0 is -bash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$ cat foo
echo '$0' is $0
echo '$*' is $*
$ bash ./foo 1 2 3
$0 is ./foo
$* is 1 2 3
$ bash $(pwd)/foo 1 2 3
$0 is /Users/kerl/git/TileDB-Inc/TileDB/foo
$* is 1 2 3
$ source foo 1 2 3
$0 is -bash
$* is 1 2 3
$ source $(pwd)/foo 1 2 3
$0 is -bash
$* is 1 2 3

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should fix the workflow, it doesn't make much sense to run this script by sourcing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤷

I saw somewhen/somewhere some comments about sourcing in GH YAML; maybe a recommended best practice? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally I'm happy with trying the experimental method -- I can modify the calling YAML to bash the script than source the script ...

Copy link
Member

Choose a reason for hiding this comment

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

No idea. 😅

My intuition is that sourcing should be done only in special circumstances and when a script is less of a "function" and more of an "environment initializer".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@teo-tsirpanis oh I 100% agree, and have for years, even before TileDB. The only good reason for source to me is something that needs to set environment variables, aliases, etc. for the parent process.

I'm simply wondering if there's some other good reason, within this particular GHA context, which the person who keystroked source into GHA YAML didn't bother to explain at the time, leaving you & me to wonder. But again, I'm happy to find that out by experiment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For whatever the reason (good or bad) whenever this was written, there's a lot of it:

kerl@arvad[prod][kerl/current-domain-error-message][TileDB]$ rg ' source ' .github/workflows/*ml
.github/workflows/unit-test-runs.yml
88:          source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh

.github/workflows/test-cloud-e2e.yml
57:          source $GITHUB_WORKSPACE/scripts/ci/bootstrap_libtiledb.sh
68:          source $GITHUB_WORKSPACE/scripts/ci/build_libtiledb.sh
106:          source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh

.github/workflows/release.yml
136:          source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh

.github/workflows/check-formatting.yml
41:          source $GITHUB_WORKSPACE/scripts/ci/check_formatting_linux.sh

.github/workflows/build-ubuntu20.04-backwards-compatibility.yml
41:          source $GITHUB_WORKSPACE/scripts/ci/bootstrap_libtiledb.sh
42:          source $GITHUB_WORKSPACE/scripts/ci/build_libtiledb.sh
122:          source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh

.github/workflows/ci-linux_mac.yml
157:          source $GITHUB_WORKSPACE/scripts/ci/bootstrap_libtiledb.sh
168:          source $GITHUB_WORKSPACE/scripts/ci/build_libtiledb.sh
189:          source $GITHUB_WORKSPACE/scripts/ci/posix/build-services-start.sh
211:          source $GITHUB_WORKSPACE/scripts/ci/posix/build-services-stop.sh
221:          # It relies on finding its source directory.
227:          source $GITHUB_WORKSPACE/scripts/ci/build_benchmarks.sh
274:          source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh

.github/workflows/build-rtools40.yml
66:          source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh

.github/workflows/build-windows.yml
432:          source $GITHUB_WORKSPACE/scripts/ci/print_logs.sh

cd $src

$src/scripts/run-clang-format.sh $src clang-format-17 0
4 changes: 4 additions & 0 deletions scripts/install-clangformat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ install_clang_format() {

run() {
install_clang_format

echo
echo "clang-format --version" $(clang-format --version)
echo
}

run
Loading