|
| 1 | +name: Test code |
| 2 | + |
| 3 | +on: |
| 4 | + # Trigger the workflow on push |
| 5 | + push: |
| 6 | + # Every branch |
| 7 | + branches: |
| 8 | + - '**' |
| 9 | + # But do not run this workflow on creating a new tag starting with 'v', e.g. 'v1.0.3' (see pypi-publish.yml) |
| 10 | + tags-ignore: |
| 11 | + - 'v*' |
| 12 | + # Trigger the workflow on pull request |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - '**' |
| 16 | + # Allows you to run this workflow manually from the Actions tab |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +# Allow only one concurrent workflow, skipping runs queued between the run in-progress and latest queued. |
| 20 | +# And cancel in-progress runs. |
| 21 | +concurrency: |
| 22 | + group: |
| 23 | + ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + test-code: |
| 28 | + |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + os: [ubuntu-24.04, windows-2022, macos-13, macos-14] |
| 33 | + python-version: ['3.12'] |
| 34 | + |
| 35 | + runs-on: ${{ matrix.os }} |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout repository |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Set up Python ${{ matrix.python-version }} |
| 42 | + uses: actions/setup-python@v5 |
| 43 | + with: |
| 44 | + python-version: ${{ matrix.python-version }} |
| 45 | + |
| 46 | + - name: Upgrade package installer for Python |
| 47 | + shell: bash |
| 48 | + run: python -m pip install --upgrade pip |
| 49 | + |
| 50 | + - name: Install Python dependencies |
| 51 | + shell: bash |
| 52 | + run: python -m pip install -r requirements.txt |
| 53 | + |
| 54 | + # Check if tutorials as python scripts run without errors |
| 55 | + # Run all Python scripts in the folder tutorials/ in parallel |
| 56 | + # -n 1: run one script per Python invocation |
| 57 | + # -P 0: run as many in parallel as you have cores (auto mode) |
| 58 | + - name: Run tutorials as python scripts |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + export PYTHONPATH=$(pwd)/src:$PYTHONPATH |
| 62 | + find tutorials/ -name "*.py" | xargs -n 1 -P 0 python |
| 63 | +
|
| 64 | + # Check if tutorials as Jupyter Notebooks run without errors |
| 65 | + # Convert all Python scripts in the folder tutorials/ to Jupyter Notebooks |
| 66 | + # Run all Jupyter Notebooks in the folder tutorials/ in parallel |
| 67 | + # -n=auto: run as many in parallel as you have cores (auto mode) |
| 68 | + # --nbmake-timeout=300: set timeout to 300 seconds |
| 69 | + - name: Run tutorials as Jupyter Notebooks |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + export PYTHONPATH=$(pwd)/src:$PYTHONPATH |
| 73 | + jupytext tutorials/*.py --to ipynb |
| 74 | + python -m pytest --nbmake tutorials/ --nbmake-timeout=300 --color=yes -n=auto |
0 commit comments