-
Notifications
You must be signed in to change notification settings - Fork 295
Support overriding the clickhouse binary with a PR build #988
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
Open
alexey-milovidov
wants to merge
2
commits into
main
Choose a base branch
from
clickhouse-pr-binary-override
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+125
−9
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,5 @@ | |
| set -e | ||
|
|
||
| if [ ! -x ./clickhouse ]; then | ||
| curl https://clickhouse.com/ | sh | ||
| ../lib/download-clickhouse | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,5 @@ | |
| set -e | ||
|
|
||
| if [ ! -x ./clickhouse ]; then | ||
| curl https://clickhouse.com/ | sh | ||
| ../lib/download-clickhouse | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/bin/bash | ||
| # Put the `clickhouse` universal binary in the current directory. | ||
| # | ||
| # Default: download the latest stable build from clickhouse.com — exactly what | ||
| # every clickhouse* install script did inline (`curl https://clickhouse.com/ | | ||
| # sh`) before this helper existed. | ||
| # | ||
| # Override: when the `clickhouse_pr` environment variable names a | ||
| # ClickHouse/ClickHouse pull-request number, fetch that PR's CI release build | ||
| # instead of the stable one. This is how an operator benchmarks an unreleased | ||
| # binary straight from a PR: | ||
| # | ||
| # clickhouse_pr=81944 system=clickhouse ./run-benchmark.sh | ||
| # | ||
| # `clickhouse_pr` is set on the operator side, threaded to the VM through | ||
| # cloud-init, and consumed ONLY here — so only the clickhouse* systems react to | ||
| # it; every other system ignores it. | ||
| # | ||
| # "The binary from the PR" is resolved as: the newest commit in the PR whose | ||
| # release-build CI job for THIS machine's architecture finished successfully, | ||
| # then the raw self-extracting binary that job uploaded to S3. Walking from the | ||
| # newest commit backwards (rather than pinning the tip) means a tip commit whose | ||
| # build is still running, failed, or was skipped (e.g. a docs-only commit) falls | ||
| # back to the last commit that does have a finished build. | ||
| set -euo pipefail | ||
|
|
||
| # No PR requested: the default path. | ||
| if [ -z "${clickhouse_pr:-}" ]; then | ||
| curl https://clickhouse.com/ | sh | ||
| exit 0 | ||
| fi | ||
|
|
||
| pr="$clickhouse_pr" | ||
| api="https://api.github.com/repos/ClickHouse/ClickHouse" | ||
|
|
||
| # ClickHouse names its release builds by short arch (amd / arm). Map this | ||
| # machine's architecture onto that; reject targets that have no release build. | ||
| case "$(uname -m)" in | ||
| x86_64 | amd64) arch=amd ;; | ||
| aarch64 | arm64) arch=arm ;; | ||
| *) | ||
| echo "clickhouse_pr: no release build for architecture '$(uname -m)'" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| check_name="Build (${arch}_release)" # CI check-run name for the release build | ||
| build_dir="build_${arch}_release" # S3 folder that build uploads into | ||
|
|
||
| # GitHub's anonymous API limit is 60 requests/hour; if the operator exported a | ||
| # GITHUB_TOKEN, use it to lift the limit (helps when many machines launch at | ||
| # once and each makes a handful of calls). | ||
| gh() { | ||
| if [ -n "${GITHUB_TOKEN:-}" ]; then | ||
| curl -fsSL -H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
| -H "Accept: application/vnd.github+json" "$@" | ||
| else | ||
| curl -fsSL -H "Accept: application/vnd.github+json" "$@" | ||
| fi | ||
| } | ||
|
|
||
| # Candidate commits, newest first: the PR head (the usual answer) followed by | ||
| # the rest of the PR's commits newest->oldest as a fallback. The PR-commits | ||
| # endpoint returns oldest->newest, so `tac` flips it; awk drops blanks and the | ||
| # duplicate head. (For a PR with >100 commits only the first page's commits act | ||
| # as fallback, but the head — checked first — covers the normal case.) | ||
| head_sha=$(gh "${api}/pulls/${pr}" | jq -r '.head.sha') | ||
| rest=$(gh "${api}/pulls/${pr}/commits?per_page=100" | jq -r '.[].sha' | tac) | ||
| candidates=$(printf '%s\n%s\n' "$head_sha" "$rest" | awk 'NF && !seen[$0]++') | ||
|
|
||
| echo "clickhouse_pr=${pr}: looking for a successful '${check_name}' build..." >&2 | ||
| sha="" | ||
| while IFS= read -r commit; do | ||
| [ -z "$commit" ] && continue | ||
| # Filter server-side by check name so we don't have to page through the | ||
| # ~170 check-runs a ClickHouse commit accumulates. | ||
| if gh -G --data-urlencode "check_name=${check_name}" \ | ||
| "${api}/commits/${commit}/check-runs" \ | ||
| | jq -e 'any(.check_runs[]; .conclusion == "success")' >/dev/null; then | ||
| sha="$commit" | ||
| break | ||
| fi | ||
| done <<< "$candidates" | ||
|
|
||
| if [ -z "$sha" ]; then | ||
| echo "clickhouse_pr=${pr}: found no commit with a successful '${check_name}'." >&2 | ||
| echo "clickhouse_pr=${pr}: is CI still running, or did the release build fail?" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| url="https://clickhouse-builds.s3.amazonaws.com/PRs/${pr}/${sha}/${build_dir}/clickhouse" | ||
| echo "clickhouse_pr=${pr}: commit ${sha}" >&2 | ||
| echo "clickhouse_pr=${pr}: downloading ${url}" >&2 | ||
| wget --continue --progress=dot:giga "$url" -O clickhouse | ||
| chmod +x clickhouse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's embrace the simplicity of the default install.
So it should remain
curl https://clickhouse.com/ | shand be exposed here.Add a non-standard setup only as a special case (a single if condition that invokes a script). Name the script to emphasize that it is non-standard.
Reason: no one should ever think that installing ClickHouse is not easy.