Skip to content

Commit

Permalink
Use src layout and fix tests (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfrg authored Sep 24, 2023
1 parent 8dddac0 commit d3a7668
Show file tree
Hide file tree
Showing 51 changed files with 152 additions and 420 deletions.
52 changes: 21 additions & 31 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,23 @@ jobs:
# ------------------------------------------------------------------------
# Set up JS

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
node-version: ${{ matrix.node-version }}
version: 8

- name: Load cached node_modules
id: cached-node_modules
uses: actions/cache@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
path: js/node_modules
key: >
node_modules
${{ runner.os }}
node-${{ matrix.node-version }}
${{ hashFiles('js/package*.json') }}
node-version: ${{ matrix.node-version }}

- name: Install JS deps
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: |
task js-install
task js:install
- name: Build JS
run: |
task js-build
task js:build
# ------------------------------------------------------------------------
# Setup Python
Expand All @@ -66,32 +59,29 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# - uses: actions/cache@v3
# id: cached-python-env
# with:
# path: ${{ env.pythonLocation }}
# key: >
# python
# ${{ runner.os }}
# python-${{ matrix.python-version }}
# ${{ hashFiles('pyproject.toml') }}
# ${{ hashFiles('requirements/*') }}
- uses: actions/cache@v3
id: cached-python-env
with:
path: ${{ env.pythonLocation }}
key: >
docs
${{ runner.os }}
python-${{ matrix.python-version }}
${{ hashFiles('pyproject.toml') }}
${{ hashFiles('requirements/*') }}
- name: Install dependencies
# if: steps.cached-python-env.outputs.cache-hit != 'true'
run: |
pip install -r requirements/pyproject.txt
run: pip install -r requirements-dev.lock

- name: Install Hatch
run: |
pip install --upgrade hatch
run: pip install --upgrade hatch

# ------------------------------------------------------------------------
# Test

- name: Build package
run: |
task build
run: hatch build

- name: Install package
run: |
Expand Down
39 changes: 15 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
# os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.8, 3.9, "3.10", 3.11]
python-version: [3.9, "3.10", 3.11]
node-version: [18]

runs-on: ubuntu-latest
Expand All @@ -36,30 +36,23 @@ jobs:
# ------------------------------------------------------------------------
# JS

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
node-version: ${{ matrix.node-version }}
version: 8

- name: Load cached node_modules
id: cached-node_modules
uses: actions/cache@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
path: js/node_modules
key: >
node_modules
${{ runner.os }}
node-${{ matrix.node-version }}
${{ hashFiles('js/package*.json') }}
node-version: ${{ matrix.node-version }}

- name: Install JS deps
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: |
task js-install
task js:install
- name: Build JS
run: |
task js-build
task js:build
# ------------------------------------------------------------------------
# Python
Expand All @@ -74,20 +67,18 @@ jobs:
with:
path: ${{ env.pythonLocation }}
key: >
python2
python
${{ runner.os }}
python-${{ matrix.python-version }}
${{ hashFiles('pyproject.toml') }}
${{ hashFiles('requirements/*') }}
${{ hashFiles('requirements*') }}
- name: Install dependencies
if: steps.cached-python-env.outputs.cache-hit != 'true'
run: |
pip install -r requirements/pyproject.txt
run: pip install -r requirements-dev.lock

- name: Install Hatch
run: |
pip install --upgrade hatch
run: pip install --upgrade hatch

- name: Print Python info
run: |
Expand All @@ -101,7 +92,7 @@ jobs:
# Test

- name: Build package
run: task build
run: hatch build

- name: Install package
run: |
Expand All @@ -110,7 +101,7 @@ jobs:
- name: Run tests
run: |
task test:all
pytest .
task report
- name: Codecov
Expand Down
7 changes: 2 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
version: "3"

env:
PYTEST_K: ""

tasks:
build:
cmds:
Expand All @@ -25,11 +22,11 @@ tasks:

test:
cmds:
- pytest -k "{{.PYTEST_K}}"
- rye run pytest -k "{{.name}}"

test:all:
cmds:
- pytest .
- rye run pytest .

report:
cmds:
Expand Down
1 change: 1 addition & 0 deletions js/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default defineConfig({
outDir: path.join(
__dirname,
"..",
"src",
"mkdocs_jupyter",
"templates",
"mkdocs_html"
Expand Down
113 changes: 51 additions & 62 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
name = "mkdocs-jupyter"
description = "Use Jupyter in mkdocs websites"
readme = "README.md"
requires-python = ">=3.7"
license = "Apache-2.0"
requires-python = ">=3.9"
license = { "text" = "Apache-2.0" }
keywords = ["mkdocs", "jupyter", "jupyterlab", "notebooks", "documentation"]
authors = [{ name = "Daniel Rodriguez", email = "[email protected]" }]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -27,95 +25,86 @@ dependencies = [
]
dynamic = ["version"]

[project.urls]
Documentation = "https://github.com/danielfrg/mkdocs-jupyter#readme"
Issues = "https://github.com/danielfrg/mkdocs-jupyter/issues"
Source = "https://github.com/danielfrg/mkdocs-jupyter"

[project.entry-points."mkdocs.plugins"]
mkdocs-jupyter = "mkdocs_jupyter.plugin:Plugin"

[project.optional-dependencies]
test = ["coverage[toml]", "pymdown-extensions", "pytest", "pytest-cov"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build]
artifacts = ["mkdocs_jupyter/**"]
exclude = [".github", "docs"]

[tool.hatch.version]
path = "mkdocs_jupyter/__about__.py"

[tool.hatch.envs.default]
dependencies = [
[tool.rye]
managed = true
dev-dependencies = [
# Testing
"coverage[toml]",
"pymdown-extensions",
"pytest",
"pytest-cov",
# Linting
"black",
"flake8",
"isort",
"pip-tools",
"ruff",
# Development
# Utils
"jupyterlab",
]

[tool.hatch.envs.default.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=adsctl --cov=tests {args}"
no-cov = "cov --no-cov {args}"
[project.entry-points."mkdocs.plugins"]
mkdocs-jupyter = "mkdocs_jupyter.plugin:Plugin"

[tool.hatch.build]
artifacts = ["mkdocs_jupyter/**"]
exclude = [".github", "docs"]

[[tool.hatch.envs.test.matrix]]
python = ["37", "38", "39", "310", "311"]
[tool.hatch.version]
path = "src/mkdocs_jupyter/__about__.py"

[tool.hatch.metadata]
allow-direct-references = true

[tool.pytest.ini_options]
testpaths = ["mkdocs_jupyter/tests"]
testpaths = ["tests"]
addopts = [
"-s",
"-vv",
"--strict-config",
"--strict-markers",
"--ignore=dist",
"--ignore=site-packages",
# "--strict-markers",
"--cov=mkdocs_jupyter",
"--cov-report=term",
"--cov-config=pyproject.toml",
]
markers = [
"pkg: marks tests as Packaging tests",
"adsapi: mark test that require connection to the API",
]
xfail_strict = true
filterwarnings = ["ignore::DeprecationWarning"]

[tool.coverage.run]
branch = true
parallel = true
omit = ["adsctl/__about__.py"]
omit = ["tests/*"]

[tool.coverage.report]
show_missing = true
ignore_errors = false

exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"pragma: no cover",
"raise NotImplementedError",
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]

[tool.ruff]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
# "I", # isort
"B", # flake8-bugbear
]
omit = ["mkdocs_jupyter/tests/*"]

[tool.coverage.paths]
source = ["mkdocs_jupyter", ".venv/lib/python*/site-packages/mkdocs_jupyter"]

[tool.black]
line_length = 79
skip_string_normalization = true

[tool.isort]
ensure_newline_before_comments = true
line_length = 79
multi_line_output = 3
include_trailing_comma = true
profile = "black"

[tool.pydocstyle]
add_ignore = ["D100", "D101", "D102", "D103", "D104", "D105"]
convention = "numpy"
inherit = false
match_dir = "mkdocs_jupyter"
[tool.mypy]
strict = true

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project.urls]
Documentation = "https://github.com/danielfrg/mkdocs-jupyter#readme"
Issues = "https://github.com/danielfrg/mkdocs-jupyter/issues"
Source = "https://github.com/danielfrg/mkdocs-jupyter"
Loading

0 comments on commit d3a7668

Please sign in to comment.