Skip to content

Commit

Permalink
replace tox to nox (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
shkumagai authored Jan 31, 2024
1 parent ec0d845 commit 760af79
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 902 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# http://editorconfig.org

root = true

[*]
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

[Makefile,*.bat]
indent_style = tab

[*.{js,ts,json}]
indent_size = 2
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11']
max-parallel: 1

steps:
Expand All @@ -24,21 +24,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install tox and any other dependencies for test
- name: Install nox and any other dependencies for test
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
pip install nox
- name: Run tox
- name: Run nox
run: |
python -V
tox
nox -s test-${{ matrix.python-version }}
lint:
runs-on: ubuntu-latest
strategy:
matrix:
env: ['flake8', 'isort', 'bandit', 'readme']
env: ['ruff', 'isort', 'bandit', 'mypy', 'readme']

steps:
- name: Checkout code
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Install tox and any other dependencies for test
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
pip install nox
- name: Run tox
run: tox -e ${{ matrix.env }}
- name: Run nox
run: nox -s ${{ matrix.env }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ dist/
eggs/
parts/
.venv
.nox/
.mypy_cache/
.ruff_cache/
.installed.cfg
_build/
*.egg-info/
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ include setup.cfg
include setup.py

exclude .editorconfig
exclude .pyup.yml
exclude *.json
exclude *.lock
exclude Makefile
Expand Down
36 changes: 27 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,39 @@ SRC_DIR := node_modules/impress.js
DEST_DIR := sphinxjp/themes/impressjs/templates/impressjs/static

update-impressjs:
npm install
cp -r $(SRC_DIR)/js $(DEST_DIR)/js
cp -r $(SRC_DIR)/css $(DEST_DIR)/css
@npm install
@cp -r $(SRC_DIR)/js $(DEST_DIR)/js
@cp -r $(SRC_DIR)/css $(DEST_DIR)/css

package:
poetry build
@poetry run python -m build

release-test:
twine upload --repository testpypi dist/*
@twine upload --repository testpypi dist/*

release-prod:
twine upload --repository pypi dist/*
@twine upload --repository pypi dist/*

clear-dist:
rm -rf dist/*
clean:
@git clean -fdx

dist-clean:
@rm -rf dist/*

test:
tox
@nox -s test

lint:
@nox -t lint

fmt:
@nox -s fmt

security:
@nox -s bandit

typing:
@nox -s mypy

readme:
@nox -s readme
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Requirement
===========
Libraries:

* Python 3.6 or later
* Sphinx 3.0 or later.
* Python 3.9 or later
* Sphinx 7.2 or later.


Browsers:
Expand Down
97 changes: 97 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import nox


@nox.session(python=["3.9", "3.10", "3.11"])
def test(session):
"""Run test"""

session.install(".")
session.run(
"sphinx-build",
"-b",
"html",
"-d",
"_build/doctree",
"docs",
"_build/html",
env={
"PYTHONDONTWRITEBYTECODE": "1",
"PYTHONNOWARNINGS": "once",
},
)


@nox.session(tags=["style", "lint"])
def ruff(session):
"""Run Ruff."""
posargs = session.posargs if session.posargs else ["check", "src", "noxfile.py"]

session.install("ruff")
session.run("ruff", *posargs)


@nox.session
def fmt(session):
"""Run format."""

posargs = (
session.posargs if session.posargs else ["format", "-q", "src", "noxfile.py"]
)

session.notify("ruff", posargs=posargs)


@nox.session(tags=["style", "lint"])
def flake8(session):
"""Run flake8."""

posargs = session.posargs if session.posargs else ["src"]

session.install("flake8")
session.install("flake8-copyright")
session.install("flake8-commas")
session.install("flake8-print")
session.install("flake8-return")
session.install("flake8-string-format")
session.run("flake8", *posargs)


@nox.session(tags=["style", "lint"])
def isort(session):
"""Run isort."""

posargs = session.posargs if session.posargs else ["src"]

session.install("isort")
session.run("isort", "--check-only", "--diff", *posargs)


@nox.session(tags=["security"])
def bandit(session):
"""Run bandit."""

posargs = session.posargs if session.posargs else ["src"]

session.install("bandit")
session.run("bandit", "--quiet", "-r", *posargs)


@nox.session(tags=["typing"])
def mypy(session):
"""Run mypy."""

posargs = session.posargs if session.posargs else ["src"]

session.install("mypy")
session.install("types-docutils")
session.run("mypy", *posargs)


@nox.session
def readme(session):
"""Run readme check by twine."""

session.install("build")
session.install("twine")
session.run("python", "-m", "build")
session.run("twine", "check", "dist/*")
Loading

0 comments on commit 760af79

Please sign in to comment.