Skip to content

Commit

Permalink
Run nox sessions through poetry versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mseitzer committed Mar 17, 2024
1 parent ae19ad6 commit 001a67b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/tests_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:

jobs:
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
Expand All @@ -22,20 +22,32 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
pip install poetry==1.8.2
pip install poetry-plugin-export==1.7.0
- name: Install Nox
run: pip install nox==2024.03.02
run: |
pip install nox==2024.03.02
pip install nox-poetry==1.0.3
- name: Run tests
run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}"

lint:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Install Poetry
run: |
pip install poetry==1.8.2
pip install poetry-plugin-export==1.7.0
- name: Install Nox
run: pip install nox==2024.03.02
run: |
pip install nox==2024.03.02
pip install nox-poetry==1.0.3
- name: Lint
run: nox --non-interactive --error-on-missing-interpreter --session "lint"
16 changes: 14 additions & 2 deletions .github/workflows/tests_reduced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
pip install poetry==1.8.2
pip install poetry-plugin-export==1.7.0
- name: Install Nox
run: pip install nox==2024.03.02
run: |
pip install nox==2024.03.02
pip install nox-poetry==1.0.3
- name: Run tests
run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}"

Expand All @@ -34,7 +40,13 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Poetry
run: |
pip install poetry==1.8.2
pip install poetry-plugin-export==1.7.0
- name: Install Nox
run: pip install nox==2024.03.02
run: |
pip install nox==2024.03.02
pip install nox-poetry==1.0.3
- name: Lint
run: nox --non-interactive --error-on-missing-interpreter --session "lint"
30 changes: 20 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
import sys
from textwrap import dedent

import nox


try:
from nox_poetry import session
except ImportError:
message = f"""\
Nox failed to import the 'nox-poetry' package.
Please install it using the following command:
{sys.executable} -m pip install nox-poetry"""
raise SystemExit(dedent(message)) from None


LOCATIONS = ("src/", "tests/", "noxfile.py", "setup.py")


@nox.session
@session
def lint(session):
session.install("flake8")
session.install("flake8-bugbear")
session.install("flake8-isort")
session.install("black==24.3.0")
session.install("black")

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


@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
@session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
def tests(session):
session.install(
"torch==2.2.1",
"torchvision",
"--index-url",
"https://download.pytorch.org/whl/cpu",
)
session.install(".")
session.install(".", '--extra-index-url', 'https://download.pytorch.org/whl/cpu')
session.install("pytest")
session.install("pytest-mock")
session.run("pytest", *session.posargs)

0 comments on commit 001a67b

Please sign in to comment.