Skip to content

Reorganize repo to src-layout, migrate to hatch build system and pyproject.toml #1414

Reorganize repo to src-layout, migrate to hatch build system and pyproject.toml

Reorganize repo to src-layout, migrate to hatch build system and pyproject.toml #1414

name: CI
on:
push:
paths-ignore:
- 'CHANGELOG.md'
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 11 * * 4'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: pre-commit/[email protected]
codeql:
needs: pre-commit
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python, javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
test-pip:
needs: pre-commit
continue-on-error: ${{ matrix.experimental || false }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
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
- python-version: "3.13-dev"
experimental: true
- python-version: 3.9
markdown-it-py-version: ""
- python-version: 3.9
markdown-it-py-version: "~=3.0"
- python-version: "3.11"
markdown-it-py-version: "~=4.0"
experimental: true
- python-version: 3.9
kernel: false
- python-version: 3.9
quarto: true
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 dependencies
run: |
python -m pip install --upgrade pip
# install sphinx_gallery and matplotlib if available
python -m pip install sphinx_gallery~=0.7.0 || true
python -m pip install jupyter-fs || true
- name: Install markdown-it-py
if: ${{ matrix.markdown-it-py-version }}
run: python -m pip install markdown-it-py${{ matrix.markdown-it-py-version }}
- name: Install from source (required for the pre-commit tests)
run: python -m pip install '.[dev]'
- name: Install a Jupyter Kernel
if: ${{ matrix.kernel }}
run: python -m ipykernel install --name python_kernel --user
- name: Install Quarto
if: ${{ matrix.quarto }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
# download the latest release
gh release download --repo quarto-dev/quarto-cli --pattern 'quarto-*-linux-amd64.deb'
# install it
sudo apt install ./*.deb
- name: Test with pytest
run: pytest
- name: Upload coverage
uses: codecov/codecov-action@v3
test-conda:
needs: pre-commit
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
python-version: [ 3.9 ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache conda
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('environment-ci.yml') }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
auto-activate-base: false
activate-environment: jupytext-ci
python-version: ${{ matrix.python-version }}
channels: defaults,conda-forge
environment-file: environment-ci.yml
use-only-tar-bz2: true
- name: Install from source
# This is required for the pre-commit tests
shell: pwsh
run: python -m pip install .
- name: Create kernel
shell: pwsh
run: |
python -m ipykernel install --name jupytext-ci --user
- name: Conda list
shell: pwsh
run: conda list
- name: Test with pytest
shell: pwsh
run: pytest
- name: Upload coverage
uses: codecov/codecov-action@v3
if: ${{ matrix.os != 'windows-latest' }}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: 3.9
- name: Build package
run: |
python -m pip install build wheel
# Build jupytext package
python -m build
# Build jupyterlab_jupytext extension
cd packages/labextension
python -m build
# Move all dists into root
cp -r dist/* ../../dist/
cd ../../
# Don't publish a tar.gz file over 1MB (Issue #730)
if (($(wc -c < dist/*.tar.gz) > 1000000)); then exit 1; fi
# node_modules should not be in the package
if (($(tar -tf dist/*.tar.gz | grep node_modules | wc -l)>0)); then echo "node_modules should not be included" && exit 1; fi
# Check that the lab and the notebook extensions are there
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
python -m pip install dist/*.tar.gz
echo "Install went OK"
- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist