-
Notifications
You must be signed in to change notification settings - Fork 39
Cleanup #1008
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
base: main
Are you sure you want to change the base?
Cleanup #1008
Changes from all commits
6df90d7
4850fc3
7c8d43c
86437ce
1a1ae38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| {% include "header.j2" %} | ||
|
|
||
| .PHONY: format | ||
| format: | ||
| {%- if black %} | ||
| black . | ||
| {%- else %} | ||
| @echo "No formating configured in this repository." | ||
| {%- endif %} | ||
|
|
||
| .PHONY: lint | ||
| lint: | ||
| yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows | ||
| bump-my-version bump --dry-run release | ||
| {%- if black %} | ||
| black --check --diff . | ||
| {%- endif %} | ||
| {%- if flake8 %} | ||
| flake8 | ||
| {%- endif %} | ||
| {%- if check_manifest %} | ||
| check-manifest | ||
| {%- endif %} | ||
| {%- if lint_requirements %} | ||
| python .ci/scripts/check_requirements.py | ||
| {%- endif %} | ||
| {%- if check_stray_pulpcore_imports %} | ||
| sh .ci/scripts/check_pulpcore_imports.sh | ||
| {%- endif %} | ||
| {%- if check_gettext %} | ||
| sh .ci/scripts/check_gettext.sh | ||
| {%- endif %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,9 @@ | |
| import argparse | ||
| import re | ||
| import os | ||
| import sys | ||
| import tomllib | ||
| import typing as t | ||
| from pathlib import Path | ||
|
|
||
| import yaml | ||
|
|
@@ -23,7 +25,7 @@ | |
| Z_CHANGELOG_EXTS = [".bugfix", ".misc"] | ||
|
|
||
|
|
||
| def options(): | ||
| def options() -> argparse.Namespace: | ||
| """Check which branches need a release.""" | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
|
|
@@ -42,13 +44,13 @@ def options(): | |
| return parser.parse_args() | ||
|
|
||
|
|
||
| def template_config(): | ||
| def template_config() -> dict[str, t.Any]: | ||
| # Assume this script lies in .ci/scripts | ||
| path = Path(__file__).absolute().parent.parent.parent / "template_config.yml" | ||
| return yaml.safe_load(path.read_text()) | ||
|
|
||
|
|
||
| def current_version(repo, commitish): | ||
| def current_version(repo: Repo, commitish: str) -> Version: | ||
| try: | ||
| pyproject_toml = tomllib.loads(repo.git.show(f"{commitish}:pyproject.toml")) | ||
| try: | ||
|
|
@@ -62,7 +64,7 @@ def current_version(repo, commitish): | |
| return Version(current_version) | ||
|
|
||
|
|
||
| def check_pyproject_dependencies(repo, from_commit, to_commit): | ||
| def check_pyproject_dependencies(repo: Repo, from_commit:str, to_commit:str) -> list[str]: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why black didn't complain about that |
||
| try: | ||
| new_pyproject = tomllib.loads(repo.git.show(f"{to_commit}:pyproject.toml")) | ||
| try: | ||
|
|
@@ -83,8 +85,8 @@ def check_pyproject_dependencies(repo, from_commit, to_commit): | |
| return ["pyproject.toml changed somehow (PLEASE check if dependencies are affected)."] | ||
|
|
||
|
|
||
| def main(options, template_config): | ||
| DEFAULT_BRANCH = template_config["plugin_default_branch"] | ||
| def main(options: argparse.Namespace, template_config: dict[str, t.Any]) -> int: | ||
| DEFAULT_BRANCH: str = template_config["plugin_default_branch"] | ||
|
|
||
| repo = Repo() | ||
|
|
||
|
|
@@ -97,7 +99,7 @@ def main(options, template_config): | |
|
|
||
| # Warning: This will not work if branch names contain "/" but we don't really care here. | ||
| heads = [h.split("/")[-1] for h in repo.git.branch("--remote").split("\n")] | ||
| available_branches = [h for h in heads if re.search(RELEASE_BRANCH_REGEX, h)] | ||
| available_branches = [h for h in heads if re.fullmatch(RELEASE_BRANCH_REGEX, h)] | ||
| available_branches.sort(key=lambda ver: Version(ver)) | ||
| available_branches.append(DEFAULT_BRANCH) | ||
|
|
||
|
|
@@ -114,7 +116,10 @@ def main(options, template_config): | |
|
|
||
| if diff := branches - set(available_branches): | ||
| print(f"Supplied branches contains non-existent branches! {diff}") | ||
| exit(1) | ||
| return 1 | ||
|
|
||
| branches = [branch for branch in available_branches if branch in branches] | ||
| branches.reverse() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverse doesn't sort the branches. Maybe |
||
|
|
||
| print(f"Checking for releases on branches: {branches}") | ||
|
|
||
|
|
@@ -179,6 +184,8 @@ def main(options, template_config): | |
| if len(releases) == 0: | ||
| print("No new releases to perform.") | ||
|
|
||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main(options(), template_config()) | ||
| sys.exit(main(options(), template_config())) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,11 +53,20 @@ jobs: | |
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@v6 | ||
| id: "create_pr_changelog" | ||
| with: | ||
| token: {{ '${{ secrets.RELEASE_TOKEN }}' }} | ||
| title: "Update Changelog" | ||
| body: "" | ||
| branch: "changelog/update" | ||
| delete-branch: true | ||
| path: "{{ plugin_name }}" | ||
| - name: "Mark PR automerge" | ||
| working-directory: "{{ plugin_name }}" | ||
| run: | | ||
| gh pr merge --rebase --auto "{{ '${{ steps.create_pr_changelog.outputs.pull-request-number }}' }}" | ||
| if: "steps.create_pr_changelog.outputs.pull-request-number" | ||
| env: | ||
| GH_TOKEN: "{{ '${{ secrets.RELEASE_TOKEN }}' }}" | ||
| continue-on-error: true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've seen some flaky bugs with changes aggregation but 99% it just works. |
||
| ... | ||
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.
The convenience about this (idea) was having a separate commit for formatting, because the CI update PRs squash all changes from plugin-templates in a single PR. But In the end I think this wasn't even working properly, since we have a format call on the plugin-template apply itself.