-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Script to verify example after new release. #579
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits.
verify_examples.sh
Outdated
mkdir -p $DIR_TMP | ||
|
||
printf "Copy examples to ${DIR_TMP}\n" | ||
rsync -r ./example ${DIR_TMP} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something in rsync -r
that cp -a
wouldn't do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was using cp -p and that didn't work on Mac. Didn't know '-a' was an option.
Changed it to cp -a
.
verify_examples.sh
Outdated
(cd "${DIR_TMP}/${dir}" && \ | ||
sed -i .bak "s/module go.opentelemetry.io\/otel/module oteltmp/" go.mod && \ | ||
sed -i .bak "s/^.*=\>.*$//" go.mod && \ | ||
go mod tidy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that maybe we should avoid tinkering with go.mod like that and use go mod edit
for it, like:
(cd "${dir}"
# replaces is ("mod1" "mod2" …)
replaces=($(go mod edit -json | jq '.Replace[].Old.Path'))
# strip double quotes
replaces=("${replaces[@]%\"}")
replaces=("${replaces[@]#\"}")
# make an array (-dropreplace=mod1 -dropreplace=mod2 …)
dropreplaces=("${replaces[@]/#/-dropreplace=}")
go mod edit -module "oteltmp/${dir}" "${dropreplaces[@]}"
go mod tidy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point and nice suggestion. Learning few tricks as well..
verify_examples.sh
Outdated
# directories that contain go.mod files. | ||
# | ||
printf "Build examples:\n" | ||
EXAMPLES=`./get_main_pkgs.sh ./example` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXAMPLES=`./get_main_pkgs.sh ./example` | |
EXAMPLES=$(./get_main_pkgs.sh ./example) |
verify_examples.sh
Outdated
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set -euo pipefail
maybe could be a better safety net. -u
is for bailing out on undefined variables (like in rm -rf ${undefined}/*
;) ). -o pipefail
for bailing out in scenario like failing_command | process_stdin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
verify_examples.sh
Outdated
@@ -0,0 +1,64 @@ | |||
#!/bin/sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say just use bash and let's not pretend we care to be ran under every possible implementation of POSIX shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
verify_examples.sh
Outdated
@@ -0,0 +1,64 @@ | |||
#!/bin/sh | |||
# Copyright 2020, OpenTelemetry Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Copyright 2020, OpenTelemetry Authors | |
# Copyright The OpenTelemetry Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
verify_examples.sh
Outdated
printf "$(git log -1)" | ||
printf "\n\nError: HEAD is not pointing to a tagged version" | ||
fi | ||
exit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks leftover from debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops!
fixed now.
This script verifies that examples build outside of the otel repo.
This should be run after every release.