Skip to content

Commit 001a67b

Browse files
committed
Run nox sessions through poetry versions
1 parent ae19ad6 commit 001a67b

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

.github/workflows/tests_full.yaml

+18-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111

1212
jobs:
1313
tests:
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1515
strategy:
1616
matrix:
1717
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
@@ -22,20 +22,32 @@ jobs:
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
25+
- name: Install Poetry
26+
run: |
27+
pip install poetry==1.8.2
28+
pip install poetry-plugin-export==1.7.0
2529
- name: Install Nox
26-
run: pip install nox==2024.03.02
30+
run: |
31+
pip install nox==2024.03.02
32+
pip install nox-poetry==1.0.3
2733
- name: Run tests
2834
run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}"
2935

3036
lint:
31-
runs-on: ubuntu-latest
37+
runs-on: ubuntu-22.04
3238
steps:
3339
- uses: actions/checkout@v4
34-
- name: Set up Python 3.9
40+
- name: Set up Python 3.11
3541
uses: actions/setup-python@v5
3642
with:
37-
python-version: 3.9
43+
python-version: 3.11
44+
- name: Install Poetry
45+
run: |
46+
pip install poetry==1.8.2
47+
pip install poetry-plugin-export==1.7.0
3848
- name: Install Nox
39-
run: pip install nox==2024.03.02
49+
run: |
50+
pip install nox==2024.03.02
51+
pip install nox-poetry==1.0.3
4052
- name: Lint
4153
run: nox --non-interactive --error-on-missing-interpreter --session "lint"

.github/workflows/tests_reduced.yaml

+14-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ jobs:
2121
uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ matrix.python-version }}
24+
- name: Install Poetry
25+
run: |
26+
pip install poetry==1.8.2
27+
pip install poetry-plugin-export==1.7.0
2428
- name: Install Nox
25-
run: pip install nox==2024.03.02
29+
run: |
30+
pip install nox==2024.03.02
31+
pip install nox-poetry==1.0.3
2632
- name: Run tests
2733
run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}"
2834

@@ -34,7 +40,13 @@ jobs:
3440
uses: actions/setup-python@v5
3541
with:
3642
python-version: 3.9
43+
- name: Install Poetry
44+
run: |
45+
pip install poetry==1.8.2
46+
pip install poetry-plugin-export==1.7.0
3747
- name: Install Nox
38-
run: pip install nox==2024.03.02
48+
run: |
49+
pip install nox==2024.03.02
50+
pip install nox-poetry==1.0.3
3951
- name: Lint
4052
run: nox --non-interactive --error-on-missing-interpreter --session "lint"

noxfile.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1+
import sys
2+
from textwrap import dedent
3+
14
import nox
25

6+
7+
try:
8+
from nox_poetry import session
9+
except ImportError:
10+
message = f"""\
11+
Nox failed to import the 'nox-poetry' package.
12+
13+
Please install it using the following command:
14+
15+
{sys.executable} -m pip install nox-poetry"""
16+
raise SystemExit(dedent(message)) from None
17+
18+
319
LOCATIONS = ("src/", "tests/", "noxfile.py", "setup.py")
420

521

6-
@nox.session
22+
@session
723
def lint(session):
824
session.install("flake8")
925
session.install("flake8-bugbear")
1026
session.install("flake8-isort")
11-
session.install("black==24.3.0")
27+
session.install("black")
1228

1329
args = session.posargs or LOCATIONS
1430
session.run("flake8", *args)
1531
session.run("black", "--check", "--diff", *args)
1632

1733

18-
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
34+
@session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
1935
def tests(session):
20-
session.install(
21-
"torch==2.2.1",
22-
"torchvision",
23-
"--index-url",
24-
"https://download.pytorch.org/whl/cpu",
25-
)
26-
session.install(".")
36+
session.install(".", '--extra-index-url', 'https://download.pytorch.org/whl/cpu')
2737
session.install("pytest")
2838
session.install("pytest-mock")
2939
session.run("pytest", *session.posargs)

0 commit comments

Comments
 (0)