Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Reorganize the tests into unit/functional/integration/external #1155

Merged
merged 37 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2493743
Move the test notebooks to tests/data/notebooks
mwouts Nov 6, 2023
555d0d7
Move the pre-commit tests to a subdir
mwouts Nov 6, 2023
eb0e77e
Split tests into unit/integration/functional
mwouts Nov 7, 2023
2ef289a
Split the test dependencies into test/integration/functional
mwouts Nov 9, 2023
32f8c92
Document test requirements with pytest markers
mwouts Nov 11, 2023
c1850be
Use packaging.version if available
mwouts Nov 11, 2023
e22b7be
Ignore a few more warnings
mwouts Nov 11, 2023
c442e3f
Move the codecov.yml configuration file to .github
mwouts Nov 11, 2023
3fcc046
Remove the world population notebook from the examples
mwouts Nov 11, 2023
4b3eec3
Move some tests to external
mwouts Nov 19, 2023
bf6b3e4
Test unit/functional/integration/external tests and their dependencies
mwouts Nov 19, 2023
0b9344d
Parametrize the tests by all the Python files in `src/jupytext`
mwouts Nov 19, 2023
f180532
Move tests with dependencies to integration/external
mwouts Nov 19, 2023
3d5b528
Move test on pre-commit mode
mwouts Nov 19, 2023
ab15185
Label as external a test on the rst2md option
mwouts Nov 19, 2023
a6ca72d
Fix import error
mwouts Nov 19, 2023
4e32850
Include tests in the Jupytext package
mwouts Nov 19, 2023
4406786
Use Python 3.x for the external tests
mwouts Nov 19, 2023
57ed3b4
Filter more of the expected warnings
mwouts Nov 19, 2023
7442c15
Install JupyterLab before testing the extension
mwouts Nov 19, 2023
8f29535
Remove isort_version
mwouts Nov 19, 2023
674b3aa
Remove matrix.external, kernel=true is the default
mwouts Nov 19, 2023
54189af
Install external dependencies too
mwouts Nov 19, 2023
096ff0d
Install JupyterLab before running UI tests
mwouts Nov 19, 2023
abc6676
Fix name of env
mwouts Nov 19, 2023
3b82bdf
Restore environment-ci.yml
mwouts Nov 20, 2023
595e154
Include step test_classification in the CI
mwouts Nov 21, 2023
1417ca7
Remove empty line
mwouts Nov 21, 2023
a2cd5c7
Turn the tests notebooks into fixtures
mwouts Nov 21, 2023
23fdd2d
packaging is a dependency
mwouts Nov 23, 2023
12b2201
Importing parse won't fail
mwouts Nov 23, 2023
6e10678
Try codecov flags
mwouts Nov 23, 2023
6ea8a80
Remove marker 'requires_jupytext'
mwouts Nov 23, 2023
12dbf54
Simplify the pytest command
mwouts Nov 23, 2023
4fb0dba
Move some tests to external
mwouts Nov 23, 2023
3c8608d
Rename test to avoid conflict
mwouts Nov 23, 2023
52c53b1
Fix the tests on Windows
mwouts Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 1 addition & 18 deletions .ci/environment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@ channels:
- defaults
- conda-forge
dependencies:
- ipykernel
- nbconvert
- jupyterlab
- nbformat>=5.1.2
- pyyaml
- toml
- markdown-it-py
- mdit-py-plugins
- pip
- pytest
- pytest-randomly
- pytest-cov
- coverage
- flake8
- autopep8
- black
- isort
- pandoc==2.16.2
- sphinx-gallery<0.8
- pre-commit
- gitpython
34 changes: 34 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
codecov:
notify:
after_n_builds: 15

comment:
after_n_builds: 15

coverage:
status:
project:
source:
paths:
- "src/jupytext/"
target: 97%
threshold: 0.002
tests:
paths:
- "tests/"
target: 100%
unit-tests:
flags:
- unit
functional-tests:
flags:
- functional
integration-tests:
flags:
- integration
external-tests:
flags:
- external
patch:
default:
target: 80% # new contributions should have a coverage at least equal to target
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
needs: [codeql]
uses: ./.github/workflows/step_tests-pip.yml

test-unit-functional-integration:
needs: [codeql]
uses: ./.github/workflows/step_test_unit_functional.yml

test-conda:
needs: [codeql]
uses: ./.github/workflows/step_tests-conda.yml
Expand All @@ -56,7 +60,7 @@ jobs:
upload: ${{ inputs.upload-build-artifacts || false }}

pass:
needs: [pre-commit, codeql, test-pip, test-conda, test-ui, build]
needs: [pre-commit, codeql, test-unit-functional-integration, test-pip, test-conda, test-ui, build]
runs-on: ubuntu-latest
steps:
- name: Check jobs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/step_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
python -m pip install build wheel

# NOTE: These builds and verifications of the builds can be done more
# robustily with jupyter-releaser.
# robustly with jupyter-releaser.
#
# Removed the check on size of package as we are distributing tests/ with
# sdist now and they are around 8MB. Seems like original check was to make
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/step_test_unit_functional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test-categories
run-name: Run Unit/Functional/Integration and External tests using Pip

on:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-test_classification
cancel-in-progress: true

jobs:
test-pip:
continue-on-error: ${{ matrix.experimental || false }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
coverage: [unit, functional, integration, external]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: ${{ matrix.python-version }}

- name: Install from source
run: HATCH_BUILD_HOOKS_ENABLE=false python -m pip install -e '.[test-cov,test-${{ matrix.coverage }}]' markdown-it-py~=3.0

- name: Install a Jupyter Kernel
run: python -m ipykernel install --name python_kernel --user

- name: Run the tests
run: pytest tests/${{ matrix.coverage }} --cov

- name: Upload the coverage
uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.coverage }}
fail_ci_if_error: true
verbose: true
8 changes: 3 additions & 5 deletions .github/workflows/step_tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
python-version: [ 3.9 ]
python-version: [ 3.11 ]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -38,9 +38,8 @@ jobs:
use-only-tar-bz2: true

