Skip to content

Commit 5b741c8

Browse files
authored
[stable-2.16] support pip-compile check mode and remove pip-compile workflows from stable branch (#1948)
* nox pip-compile: support check mode Support a custom --check flag to fail if pip-compile made any changes so we can check that that lockfiles are in sync with the input (.in) files. (cherry picked from commit cb295b1) * ci: remove pip-compile workflows from stable branch We don't need these on stable branches, as they can be triggered from the devel branch with a custom base-branch input. They were also missing backports of various fixes from the devel branch. Rather than trying to backport all the changes, let's just remove it from stable branches and make sure we do so after each branching. (cherry picked from commit 0d8d26e)
1 parent cb8c86d commit 5b741c8

File tree

5 files changed

+21
-211
lines changed

5 files changed

+21
-211
lines changed

.github/workflows/pip-compile-dev.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/pip-compile-docs.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/reusable-nox.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
include:
14+
# Inputs:
15+
# session: name of session
16+
# python-versions: comma-separated list of Python versions to install
17+
# extra-args (optional): extra arguments to pass to nox session.
1418
- session: static
1519
python-versions: "3.11"
1620
- session: formatters_check
@@ -23,6 +27,9 @@ jobs:
2327
python-versions: "3.11"
2428
- session: "checkers(docs-build)"
2529
python-versions: "3.11"
30+
- session: "pip-compile"
31+
extra-args: "--check"
32+
python-versions: "3.10"
2633
name: "Run nox ${{ matrix.session }} session"
2734
steps:
2835
- name: Check out repo
@@ -36,4 +43,6 @@ jobs:
3643
nox -e clone-core
3744
- name: "Run nox -e ${{ matrix.session }}"
3845
run: |
39-
nox -e "${{ matrix.session }}"
46+
# Using GHA expression interpolation is fine here,
47+
# as we control all the inputs.
48+
nox -e "${{ matrix.session }}" -- ${{ matrix.extra-args }}

.github/workflows/reusable-pip-compile.yml

Lines changed: 0 additions & 133 deletions
This file was deleted.

noxfile.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ def pip_compile(session: nox.Session, req: str):
114114

115115
# Use --upgrade by default unless a user passes -P.
116116
args = list(session.posargs)
117-
if not any(
117+
118+
# Support a custom --check flag to fail if pip-compile made any changes
119+
# so we can check that that lockfiles are in sync with the input (.in) files.
120+
check_mode = "--check" in args
121+
if check_mode:
122+
# Remove from args, as pip-compile doesn't actually support --check.
123+
args.remove("--check")
124+
elif not any(
118125
arg.startswith(("-P", "--upgrade-package", "--no-upgrade")) for arg in args
119126
):
120127
args.append("--upgrade")
@@ -128,6 +135,9 @@ def pip_compile(session: nox.Session, req: str):
128135
)
129136
# fmt: on
130137

138+
if check_mode and session.run("git", "diff", "tests", silent=True, external=True):
139+
session.error("Check mode: files were changed")
140+
131141

132142
@nox.session(name="clone-core")
133143
def clone_core(session: nox.Session):

0 commit comments

Comments
 (0)