Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ jobs:
run: uv run ty check
- name: Analyze Dependencies
run: uv run deptry .
- name: Check workflow templates use .yaml extension
run: |
yml_files=$(find github_rest_api/scripts/github/workflows/ -name '*.yml')
if [ -n "$yml_files" ]; then
echo "The following workflow templates must use the .yaml extension instead of .yml:"
echo "$yml_files"
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _create_push_branch(branch: str):
_add_workflow(path, language)


def add_github_repo(
def create_github_repo(
repo: str,
private: bool,
language: str,
Expand Down Expand Up @@ -117,21 +117,21 @@ def _add_workflow(path: Path, language: str, workflow_dir: Path | None = None) -
workflow_dir = Path(__file__).parent / "workflows"
dir_dest = path / ".github" / "workflows"
dir_dest.mkdir(parents=True, exist_ok=True)
for yaml in workflow_dir.glob("*.yml"):
for yaml in workflow_dir.glob("*.yaml"):
if not (dir_dest / yaml.name).exists():
shutil.copy2(yaml, dir_dest)
Comment thread
dclong marked this conversation as resolved.
Resolved
Comment on lines +120 to 122

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Restricting the search pattern to *.yaml will ignore any existing workflow files with the .yml extension. Since GitHub Actions supports both .yml and .yaml formats, it is better to support both extensions to prevent missing valid workflows.

Suggested change
for yaml in workflow_dir.glob("*.yaml"):
if not (dir_dest / yaml.name).exists():
shutil.copy2(yaml, dir_dest)
for pattern in ("*.yml", "*.yaml"):
for yaml in workflow_dir.glob(pattern):
if not (dir_dest / yaml.name).exists():
shutil.copy2(yaml, dir_dest)

if not language:
return
lang_dir = workflow_dir / language
if not lang_dir.exists():
return
for yaml in lang_dir.glob("*.yml"):
for yaml in lang_dir.glob("*.yaml"):
if not (dir_dest / yaml.name).exists():
shutil.copy2(yaml, dir_dest)
Comment thread
dclong marked this conversation as resolved.
Resolved
Comment on lines +128 to 130

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Restricting the search pattern to *.yaml will ignore any existing workflow files with the .yml extension. Since GitHub Actions supports both .yml and .yaml formats, it is better to support both extensions to prevent missing valid workflows.

Suggested change
for yaml in lang_dir.glob("*.yaml"):
if not (dir_dest / yaml.name).exists():
shutil.copy2(yaml, dir_dest)
for pattern in ("*.yml", "*.yaml"):
for yaml in lang_dir.glob(pattern):
if not (dir_dest / yaml.name).exists():
shutil.copy2(yaml, dir_dest)



def parse_args(args=None, namespace=None):
parser = argparse.ArgumentParser(description="Add a GitHub repository.")
parser = argparse.ArgumentParser(description="Create a GitHub repository.")
parser.add_argument(
"repo",
help="The GitHub repo (in the format of owner/repo) to be created.",
Expand Down Expand Up @@ -203,7 +203,7 @@ def parse_args(args=None, namespace=None):
def main() -> int:
args = parse_args()
try:
add_github_repo(
create_github_repo(
repo=args.repo,
private=args.private,
language=args.language,
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = [ "hatchling" ]

[project]
name = "github-rest-api"
version = "0.45.0"
version = "0.46.0"
description = "Simple wrapper of GitHub REST APIs."
readme = "README.md"
authors = [ { name = "Ben Du", email = "longendu@yahoo.com" } ]
Expand All @@ -27,10 +27,10 @@ dependencies = [
optional-dependencies.ai = [
"litellm>=1.50",
]
scripts.add_github_repo = "github_rest_api.scripts.github.add_github_repo:main"
scripts.auto_merge_pull_request = "github_rest_api.scripts.github.auto_merge_pull_request:main"
scripts.build_container_images = "github_rest_api.scripts.container.build_container_images:main"
scripts.config_container = "github_rest_api.scripts.container.config_container:main"
scripts.create_github_repo = "github_rest_api.scripts.github.create_github_repo:main"
scripts.create_pull_request = "github_rest_api.scripts.github.create_pull_request:main"
scripts.release_on_github = "github_rest_api.scripts.github.release_on_github:main"
scripts.remove_branch = "github_rest_api.scripts.github.remove_branch:main"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.