From 0fb5ae3f40fa09fa942784a5a83ae61cb0e9da39 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:27:00 +0200 Subject: [PATCH 1/5] BEHAVIOR: add update lock files by default --- .github/workflows/lock.yml | 22 +++++++++++++++++++ src/compwa_policy/check_dev_files/__init__.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lock.yml diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 00000000..011dc04f --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,22 @@ +name: Update lock files + +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: + - .constraints/py3.*.txt + - .pre-commit-config.yaml + workflow_dispatch: + +jobs: + lock: + uses: ComPWA/actions/.github/workflows/lock.yml@v2 + secrets: + token: ${{ secrets.PAT }} diff --git a/src/compwa_policy/check_dev_files/__init__.py b/src/compwa_policy/check_dev_files/__init__.py index 2015b5ff..7a83ca18 100644 --- a/src/compwa_policy/check_dev_files/__init__.py +++ b/src/compwa_policy/check_dev_files/__init__.py @@ -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" From 1906abf0eb5af033d472ac3436ac85706c00ca0a Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:31:35 +0200 Subject: [PATCH 2/5] FIX: always update trigger paths --- .github/workflows/lock.yml | 1 - src/compwa_policy/check_dev_files/update_lock.py | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 011dc04f..3ed8fc51 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -11,7 +11,6 @@ on: - main - epic/* paths: - - .constraints/py3.*.txt - .pre-commit-config.yaml workflow_dispatch: diff --git a/src/compwa_policy/check_dev_files/update_lock.py b/src/compwa_policy/check_dev_files/update_lock.py index 1e6a3202..707e18dd 100644 --- a/src/compwa_policy/check_dev_files/update_lock.py +++ b/src/compwa_policy/check_dev_files/update_lock.py @@ -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(): From 523e61c462e78a96ea534559fa4de6a6b5f15f96 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:34:55 +0200 Subject: [PATCH 3/5] TEMP: trigger update lock files --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aeaef5f3..b58f5a08 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -104,6 +104,6 @@ repos: - python - repo: https://github.com/ComPWA/pyright-pre-commit - rev: v1.1.384 + rev: v1.1.383 hooks: - id: pyright From c3bb3997b13f2fcdd9bbabdf7312d4d2d1b3ff55 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:36:54 +0200 Subject: [PATCH 4/5] DX: rename workflow to "Update" --- .github/workflows/lock.yml | 2 +- src/compwa_policy/.github/workflows/lock.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 3ed8fc51..85fa09a8 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -1,4 +1,4 @@ -name: Update lock files +name: Update concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/src/compwa_policy/.github/workflows/lock.yml b/src/compwa_policy/.github/workflows/lock.yml index d8046dc2..fe897530 100644 --- a/src/compwa_policy/.github/workflows/lock.yml +++ b/src/compwa_policy/.github/workflows/lock.yml @@ -1,4 +1,4 @@ -name: Update lock files +name: Update concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 1e13e45a0cc8806de1016ac85d7da6c15bcb50a9 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 16 Oct 2024 07:37:38 +0000 Subject: [PATCH 5/5] MAINT: update lock files --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b58f5a08..aeaef5f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -104,6 +104,6 @@ repos: - python - repo: https://github.com/ComPWA/pyright-pre-commit - rev: v1.1.383 + rev: v1.1.384 hooks: - id: pyright