Skip to content

Commit

Permalink
Merge pull request #13126 from ichard26/microoptimize-ci
Browse files Browse the repository at this point in the history
Faster test session reruns & microoptimize CI
  • Loading branch information
ichard26 authored Dec 26, 2024
2 parents 7c218b9 + 5ce1145 commit c10dda5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
36 changes: 14 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ jobs:
- name: Run unit tests
run: >-
nox -s test-${{ matrix.python.key || matrix.python }} --
-m unit
tests/unit
--verbose --numprocesses auto --showlocals
- name: Run integration tests
run: >-
nox -s test-${{ matrix.python.key || matrix.python }} --
-m integration
nox -s test-${{ matrix.python.key || matrix.python }} --no-install --
tests/functional
--verbose --numprocesses auto --showlocals
--durations=5
tests-windows:
name: tests / ${{ matrix.python }} / ${{ matrix.os }} / ${{ matrix.group }}
name: tests / ${{ matrix.python }} / ${{ matrix.os }} / ${{ matrix.group.number }}
runs-on: ${{ matrix.os }}-latest

needs: [packaging, determine-changes]
Expand All @@ -180,7 +180,9 @@ jobs:
# - "3.11"
# - "3.12"
- "3.13"
group: [1, 2]
group:
- { number: 1, pytest-filter: "not test_install" }
- { number: 2, pytest-filter: "test_install" }

steps:
- uses: actions/checkout@v4
Expand All @@ -198,29 +200,19 @@ jobs:
TEMP: "C:\\Temp"

# Main check
- name: Run unit tests
if: matrix.group == 1
- name: Run unit tests (group 1)
if: matrix.group.number == 1
run: >-
nox -s test-${{ matrix.python }} --
-m unit
tests/unit
--verbose --numprocesses auto --showlocals
env:
TEMP: "C:\\Temp"

- name: Run integration tests (group 1)
if: matrix.group == 1
- name: Run integration tests (group ${{ matrix.group.number }})
run: >-
nox -s test-${{ matrix.python }} --
-m integration -k "not test_install"
--verbose --numprocesses auto --showlocals
env:
TEMP: "C:\\Temp"

- name: Run integration tests (group 2)
if: matrix.group == 2
run: >-
nox -s test-${{ matrix.python }} --
-m integration -k "test_install"
nox -s test-${{ matrix.python }} --no-install --
tests/functional -k "${{ matrix.group.pytest-filter }}"
--verbose --numprocesses auto --showlocals
env:
TEMP: "C:\\Temp"
Expand Down Expand Up @@ -251,7 +243,7 @@ jobs:
- name: Run integration tests
run: >-
nox -s test-3.10 --
-m integration
tests/functional
--verbose --numprocesses auto --showlocals
--durations=5
--use-zipapp
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
args: ["--pretty", "--show-error-codes"]
additional_dependencies: [
'keyring==24.2.0',
'nox==2023.4.22',
'nox==2024.03.02',
'pytest',
'types-docutils==0.20.0.3',
'types-setuptools==68.2.0.0',
Expand Down
14 changes: 11 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ["lint"]
nox.needs_version = ">=2024.03.02" # for session.run_install()

LOCATIONS = {
"common-wheels": "tests/data/common_wheels",
Expand All @@ -44,7 +45,9 @@ def run_with_protected_pip(session: nox.Session, *arguments: str) -> None:
env = {"VIRTUAL_ENV": session.virtualenv.location}

command = ("python", LOCATIONS["protected-pip"]) + arguments
session.run(*command, env=env, silent=True)
# By using run_install(), these installation steps can be skipped when -R
# or --no-install is passed.
session.run_install(*command, env=env, silent=True)


def should_update_common_wheels() -> bool:
Expand Down Expand Up @@ -84,8 +87,13 @@ def test(session: nox.Session) -> None:
session.log(msg)

# Build source distribution
# HACK: we want to skip building and installing pip when nox's --no-install
# flag is given (to save time when running tests back to back with different
# arguments), but unfortunately nox does not expose this configuration state
# yet. https://github.com/wntrblm/nox/issues/710
no_install = "-R" in sys.argv or "--no-install" in sys.argv
sdist_dir = os.path.join(session.virtualenv.location, "sdist")
if os.path.exists(sdist_dir):
if not no_install and os.path.exists(sdist_dir):
shutil.rmtree(sdist_dir, ignore_errors=True)

run_with_protected_pip(session, "install", "build")
Expand All @@ -94,7 +102,7 @@ def test(session: nox.Session) -> None:
# pip, so uninstall pip to force build to provision a known good version of pip.
run_with_protected_pip(session, "uninstall", "pip", "-y")
# fmt: off
session.run(
session.run_install(
"python", "-I", "-m", "build", "--sdist", "--outdir", sdist_dir,
silent=True,
)
Expand Down

0 comments on commit c10dda5

Please sign in to comment.