Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adopt nox #750

Closed
wants to merge 12 commits into from
8 changes: 4 additions & 4 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ jobs:
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
- name: Install Dependencies
- name: Install dependencies
if: ${{ !env.ACT }}
run: poetry install
- name: Install Dependencies
run: poetry install -E test
- name: Install dependencies
if: ${{ env.ACT }}
# When using `act` to run the workflow locally, the `poetry install` command
# may fail due to network issues when running multiple Docker containers.
run: poetry install || poetry install || poetry install
run: poetry install -E test || poetry install -E test || poetry install -E test
- name: Test
env:
EARTHDATA_USERNAME: ${{ secrets.EDL_USERNAME }}
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Unit Tests

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]

Expand Down Expand Up @@ -42,14 +44,16 @@ jobs:
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
- name: Install Dependencies
- name: Install dependencies
if: ${{ !env.ACT }}
run: poetry install
- name: Install Dependencies
run: poetry install -E test
- name: Install dependencies
if: ${{ env.ACT }}
# When using `act` to run the workflow locally, the `poetry install` command
# may fail due to network issues when running multiple Docker containers.
run: poetry install || poetry install || poetry install
run: poetry install -E test || poetry install -E test || poetry install -E test
- name: Typecheck
run: poetry run bash scripts/typecheck.sh
- name: Test
run: poetry run bash scripts/test.sh
- name: Upload coverage
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ repos:
- id: check-toml
- id: check-json

- repo: https://github.com/python-poetry/poetry
rev: '1.8.3'
hooks:
- id: poetry-check
# This hook is very slow! Run with `pre-commit run -a poetry-lock --hook-stage manual`
- id: poetry-lock
stages: [manual]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
hooks:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Visit [our quick start guide](https://earthaccess.readthedocs.io/en/latest/quick

## Compatibility

Only **Python 3.8+** is supported.
Only **Python 3.9+** is supported.


## How to Contribute to `earthaccess`
Expand Down
81 changes: 81 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from __future__ import annotations

import shutil
from pathlib import Path

import nox

DIR = Path(__file__).parent.resolve()

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["typecheck", "test_unit"]
nox.options.default_venv_backend = "uv|virtualenv"


@nox.session
def typecheck(session: nox.Session) -> None:
"""Run the typechecker."""
session.install(".[test]")
session.run("mypy")


@nox.session
def test_unit(session: nox.Session) -> None:
"""Run the unit tests."""
session.install(".[test]")
session.run(*_test_cmd("tests/unit"), *session.posargs)


@nox.session
def test_integration(session: nox.Session) -> None:
"""Run the unit tests."""
session.install(".[test]")
session.run(*_test_cmd("tests/integration"), *session.posargs)


@nox.session(reuse_venv=True)
def docs_build(session: nox.Session) -> None:
"""Build the docs."""
session.install(".[docs]")
session.run("mkdocs", "build")


@nox.session(reuse_venv=True)
def docs_serve(session: nox.Session) -> None:
"""Serve the docs for development."""
session.install(".[docs]")

session.run(
"mkdocs",
"serve",
"--dev-addr",
"0.0.0.0:8008",
"--dirtyreload",
# HACK: --no-strict is on because --dirtyreload ALWAYS throws errors. Better
# solution?
"--no-strict",
)


@nox.session
def pkg_build(session: nox.Session) -> None:
"""Build a source distribution and binary distribution (wheel)."""
build_path = DIR.joinpath("dist")
if build_path.exists():
shutil.rmtree(build_path)

session.install("build")
session.run("python", "-m", "build")


def _test_cmd(tests_dir: str) -> list[str]:
return [
"pytest",
tests_dir,
"--cov=earthaccess",
f"--cov={tests_dir}",
"--cov-report=term-missing",
"--capture=no",
"--tb=native",
"--log-cli-level=INFO",
]
Loading
Loading