From 229f127501d973200e2f3c74c5b360bba4dee445 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 19 Nov 2022 14:00:03 -0600 Subject: [PATCH] CI Cleanup (#1910) --- .github/workflows/tests.yml | 123 +++++++++++++++--------------------- .pre-commit-config.yaml | 21 +----- .readthedocs.yaml | 5 +- codecov.yml | 3 +- docs/environment.yml | 17 ----- pyproject.toml | 60 ++++++++++++------ 6 files changed, 95 insertions(+), 134 deletions(-) delete mode 100644 docs/environment.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a5c163a18..c28507785 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,9 +9,15 @@ concurrency: group: tests-${{ github.ref }} cancel-in-progress: true +defaults: + run: + shell: bash -eux {0} + jobs: run-tests: runs-on: ${{ matrix.os }} + env: + NBFORMAT_VALIDATOR: jsonschema strategy: matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] @@ -23,79 +29,32 @@ jobs: python-version: "3.9" fail-fast: false steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Run base setup actions - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - uses: conda-incubator/setup-miniconda@v2 - with: - mamba-version: "*" - channels: conda-forge - - name: Install conda-forge python - shell: bash -l {0} - run: | - mamba create -n nbconvert - conda activate nbconvert - mamba install python=${{ matrix.python-version }} - - name: Install conda-forge dependencies - shell: bash -l {0} - run: | - mamba create -n nbconvert - conda activate nbconvert - mamba install pip pyqtwebengine pandoc pyxdg + - uses: actions/checkout@v3 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - name: Install Linux dependencies if: startsWith(runner.os, 'Linux') run: | sudo apt-get update - sudo apt-get install texlive-plain-generic inkscape texlive-xetex - sudo apt-get install xvfb x11-utils libxkbcommon-x11-0 - - name: Install package dependencies - shell: bash -l {0} - run: | - conda activate nbconvert - pip install codecov - pip install -e ".[execute,serve,test]" - which python - python -m ipykernel.kernelspec --sys-prefix - - - name: List installed packages - shell: bash -l {0} - run: | - conda activate nbconvert - pip freeze - pip check + sudo apt-get install texlive-plain-generic inkscape texlive-xetex latexmk + sudo apt-get install xvfb x11-utils libxkbcommon-x11-0 libxcb-xinerama0 python3-pyqt5 - - name: Run tests on MacOS - if: ${{ startsWith(runner.os, 'macos') }} - shell: bash -l {0} - run: | - conda activate nbconvert - # See https://github.com/pyppeteer/pyppeteer/pull/321 - pip install -U websockets - python -m pytest --cov nbconvert -vv + # pandoc is not up to date in the ubuntu repos, so we install directly + wget https://github.com/jgm/pandoc/releases/download/2.14.2/pandoc-2.14.2-1-amd64.deb && sudo dpkg -i pandoc-2.14.2-1-amd64.deb - name: Run tests on Linux if: ${{ startsWith(runner.os, 'linux') }} - shell: bash -l {0} run: | - conda activate nbconvert - # See https://github.com/pyppeteer/pyppeteer/pull/321 - pip install -U websockets - NBFORMAT_VALIDATOR=jsonschema xvfb-run --auto-servernum `which coverage` run -m pytest -vv - - - name: Run tests on pypy and Windows - if: ${{ startsWith(runner.os, 'Windows') }} - shell: bash -l {0} + xvfb-run --auto-servernum hatch run cov:test + + - name: Run tests on other platforms + if: ${{ !startsWith(runner.os, 'linux') }} run: | - conda activate nbconvert - # See https://github.com/pyppeteer/pyppeteer/pull/321 - pip install -U websockets - python -m pytest -vv + hatch run cov:test - name: Code coverage - shell: bash -l {0} run: | - conda activate nbconvert + pip install codecov codecov check_release: @@ -140,31 +99,32 @@ jobs: python_version: "3.7" - name: Install miniumum versions uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + with: + python_version: "3.8" + - uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1 + with: + only_create_file: 1 - name: Run the unit tests run: | + export PIP_CONSTRAINT="./contraints_file.txt" export NBFORMAT_VALIDATOR=jsonschema - pytest -vv -W default || pytest -vv -W default --lf + hatch run test:nowarn || hatch run test:nowarn --lf test_prereleases: name: Test Prereleases runs-on: ubuntu-latest timeout-minutes: 20 steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - name: Install the Python dependencies - run: | - pip install --pre -e ".[test]" - - name: List installed packages - run: | - pip freeze - pip check + - uses: actions/checkout@v3 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + with: + python_version: "3.11" - name: Run the tests run: | + export PIP_PRE=1 export NBFORMAT_VALIDATOR=jsonschema - pytest -vv -W default || pytest -vv -W default --lf + hatch run test:nowarn || hatch run test:nowarn --lf make_sdist: name: Make SDist @@ -183,3 +143,20 @@ jobs: steps: - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - uses: jupyterlab/maintainer-tools/.github/actions/test-sdist@v1 + + tests_check: # This job does nothing and is only used for the branch protection + if: always() + needs: + - run-tests + - pre_commit + - test_minimum_versions + - test_prereleases + - check_links + - check_release + - test_sdist + runs-on: ubuntu-latest + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f673ad8b..10d3a6cd4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,22 +62,7 @@ repos: ["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0"] stages: [manual] - - repo: https://github.com/sirosen/check-jsonschema - rev: 0.18.4 + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.19.1 hooks: - - id: check-jsonschema - name: "Check GitHub Workflows" - files: ^\.github/workflows/ - types: [yaml] - args: ["--schemafile", "https://json.schemastore.org/github-workflow"] - stages: [manual] - - - repo: local - hooks: - - id: check-pyproject - name: check pyproject file - language: python - entry: python -m check_requirements - files: ^pyproject.toml$ - stages: [manual] - additional_dependencies: ["tomli"] + - id: check-github-workflows diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 0a842d7bd..1fb11f5de 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,9 +10,6 @@ sphinx: formats: all -conda: - environment: docs/environment.yml - build: image: latest @@ -21,3 +18,5 @@ python: install: - method: pip path: . + extra_requirements: + - docs diff --git a/codecov.yml b/codecov.yml index 2962fbce9..b75c3e2db 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,8 +3,7 @@ coverage: project: default: target: auto - threshold: 10 + threshold: 1 patch: default: target: 0% -comments: off diff --git a/docs/environment.yml b/docs/environment.yml deleted file mode 100644 index 447a88ecf..000000000 --- a/docs/environment.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: nbconvert_docs -channels: - - conda-forge -dependencies: - - python==3.9 - - pandoc - - nbformat - - jupyter_client - - ipython - - sphinx>=1.5.1 - - sphinx_rtd_theme - - tornado - - entrypoints - - ipykernel - - pip - - pip: - - nbsphinx>=0.7.1 diff --git a/pyproject.toml b/pyproject.toml index b7353b525..c320c710f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,9 +56,11 @@ asciidoc = "nbconvert.exporters:ASCIIDocExporter" script = "nbconvert.exporters:ScriptExporter" [project.optional-dependencies] +qtpng = ["pyqtwebengine>=5.15"] +qtpdf = ["nbconvert[qtpng]"] +webpdf = ["pyppeteer>=1,<1.1"] test = [ "pytest", - "pytest-cov", "pytest-dependency", "ipykernel", "ipywidgets>=7", @@ -66,9 +68,6 @@ test = [ "pyppeteer>=1,<1.1", ] serve = ["tornado>=6.1"] -qtpdf = ["pyqtwebengine>=5.15"] -qtpng = ["pyqtwebengine>=5.15"] -webpdf = ["pyppeteer>=1,<1.1"] docs = [ "myst_parser", "sphinx==5.0.2", @@ -76,22 +75,7 @@ docs = [ "nbsphinx>=0.2.12", "ipython", ] -all = [ - "ipykernel", - "ipython", - "ipywidgets>=7", - "nbsphinx>=0.2.12", - "myst_parser", - "pre-commit", - "pytest", - "pytest-cov", - "pytest-dependency", - "pyqtwebengine>=5.15", - "pyppeteer>=1,<1.1", - "sphinx==5.0.2", - "sphinx_rtd_theme", - "tornado>=6.1", -] +all = ["nbconvert[qtpdf,webpdf,test,serve,docs]"] [project.scripts] jupyter-nbconvert = "nbconvert.nbconvertapp:main" @@ -115,6 +99,25 @@ exclude = [ [tool.hatch.build.targets.wheel.shared-data] "share/templates" = "share/jupyter/nbconvert/templates" +[tool.hatch.envs.docs] +features = ["docs"] +[tool.hatch.envs.docs.scripts] +build = "make -C docs html SPHINXOPTS='-W'" + +[tool.hatch.envs.test] +features = ["test"] +[tool.hatch.envs.test.scripts] +test = "python -m pytest -vv {args}" +nowarn = "test -W default {args}" + +[tool.hatch.envs.cov] +features = ["all"] +dependencies = ["coverage", "pytest-cov"] +[tool.hatch.envs.cov.scripts] +test = "python -m pytest -vv --cov nbconvert --cov-branch --cov-report term-missing:skip-covered {args}" +nowarn = "test -W default {args}" + + [tool.pytest.ini_options] markers = "network: marks tests which require network connection" addopts = "-raXs --durations 10 --color=yes --doctest-modules --ignore=nbconvert/tests/files/override.py --ignore=nbconvert/tests/files/jupyter_nbconvert_config.py" @@ -132,11 +135,26 @@ filterwarnings = [ "ignore:getargs.*format is deprecated:DeprecationWarning", # From jupyter_client "ignore:unclosed