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

[work in progress] Validate package names #12957

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all 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
36 changes: 36 additions & 0 deletions .github/scripts/check-package-names.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash -e

# shellcheck disable=SC2001

# find instrumentation -type d -name "*-common*"

# TODO javaagent modules?
#for file in $(find instrumentation/aws-sdk -name "*.java" | grep library/src/main/java | sed 's#/[^/]*$##' | sort -u); do
for dir in $(cat out); do

module_name=$(echo "$dir" | sed 's#.*/\([^/]*\)/library/src/main/java/.*#\1#')

if [[ ! "$module_name" =~ [0-9]$ ]]; then
echo "module name doesn't have a base version: $dir"
exit 1
fi

simple_module_name=$(echo "$module_name" | sed 's/-[0-9.]*$//' | sed 's/-//g')
base_version=$(echo "$module_name" | sed 's/.*-\([0-9.]*\)$/\1/' | sed 's/\./_/')

echo $base_version

expected_package_name="io/opentelemetry/instrumentation/$simple_module_name/v$base_version"

package_name=$(echo "$dir" | sed 's#.*/src/main/java/##')

# deal with differences like module name elasticsearch-rest and package name elasticsearch.rest
expected_package_name_normalized=$(echo "$expected_package_name" | sed 's#/##g')
package_name_normalized=$(echo "$package_name" | sed 's#/##g')

if [[ "$package_name_normalized" != "$expected_package_name_normalized"* ]]; then
echo "ERROR: $dir"
exit 1
fi

done
Loading