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

2024 12 08 test dependencies #209

Merged
merged 11 commits into from
Dec 30, 2024
Merged
86 changes: 21 additions & 65 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,34 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ master ]
tags: '*'
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]

build-python-package:
uses: nion-software/github-workflows/.github/workflows/build-python-package.yml@main
secrets:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
pypi-publish:
name: Upload release to PyPI
needs: [build-python-package]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
environment: release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Build Distribution
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m build
- name: Install Test Dependencies
run: |
pip install -r test-requirements.txt
pip install --no-deps git+https://github.com/nion-software/nionswift-usim.git#egg=nionswift-usim
python -m pip install mypy
mypy --version
- name: Type Checking
run: |
# use mypy -p to work around mypy issue 8944
mypy --namespace-packages --ignore-missing-imports --follow-imports=silent --strict --no-warn-redundant-casts --no-warn-unused-ignores --exclude "/test" -p nionswift_plugin.nion_instrumentation_ui -p nion.instrumentation
- name: Test
- name: Download All Artifacts
uses: actions/download-artifact@v4
- name: Copy files to upload to PyPI to dist.
shell: bash
run: |
python -m unittest discover -s nion/instrumentation/test -p "*_test.py" -v
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
name: distribution
path: dist
- name: Publish package to PyPI
mkdir dist
find . -name "*.whl" -exec cp {} dist \;
ls -lR .
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
skip-existing: true
user: __token__
password: ${{ secrets.pypi_password }}
- name: Set up Miniconda for conda-build
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: '3.11'
- name: Build/publish anaconda package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
shell: bash -l {0}
run: |
# make a directory to avoid name conflicts with the channel. argh.
mkdir conda_build
pushd conda_build
conda update -n base --all -y
conda update --all -y
conda install conda-build anaconda-client -y
conda build -q --python ${{ matrix.python-version }} -c nion -c conda-forge --override-channels --skip-existing --user nion --token ${{ secrets.anaconda_token }} ..
popd
print-hash: true
1 change: 1 addition & 0 deletions meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ requirements:

test:
imports:
- nion.device_kit
- nion.instrumentation
- nion.instrumentation.test
- nionswift_plugin.nion_instrumentation_ui
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ follow_imports = silent
strict = True
warn_redundant_casts = False
warn_unused_ignores = False
packages = nionswift_plugin.nion_instrumentation_ui, nion.instrumentation
packages = nionswift_plugin.nion_instrumentation_ui, nion.instrumentation, nion.device_kit
exclude = /test
Loading
Loading