Skip to content

Commit 4cfc2d5

Browse files
authored
[stable-2.17] support pip-compile check mode and remove pip-compile workflows from stable branch (#1947)
* 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 f5f3d12 commit 4cfc2d5

File tree

5 files changed

+21
-208
lines changed

5 files changed

+21
-208
lines changed

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

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

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

Lines changed: 0 additions & 40 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
@@ -25,6 +29,9 @@ jobs:
2529
python-versions: "3.11"
2630
- session: "actionlint"
2731
python-versions: "3.11"
32+
- session: "pip-compile"
33+
extra-args: "--check"
34+
python-versions: "3.10"
2835
name: "Run nox ${{ matrix.session }} session"
2936
steps:
3037
- name: Check out repo
@@ -38,4 +45,6 @@ jobs:
3845
nox -e clone-core
3946
- name: "Run nox -e ${{ matrix.session }}"
4047
run: |
41-
nox -e "${{ matrix.session }}"
48+
# Using GHA expression interpolation is fine here,
49+
# as we control all the inputs.
50+
nox -e "${{ matrix.session }}" -- ${{ matrix.extra-args }}

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

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

noxfile.py

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

162162
# Use --upgrade by default unless a user passes -P.
163163
args = list(session.posargs)
164-
if not any(
164+
165+
# Support a custom --check flag to fail if pip-compile made any changes
166+
# so we can check that that lockfiles are in sync with the input (.in) files.
167+
check_mode = "--check" in args
168+
if check_mode:
169+
# Remove from args, as pip-compile doesn't actually support --check.
170+
args.remove("--check")
171+
elif not any(
165172
arg.startswith(("-P", "--upgrade-package", "--no-upgrade")) for arg in args
166173
):
167174
args.append("--upgrade")
@@ -175,6 +182,9 @@ def pip_compile(session: nox.Session, req: str):
175182
)
176183
# fmt: on
177184

185+
if check_mode and session.run("git", "diff", "tests", silent=True, external=True):
186+
session.error("Check mode: files were changed")
187+
178188

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

0 commit comments

Comments
 (0)