changelog.py to retrieve best token

s3fs fix

changelog.py to use base branch to filter prs
This commit is contained in:
Max K 2024-07-31 16:22:43 +02:00
parent 9362d1a566
commit c534cd5bc2
3 changed files with 33 additions and 6 deletions

View File

@ -81,7 +81,7 @@ jobs:
docker run -u "${UID}:${GID}" -e PYTHONUNBUFFERED=1 -e CI=1 --network=host \
--volume=".:/ClickHouse" clickhouse/style-test \
/ClickHouse/tests/ci/changelog.py -v --debug-helpers \
--gh-user-or-token=${{secrets.ROBOT_CLICKHOUSE_COMMIT_TOKEN}} --jobs=5 \
--jobs=5 \
--output="/ClickHouse/docs/changelogs/${{ env.RELEASE_TAG }}.md" ${{ env.RELEASE_TAG }}
git add ./docs/changelogs/${{ env.RELEASE_TAG }}.md
echo "Generate Security"
@ -111,11 +111,11 @@ jobs:
python3 ./tests/ci/create_release.py --set-progress-completed
git reset --hard HEAD
git checkout "$GITHUB_REF_NAME"
- name: Create GH Release
shell: bash
if: ${{ inputs.type == 'patch' }}
run: |
python3 ./tests/ci/create_release.py --create-gh-release ${{ inputs.dry-run == true && '--dry-run' || '' }}
# - name: Create GH Release
# shell: bash
# if: ${{ inputs.type == 'patch' }}
# run: |
# python3 ./tests/ci/create_release.py --create-gh-release ${{ inputs.dry-run == true && '--dry-run' || '' }}
- name: Export TGZ Packages
if: ${{ inputs.type == 'patch' }}
shell: bash

View File

@ -52,6 +52,10 @@ class R2MountPoint:
if self.CACHE_ENABLED
else ""
)
if not dry_run:
self.aux_mount_options += (
"-o passwd_file /home/ubuntu/.passwd-s3fs_packages "
)
# without -o nomultipart there are errors like "Error 5 writing to /home/ubuntu/***.deb: Input/output error"
self.mount_cmd = f"s3fs {self.bucket_name} {self.MOUNT_POINT} -o url={self.API_ENDPOINT} -o use_path_request_style -o umask=0000 -o nomultipart -o logfile={self.LOG_FILE} {self.aux_mount_options}"
elif self.app == MountPointApp.RCLONE:

View File

@ -19,6 +19,8 @@ from env_helper import TEMP_PATH
from git_helper import git_runner, is_shallow
from github_helper import GitHub, PullRequest, PullRequests, Repository
from s3_helper import S3Helper
from get_robot_token import get_best_robot_token
from ci_utils import Shell
from version_helper import (
FILE_WITH_VERSION_PATH,
get_abs_path,
@ -171,6 +173,7 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--gh-user-or-token",
help="user name or GH token to authenticate",
default=get_best_robot_token(),
)
parser.add_argument(
"--gh-password",
@ -397,6 +400,15 @@ def get_year(prs: PullRequests) -> int:
return max(pr.created_at.year for pr in prs)
def get_branch_by_tag(tag: str) -> Optional[str]:
tag.removeprefix("v")
versions = tag.split(".")
if len(versions) < 3:
print("ERROR: Can't get branch by tag")
return None
return f"{versions[0]}.{versions[1]}"
def main():
log_levels = [logging.WARN, logging.INFO, logging.DEBUG]
args = parse_args()
@ -446,6 +458,17 @@ def main():
gh_cache = GitHubCache(gh.cache_path, temp_path, S3Helper())
gh_cache.download()
query = f"type:pr repo:{args.repo} is:merged"
branch = get_branch_by_tag(TO_REF)
if branch and Shell.check(f"git show-ref --quiet {branch}"):
try:
if int(branch.split(".")[-1]) > 1:
query += f" base:{branch}"
print(f"NOTE: will use base branch to filter PRs {branch}")
except ValueError:
print(f"ERROR: cannot get minor version from branch {branch} - pass")
pass
else:
print(f"ERROR: invalid branch {branch} - pass")
prs = gh.get_pulls_from_search(
query=query, merged=merged, sort="created", progress_func=tqdm.tqdm
)