Skip to content

Commit

Permalink
Switch tooling to hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Jun 1, 2024
1 parent e9bad00 commit f527cb6
Show file tree
Hide file tree
Showing 59 changed files with 3,011 additions and 3,102 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
name: Docs

on: [push, ]
on:
push:
branches:
- master
- dev
- 'release-*'
tags:
- '*'
pull_request:
branches:
- master

jobs:

build_docs:
name: Build Sphinx docs
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:

- uses: actions/checkout@v2
Expand All @@ -16,14 +26,19 @@ jobs:
with:
python-version: 3.8

- name: Install zip-files
run: pip install zip-files

- name: Install apt packages
run: sudo apt-get install graphviz imagemagick pandoc pandoc-citeproc

- name: Install Tox and other Python package requirements
run: pip install tox zip-files
- name: Install Hatch
uses: pypa/hatch@install
with:
version: 1.11.1

- name: Generate HTML Documentation
run: tox -c tox-pyenv.ini -e docs
run: hatch run docs:build

- name: Get the version
id: get_version
Expand All @@ -37,15 +52,15 @@ jobs:
with:
name: krotov-docs
# We need at least two files in the artifact to avoid a weird
# double-zip file. Hence README.rst
# double-zip file. Hence README.md
path: |
README.rst
README.md
./krotov-docs-${{ steps.get_version.outputs.VERSION }}.*
deploy_gh_pages:
name: Deploy documentation to gh-pages
if: always() && needs.build_docs.result == 'success' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: [build_docs]
steps:

Expand Down Expand Up @@ -89,7 +104,6 @@ jobs:
- name: Set download links
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "[pdf]: https://github.com/qucontrol/krotov/releases/download/${{ env.BRANCH_NAME }}/krotov-${{ env.BRANCH_NAME }}.pdf" > ./${{ env.BRANCH_NAME }}/_downloads
echo "[html]: https://github.com/qucontrol/krotov/releases/download/${{ env.BRANCH_NAME }}/krotov-${{ env.BRANCH_NAME }}.zip" >> ./${{ env.BRANCH_NAME }}/_downloads
- name: Remove artifact files
Expand Down
97 changes: 48 additions & 49 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- master
- dev
- 'release-*'
tags:
- '*'
pull_request:
branches:
- master


jobs:
Expand All @@ -9,84 +19,78 @@ jobs:
name: ${{ matrix.title }} (Python ${{ matrix.python }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
tox: tox -c tox-pyenv.ini
default_tests: src tests README.rst docs/*.rst
strategy:
fail-fast: false
matrix:
include:
- title: Codestyle and Main Tests
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: |
$tox -e run-blackcheck,run-isortcheck
$tox -e py38-test -- $default_tests
hatch run lint:black-check
hatch run lint:isort-check
hatch run cov -- $default_tests
coverage: true
- title: Oldest supported Python
os: ubuntu-18.04
python: 3.6
commands: $tox -e py36-test -- $default_tests
os: ubuntu-22.04
python: 3.7
commands: hatch -e py37 run test -- $default_tests
coverage: false
- title: QuTiP master
os: ubuntu-18.04
python: 3.8
commands: $tox -e py38qtm-test -- $default_tests
continue-on-error: true # experimental
coverage: false
- title: Windows / Conda
- title: Windows
os: windows-latest
python: 3.6
commands: tox -c tox-conda.ini -e py36-test -- src tests README.rst docs\notebooks\01_example_simple_state_to_state.ipynb docs\notebooks\05_example_transmon_xgate.ipynb
python: 3.8
commands: hatch run test -- src tests README.rst docs\notebooks\01_example_simple_state_to_state.ipynb docs\notebooks\05_example_transmon_xgate.ipynb
coverage: false
- title: MacOS
os: macos-latest
python: 3.8
commands: $tox -e py38-test -- $default_tests docs/notebooks/01_example_simple_state_to_state.ipynb
commands: hatch run cov -- $default_tests docs/notebooks/01_example_simple_state_to_state.ipynb
coverage: true
- title: Notebook 1 (State-to-State)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/01_example_simple_state_to_state.ipynb
commands: hatch run cov -- docs/notebooks/01_example_simple_state_to_state.ipynb
coverage: true
- title: Notebook 2 (RWA)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/02_example_lambda_system_rwa_complex_pulse.ipynb
commands: hatch run cov -- docs/notebooks/02_example_lambda_system_rwa_complex_pulse.ipynb
coverage: true
- title: Notebook 3 (Non-Hermitian)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/03_example_lambda_system_rwa_non_hermitian.ipynb
commands: hatch run cov -- docs/notebooks/03_example_lambda_system_rwa_non_hermitian.ipynb
coverage: true
- title: Notebook 4 (Density Matrix)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/04_example_dissipative_qubit_reset.ipynb
commands: hatch run cov -- docs/notebooks/04_example_dissipative_qubit_reset.ipynb
coverage: true
- title: Notebook 5 (Quantum Gate)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/05_example_transmon_xgate.ipynb
commands: hatch run cov -- docs/notebooks/05_example_transmon_xgate.ipynb
coverage: true
- title: Notebook 6 (3 States)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/06_example_3states.ipynb
commands: hatch run cov -- docs/notebooks/06_example_3states.ipynb
coverage: true
- title: Notebook 7 (Perfect Entanglers)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/07_example_PE.ipynb
commands: hatch run cov -- docs/notebooks/07_example_PE.ipynb
coverage: true
- title: Notebook 8 (Ensemble Optimization)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/08_example_ensemble.ipynb
commands: hatch run cov -- docs/notebooks/08_example_ensemble.ipynb
coverage: true
- title: Notebook 9 (NumPy)
os: ubuntu-18.04
os: ubuntu-22.04
python: 3.8
commands: $tox -e py38-test -- docs/notebooks/09_example_numpy.ipynb
commands: hatch run cov -- docs/notebooks/09_example_numpy.ipynb
coverage: true
steps:
- uses: actions/checkout@v2
Expand All @@ -100,15 +104,10 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get install pandoc pandoc-citeproc liblapack-dev libblas-dev gfortran

- name: Install miniconda
if: runner.os == 'Windows'
uses: conda-incubator/setup-miniconda@v2
- name: Install Hatch
uses: pypa/hatch@install
with:
auto-update-conda: true
python-version: ${{ matrix.python }}

- name: Install Tox
run: pip install tox
version: 1.11.1

- name: Run Commands
run: ${{ matrix.commands }}
Expand All @@ -117,10 +116,10 @@ jobs:
if: matrix.coverage == true
shell: bash
run: |
runenv=$(echo "${{ matrix.python }}" | sed 's/\([2-3]\)\.\([0-9]\)/py\1\2-runcmd/')
$tox -e $runenv -- python -m coverage xml
hatch run -- python -m coverage xml
- uses: codecov/codecov-action@v1
- name: Upload coverage to Codecov
if: matrix.coverage == true
with:
verbose: false
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ repos:
language: script
- id: black
name: black
entry: ./scripts/pre-commit.py black
entry: hatch run lint:black-check --
types: [python]
language: script
language: system
- id: isort
name: isort
entry: ./scripts/pre-commit.py isort
entry: hatch run lint:isort-check --
types: [python]
language: script
language: system
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ disable=invalid-name,
no-else-return,
ungrouped-imports,
unnecessary-lambda,

non-ascii-name,


# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
Loading

0 comments on commit f527cb6

Please sign in to comment.