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

[stable-2.16] support pip-compile check mode and remove pip-compile workflows from stable branch #1948

Merged
merged 2 commits into from
Oct 15, 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
40 changes: 0 additions & 40 deletions .github/workflows/pip-compile-dev.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/pip-compile-docs.yml

This file was deleted.

11 changes: 10 additions & 1 deletion .github/workflows/reusable-nox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ jobs:
fail-fast: false
matrix:
include:
# Inputs:
# session: name of session
# python-versions: comma-separated list of Python versions to install
# extra-args (optional): extra arguments to pass to nox session.
- session: static
python-versions: "3.11"
- session: formatters_check
Expand All @@ -23,6 +27,9 @@ jobs:
python-versions: "3.11"
- session: "checkers(docs-build)"
python-versions: "3.11"
- session: "pip-compile"
extra-args: "--check"
python-versions: "3.10"
name: "Run nox ${{ matrix.session }} session"
steps:
- name: Check out repo
Expand All @@ -36,4 +43,6 @@ jobs:
nox -e clone-core
- name: "Run nox -e ${{ matrix.session }}"
run: |
nox -e "${{ matrix.session }}"
# Using GHA expression interpolation is fine here,
# as we control all the inputs.
nox -e "${{ matrix.session }}" -- ${{ matrix.extra-args }}
133 changes: 0 additions & 133 deletions .github/workflows/reusable-pip-compile.yml

This file was deleted.

12 changes: 11 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@ def pip_compile(session: nox.Session, req: str):

# Use --upgrade by default unless a user passes -P.
args = list(session.posargs)
if not any(

# 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.
check_mode = "--check" in args
if check_mode:
# Remove from args, as pip-compile doesn't actually support --check.
args.remove("--check")
elif not any(
arg.startswith(("-P", "--upgrade-package", "--no-upgrade")) for arg in args
):
args.append("--upgrade")
Expand All @@ -128,6 +135,9 @@ def pip_compile(session: nox.Session, req: str):
)
# fmt: on

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


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