- name: Install from source
# This is required for the pre-commit tests
shell: pwsh
run: python -m pip install -e '.[test-cov]'
run: python -m pip install -e '.[test-external,test-cov]'

- name: Create kernel
shell: pwsh
Expand All @@ -61,8 +60,7 @@ jobs:

- name: Test with pytest
shell: pwsh
run: pytest --cov=src/jupytext --cov-report=xml
run: pytest --cov

- name: Upload coverage
uses: codecov/codecov-action@v3
if: ${{ matrix.os != 'windows-latest' }}
15 changes: 7 additions & 8 deletions .github/workflows/step_tests-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
markdown-it-py-version: ["~=2.0"]
kernel: [true]
include:
- python-version: "3.12-dev"
experimental: true
Expand All @@ -28,14 +27,13 @@ jobs:
markdown-it-py-version: ""
- python-version: "3.x"
markdown-it-py-version: "~=3.0"
- python-version: "3.11"
- python-version: "3.x"
markdown-it-py-version: "~=4.0"
experimental: true
- python-version: "3.x"
kernel: false
no_kernel: true
- python-version: "3.x"
quarto: true
kernel: true

steps:
- name: Checkout
Expand All @@ -46,11 +44,11 @@ jobs:
with:
python_version: ${{ matrix.python-version }}

- name: Install from source (required for the pre-commit tests)
run: python -m pip install -e '.[test-cov]' ${{ matrix.markdown-it-py-version && format('markdown-it-py{0}', matrix.markdown-it-py-version) }}
- name: Install from source
run: python -m pip install -e '.[test-cov,test-external]' ${{ matrix.markdown-it-py-version && format('markdown-it-py{0}', matrix.markdown-it-py-version) }}

- name: Install a Jupyter Kernel
if: ${{ matrix.kernel }}
if: ${{ !matrix.no_kernel }}
run: python -m ipykernel install --name python_kernel --user

- name: Install Quarto
Expand All @@ -66,12 +64,13 @@ jobs:
- name: Test lab extension
run: |
# Check extension
pip install jupyterlab
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab-jupytext.*OK"
python -m jupyterlab.browser_check

- name: Test with pytest
run: pytest --cov=src/jupytext --cov-report=xml
run: pytest --cov

- name: Upload coverage
uses: codecov/codecov-action@v3
8 changes: 5 additions & 3 deletions .github/workflows/step_tests-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ jobs:
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install from source (required for the pre-commit tests)
run: python -m pip install -e '.[test-cov]'
- name: Install from source
run: python -m pip install -e .

- name: Install galata
working-directory: jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install
run: |
pip install jupyterlab
jlpm install

- name: Install browser
working-directory: jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
exclude: >
(?x)^(
demo/.*|
tests/notebooks/.*|
tests/data/notebooks/.*|
)$
repos:

Expand Down
23 changes: 0 additions & 23 deletions codecov.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ You want to submit an enhancement on Jupytext? Unless this is a small change, we
A pull request for which you do not need to contact us in advance is the addition of a new language to Jupytext. In principle that should be easy - you would only have to:
- document the language extension and comment by adding one line to `_SCRIPT_EXTENSIONS` in `jupytext/languages.py`.
- add the language to `docs/languages.md`
- contribute a sample notebook in `tests/notebooks/ipynb_[language]`.
- run the tests suite (create a [development environment](developing.md), then execute `pytest` locally). The tests will generate various text representations corresponding to your notebook under `tests/notebooks/mirror/`. Please verify that these files are valid scripts, and include them in your PR.
- contribute a sample notebook in `tests/data/notebooks/inputs/ipynb_[language]`.
- run the tests suite (create a [development environment](developing.md), then execute `pytest` locally). The tests will generate various text representations corresponding to your notebook under `tests/data/notebooks/outputs/`. Please verify that these files are valid scripts, and include them in your PR.
4 changes: 2 additions & 2 deletions docs/using-pre-commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ repos:
language_version: python3
```

Tested examples of how to use the pre-commit hook are available in our [tests](https://github.com/mwouts/jupytext/tree/main/tests) -
see for instance [test_pre_commit_1_sync_with_config.py](https://github.com/mwouts/jupytext/blob/main/tests/test_pre_commit_1_sync_with_config.py).
Tested examples of how to use the pre-commit hook are available in our [tests](https://github.com/mwouts/jupytext/tree/main/tests/functional/pre-commit) -
see for instance [test_pre_commit_1_sync_with_config.py](https://github.com/mwouts/jupytext/blob/main/tests/functional/pre-commit/test_pre_commit_1_sync_with_config.py).
19 changes: 1 addition & 18 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ dependencies:
- python>=3.8
- jupyterlab>=4.0.0
- nbformat>=5.1.2
- pyyaml
- toml
- markdown-it-py>=1.0.0,<3.0.0
- mdit-py-plugins
- nbconvert
- ipykernel
- pytest
- pytest-xdist
- pytest-randomly
- pytest-cov
- pre-commit
- gitpython
- pylint
- flake8
- black==23.11.0
- isort==5.12.0
- autopep8
- sphinx-gallery<0.8
- pandoc==2.16.2
- nodejs>=20
- pandoc==2.16.2
Loading
Loading