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

fix: Get CI running again #1035

Merged
merged 6 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 63 additions & 59 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,37 @@ jobs:
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v1
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- uses: pre-commit/[email protected]
python-version: "3.x"
- uses: pre-commit/[email protected]

lint:
name: Lint
needs: skip_duplicate
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# all Python files should follow PEP8 (except some notebooks, see setup.cfg)
flake8 jupytext tests
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --statistics

analyse:
name: Analyse
Expand All @@ -38,7 +63,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can check out the head.
Expand All @@ -60,41 +85,29 @@ jobs:
uses: github/codeql-action/analyze@v1

test-pip:
needs: skip_duplicate
needs: lint
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }}
strategy:
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
# install black, isort, and autopep8 for testing the pipe mode
pip install black
pip install isort>=5.3.0
pip install autopep8
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
# install sphinx_gallery and matplotlib if available (may not work on pypy)
pip install sphinx_gallery~=0.7.0 || true
pip install jupyter-fs || true
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# all Python files should follow PEP8 (except some notebooks, see setup.cfg)
flake8 jupytext tests
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --statistics
python -m pip install sphinx_gallery~=0.7.0 || true
python -m pip install jupyter-fs || true
- name: Install from source (required for the pre-commit tests)
run: pip install .
run: python -m pip install .
- name: Install a Jupyter Kernel
run: python -m ipykernel install --name python_kernel --user
- name: Install Quarto
Expand All @@ -111,7 +124,7 @@ jobs:
uses: codecov/codecov-action@v1

test-conda:
needs: skip_duplicate
needs: lint
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }}
strategy:
matrix:
Expand All @@ -120,9 +133,9 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Cache conda
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('environment-ci.yml') }}
Expand All @@ -136,19 +149,10 @@ jobs:
channels: defaults,conda-forge
environment-file: environment-ci.yml
use-only-tar-bz2: true
- name: Lint with flake8
shell: pwsh
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# all Python files should follow PEP8 (except some notebooks, see setup.cfg)
flake8 jupytext tests
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --statistics
- name: Install from source
# This is required for the pre-commit tests
shell: pwsh
run: pip install .
run: python -m pip install .
- name: Create kernel
shell: pwsh
run: |
Expand Down Expand Up @@ -177,17 +181,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies, except markdown-it-py
run: |
python -m pip install --upgrade pip
# All dependencies but markdown-it-py
pip install nbformat pyyaml toml
pip install -r requirements-dev.txt
python -m pip install nbformat pyyaml toml
python -m pip install -r requirements-dev.txt
- name: Install a Jupyter Kernel
run: python -m ipykernel install --name python_kernel --user
- name: Test with pytest
Expand All @@ -204,16 +208,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
- name: Test with pytest
run: pytest --cov=./ --cov-report=xml
- name: Upload coverage
Expand All @@ -228,19 +232,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# All dependencies but markdown-it-py
pip install -r requirements.txt
pip install -r requirements-dev.txt
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
# Notebook pre-release version #933
pip install --pre -U notebook
python -m pip install --pre -U notebook
- name: Install a Jupyter Kernel
run: python -m ipykernel install --name python_kernel --user
- name: Test with pytest
Expand All @@ -253,14 +257,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Build package
run: |
pip install wheel jupyter-packaging jupyterlab>=3
python -m pip install wheel jupyter-packaging jupyterlab>=3
BUILD_JUPYTERLAB_EXTENSION=1 python setup.py sdist bdist_wheel
# Don't publish a tar.gz file over 1MB (Issue #730)
if (($(wc -c < dist/*.tar.gz) > 1000000)); then exit 1; fi
Expand All @@ -270,7 +274,7 @@ jobs:
if (($(tar -tf dist/*.tar.gz | grep packages/labextension/package.json$ | wc -l)==0)); then echo "Missing lab extension" && exit 1; fi
if (($(tar -tf dist/*.tar.gz | grep jupytext/nbextension/index.js$ | wc -l)==0)); then echo "Missing notebook extension" && exit 1; fi
# Install
pip install dist/*.tar.gz
python -m pip install dist/*.tar.gz
echo "Install went OK"
publish:
name: Publish to PyPi
Expand All @@ -279,14 +283,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Build package
run: |
pip install wheel jupyter-packaging jupyterlab>=3
python -m pip install wheel jupyter-packaging jupyterlab>=3
BUILD_JUPYTERLAB_EXTENSION=1 python setup.py sdist bdist_wheel
- name: Publish
uses: pypa/[email protected]
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@ exclude: >
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.4.0
hooks:
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py36-plus"]

- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.0.1
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']

- repo: https://github.com/pycqa/flake8
rev: 3.9.2
rev: 6.0.0
hooks:
- id: flake8

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
# isort needs the 'black' profile when used in combination with black
# See https://github.com/PyCQA/isort/issues/1518
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
1 change: 0 additions & 1 deletion jupytext/cell_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ def find_region_end(self, lines):
self.cell_marker_start or i == 0 or _BLANK_LINE.match(lines[i - 1])
)
):

if self.explicit_end_marker_required:
# Metadata here was conditioned on finding an explicit end marker
# before the next start marker. So we dismiss it.
Expand Down
1 change: 0 additions & 1 deletion jupytext/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def compare_cells(
if (ref_cell.cell_type == "code" and not allow_missing_code_cell_metadata) or (
ref_cell.cell_type != "code" and not allow_missing_markdown_cell_metadata
):

ref_metadata = ref_cell.metadata
test_metadata = test_cell.metadata
if allow_filtered_cell_metadata:
Expand Down
2 changes: 0 additions & 2 deletions jupytext/myst.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ def _flush_markdown(start_line, token, md_metadata):
md_metadata = {}

for token in tokens:

nesting_level += token.nesting

if nesting_level != 0:
Expand Down Expand Up @@ -381,7 +380,6 @@ def notebook_to_myst(

last_cell_md = False
for i, cell in enumerate(nb.cells):

if cell.cell_type == "markdown":
metadata = from_nbnode(cell.metadata)
if metadata or last_cell_md:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_read_text_and_combine_with_outputs(tmpdir):
tmp_ipynb = "notebook.ipynb"
tmp_script = "notebook.py"

with (open(str(tmpdir.join(tmp_script)), "w")) as fp:
with open(str(tmpdir.join(tmp_script)), "w") as fp:
fp.write(
"""# ---
# jupyter:
Expand All @@ -61,7 +61,7 @@ def test_read_text_and_combine_with_outputs(tmpdir):
"""
)

with (open(str(tmpdir.join(tmp_ipynb)), "w")) as fp:
with open(str(tmpdir.join(tmp_ipynb)), "w") as fp:
fp.write(
"""{
"cells": [
Expand Down
3 changes: 2 additions & 1 deletion tests/test_hide_remove_input_outputs_rmarkdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def test_jupyter_book_options_to_rmarkdown(md, rmd):
)
def test_runtools_options_to_rmarkdown(md, rmd):
"""Options set by the runtools extension are mapped to the corresponding R Markdown options
https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/runtools/readme.html"""
https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/runtools/readme.html
"""
md = (
"```python "
+ md
Expand Down
1 change: 0 additions & 1 deletion tests/test_read_simple_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,6 @@ def test_arg(arg):
],
)
def test_indented_magic_commands(script, cell):

nb = jupytext.reads(script, "py")
assert len(nb.cells) == 1
assert nb.cells[0].cell_type == "code"
Expand Down