Skip to content

Commit

Permalink
Use pixi for managing environments
Browse files Browse the repository at this point in the history
  • Loading branch information
dansondergaard committed Feb 6, 2025
1 parent e91af8b commit 810886e
Show file tree
Hide file tree
Showing 7 changed files with 1,506 additions and 147 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SCM syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
14 changes: 5 additions & 9 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ jobs:
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip nox
shell: bash

- name: Build docs
run: |
python -m nox -s docs
shell: bash
- uses: prefix-dev/setup-pixi@v0.8.0
with:
pixi-version: v0.41.0
cache: true
- run: pixi run build-docs

- name: Add .nojekyll
run: |
Expand Down
40 changes: 6 additions & 34 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- master
pull_request:

concurrency:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

Expand All @@ -17,40 +17,12 @@ jobs:
fail-fast: false
matrix:
os: ["macos-latest", "ubuntu-latest"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
name: Install Python ${{ matrix.python_version }}
with:
python-version: ${{ matrix.python_version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip nox
shell: bash

- name: Run tests
run: |
python -m nox -s test-${{ matrix.python_version }}
shell: bash

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
- uses: prefix-dev/setup-pixi@v0.8.0
with:
python-version: "3.10"

- name: Install gwf
run: |
python -m pip install --upgrade pip flit
flit install -s
- name: Lint
run: nox --non-interactive -s lint
pixi-version: v0.41.0
cache: true
- run: pixi run test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ examples/minimal-workflow-explicit-options/world.txt
.nox
.venv
conda-bld/

# pixi environments
.pixi
*.egg-info
93 changes: 0 additions & 93 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,96 +50,3 @@ def delete_recursively(path):
def build(session):
session.install("flit")
session.run("flit", "build", "--no-setup-py", "--format", "wheel")


@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
def test(session):
# urllib3 v2 came out and shows an openssl error (at least on Py37).
# For now we'll just force <2 to make stuff work.
session.install("urllib3<2", "flit")
session.run("flit", "install", "-s", "--deps", "production")

session.install(
"flake8",
"pytest",
"pytest-click",
"pytest-cov",
"pytest-flake8",
"pytest-mock",
"pytest-runner",
"pytest-asyncio",
)

session.run(
"pytest",
"--cov-config",
"pyproject.toml",
"--cov",
"gwf",
"tests/",
env={"COVERAGE_FILE": f".coverage.{session.python}"},
)

if session.interactive:
session.notify("coverage")


@nox.session(python="3.10")
def coverage(session):
session.install("coverage[toml]")
session.run("coverage", "combine")
session.run("coverage", "report", "--fail-under=65", "--show-missing")
session.run("coverage", "erase")

token = os.getenv("COVERALLS_REPO_TOKEN")
if token:
session.install("coveralls")
session.run("coveralls", env={"COVERALLS_REPO_TOKEN": token})


@nox.session
def format(session):
session.install("black", "isort")

files = ["src/gwf", "tests"]
session.run("black", *files)
session.run("isort", *files)


@nox.session
def lint(session):
session.install("black", "isort", "flake8")

files = ["src/gwf", "tests"]
session.run("black", "--check", *files)
session.run("isort", "--check", *files)

# TODO: Also lint tests at some point...
session.run("flake8", "src/gwf")


@nox.session(python="3.10")
def docs(session):
session.install("flit")
session.run("flit", "install", "-s", "--deps", "production")

session.install(
"sphinx",
"sphinx-autobuild",
"furo",
)

session.cd("docs")
if os.path.exists("_build"):
shutil.rmtree("_build")

# TODO: Add -W to treat warnings as errors
sphinx_args = ["-b", "dirhtml", ".", "_build/dirhtml"]

if not session.interactive:
sphinx_cmd = "sphinx-build"
else:
sphinx_cmd = "sphinx-autobuild"
sphinx_args.insert(0, "--open-browser")

session.run(sphinx_cmd, *sphinx_args)
Loading

0 comments on commit 810886e

Please sign in to comment.