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

ci: add script to open pr to update bazel builder version #92348

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

healthy-pod
Copy link
Contributor

Release note: None
Part of: CRDB-11061

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@healthy-pod healthy-pod force-pushed the open-pr branch 24 times, most recently from d5d08c5 to c7a7417 Compare November 24, 2022 01:42
@healthy-pod healthy-pod marked this pull request as ready for review November 24, 2022 01:48
@healthy-pod healthy-pod requested a review from a team as a code owner November 24, 2022 01:48
@healthy-pod
Copy link
Contributor Author

Corresponding build config: Open New Bazel Builder Image PR

Copy link
Member

@rail rail left a comment

Choose a reason for hiding this comment

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

In overall it looks great! Just a teeny fix.

configure_git_ssh_key
mv .cockroach-teamcity-key /tmp/.cockroach-teamcity-key

git_ssh clone "ssh://[email protected]/cockroachdb/cockroach.git" "/tmp/cockroach" && cd "/tmp/cockroach"
Copy link
Member

Choose a reason for hiding this comment

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

Can you use a temp directory (mktemp -d) instead of hardcoded /tmp/cocroach for a few reasons:

  • harder to predict (and attack)
  • no need to rely on absence of the directory - you would need to make sure it doesn't exist or empty before cloning - otherwise git fails.

Also, can you rm -rf that directory, so we clean after it's done. Maybe add all needed cleanup command to a function and trap it? But we should be careful using trap - IIRC there is one already sourced, and only one can be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the clone and key to a temp dir which gets cleaned at the end

wget -O /tmp/gh.tar.gz https://github.com/cli/cli/releases/download/v2.13.0/gh_2.13.0_linux_amd64.tar.gz
echo "9e833e02428cd49e0af73bc7dc4cafa329fe3ecba1bfe92f0859bf5b11916401 /tmp/gh.tar.gz" | sha256sum -c -
tar --strip-components 1 -xf /tmp/gh.tar.gz
export PATH=$PWD/bin:$PATH
Copy link
Member

Choose a reason for hiding this comment

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

Or you use the absolute path when you call gh.

Copy link
Member

Choose a reason for hiding this comment

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

One more nit. Can you move the gh setup part up, so we fail early if we cannot install it for some reason.

git config --global user.email "[email protected]"
git config --global user.name "cockroach-teamcity"
configure_git_ssh_key
mv .cockroach-teamcity-key /tmp/.cockroach-teamcity-key
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to move the key under /tmp? I don't think it'll be cleaned up in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it to the temp dir along with the clone

Copy link
Member

@rail rail left a comment

Choose a reason for hiding this comment

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

Sorry for missing some pieces in the first review. This is almost ready. :)

wget -O /tmp/gh.tar.gz https://github.com/cli/cli/releases/download/v2.13.0/gh_2.13.0_linux_amd64.tar.gz
echo "9e833e02428cd49e0af73bc7dc4cafa329fe3ecba1bfe92f0859bf5b11916401 /tmp/gh.tar.gz" | sha256sum -c -
tar --strip-components 1 -xf /tmp/gh.tar.gz
export PATH=$PWD/bin:$PATH
Copy link
Member

Choose a reason for hiding this comment

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

One more nit. Can you move the gh setup part up, so we fail early if we cannot install it for some reason.


git_ssh() {
# $@ passes all arguments to this function to the command
GIT_SSH_COMMAND="ssh -i /tmp/.cockroach-teamcity-key" git "$@"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this command is going to work, because the key lives in a different spot now.

I have a suggestion. How about using GIT_SSH_COMMAND="ssh -i $dir/.cockroach-teamcity-key" git "$@" instead. This way you don't need to move the key anywhere.

git config --global user.name "cockroach-teamcity"
configure_git_ssh_key
WORKDIR="$(mktemp -d ./workdir.XXXXXX)"
mv .cockroach-teamcity-key $WORKDIR/.cockroach-teamcity-key
Copy link
Member

Choose a reason for hiding this comment

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

If the suggestions above make sense, you can get rid of the mv line.

Release note: None
Part of: CRDB-11061
Copy link
Member

@rail rail left a comment

Choose a reason for hiding this comment

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

LGTM, :shipit:

@healthy-pod
Copy link
Contributor Author

TFTR!

bors r=rail

@craig craig bot merged commit edc6fda into cockroachdb:master Nov 29, 2022
@craig
Copy link
Contributor

craig bot commented Nov 29, 2022

Build succeeded:

@healthy-pod healthy-pod deleted the open-pr branch December 1, 2022 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants