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

BEHAVIOR: update lock files by default #436

Merged
merged 5 commits into from
Oct 16, 2024
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
21 changes: 21 additions & 0 deletions .github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: |-
${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
on:
pull_request:
branches:
- main
- epic/*
paths:
- .pre-commit-config.yaml
workflow_dispatch:

jobs:
lock:
uses: ComPWA/actions/.github/workflows/lock.yml@v2
secrets:
token: ${{ secrets.PAT }}
2 changes: 1 addition & 1 deletion src/compwa_policy/.github/workflows/lock.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update lock files
name: Update

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _create_argparse() -> ArgumentParser:
parser.add_argument(
"--update-lock-files",
choices=update_lock.Frequency.__args__, # type:ignore[attr-defined]
default="no",
default="outsource",
help=(
"Add a workflow to update lock files, like uv.lock, .pre-commit-config.yml, "
"and pip .constraints/ files. The argument is the frequency of the cron job"
Expand Down
11 changes: 9 additions & 2 deletions src/compwa_policy/check_dev_files/update_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ def overwrite_workflow(workflow_file: str) -> None:
)
yaml = create_prettier_round_trip_yaml()
expected_data = yaml.load(expected_workflow_path)
original_paths = expected_data["on"]["pull_request"]["paths"]
existing_paths = filter_patterns(original_paths)
if not existing_paths:
msg = (
"No paths defined for pull_request trigger. Expecting any of "
", ".join(original_paths)
)
raise ValueError(msg)
expected_data["on"]["pull_request"]["paths"] = existing_paths
if frequency == "outsource":
del expected_data["on"]["schedule"]
else:
paths = filter_patterns(expected_data["on"]["pull_request"]["paths"])
expected_data["on"]["pull_request"]["paths"] = paths
expected_data["on"]["schedule"][0]["cron"] = _to_cron_schedule(frequency)
workflow_path = CONFIG_PATH.github_workflow_dir / workflow_file
if not workflow_path.exists():
Expand Down
Loading