diff --git a/.github/workflows/python_testing.yml b/.github/workflows/python_testing.yml index cf95cc25..8fdcfb5e 100644 --- a/.github/workflows/python_testing.yml +++ b/.github/workflows/python_testing.yml @@ -5,64 +5,57 @@ name: CalCOS Pytest on: push: - branches: [ pytest ] + branches: + - master pull_request: - branches: [ pytest ] - schedule: - - cron: '00 00 * * *' # every day at midnight + branches: + - master jobs: - build: - name: ${{ matrix.name }} - runs-on: ${{ matrix.runs-on }} - env: + check: + name: ${{ matrix.toxenv }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + toxenv: [ check-style, check-build ] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: 'tox.ini' + - run: pip install tox + - run: tox -e ${{ matrix.toxenv }} + test: + name: ${{ matrix.toxenv }} (Python ${{ matrix.python }}, ${{ matrix.os }}) + runs-on: ${{ matrix.os }} + env: TEST_BIGDATA: https://bytesalad.stsci.edu/artifactory lref: /grp/hst/cdbs/lref/ - working-directory: ./ strategy: fail-fast: false matrix: + toxenv: [ test-xdist ] + python: [ '3.8', '3.9', '3.10', '3.11' ] + os: [ ubuntu-latest,macos-latest ] include: - - name: Python 3.10 - runs-on: ubuntu-latest - python-version: '3.10' - toxenv: py310 - - - name: Python 3.9 - runs-on: ubuntu-latest - python-version: 3.9 - toxenv: py39 - - - name: Python 3.8 - runs-on: ubuntu-latest - python-version: 3.8 - toxenv: py38 - + - toxenv: test-cov-xdist + os: ubuntu-latest + python: '3.11' steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - pip install ci-watson - pip install astropy - pip install scipy - pip install matplotlib - pip install stsci.tools==4.0.0 - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - 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 - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - # run all the unit tests. - python setup.py install - pytest tests/test_cosutil.py -v - working-directory: ${{env.working-directory}} + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + cache: 'pip' + cache-dependency-path: 'tox.ini' + - run: pip install tox + - run: tox -e ${{ matrix.toxenv }} + - if: contains(matrix.toxenv, '-cov') + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + flags: unit + fail_ci_if_error: true diff --git a/pyproject.toml b/pyproject.toml index b22ee3cd..d765267e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,3 +5,4 @@ requires = [ "wheel", "oldest-supported-numpy", ] +build-backend = 'setuptools.build_meta' diff --git a/setup.cfg b/setup.cfg index 50b418b1..dc901d73 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,5 +8,6 @@ junit_family = xunit2 [flake8] # E265: block comment should start with '#' -ignore = E265 +# F821 undefined name +ignore = E265,F821,F841 exclude = setup.py,__init__.py diff --git a/setup.py b/setup.py index c5ba9ede..345d5b39 100755 --- a/setup.py +++ b/setup.py @@ -39,14 +39,14 @@ def c_includes(parent, depth=1): 'astropy>=5.0.4', 'numpy', 'scipy', - 'stsci.tools', + 'stsci.tools>=4.0.0', ], extras_require={ 'docs': [ 'sphinx', ], 'test': [ - 'ci_watson', + 'ci-watson', 'pytest', 'pytest-cov', 'codecov', @@ -74,6 +74,8 @@ def c_includes(parent, depth=1): author='Phil Hodge, Robert Jedrzejewski', author_email='help@stsci.edu', description='Calibration software for COS (Cosmic Origins Spectrograph)', + long_description='README.md', + long_description_content_type='text/x-rst', url='https://github.com/spacetelescope/calcos', license='BSD', classifiers=[ diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..f0aa7c4c --- /dev/null +++ b/tox.ini @@ -0,0 +1,77 @@ +[tox] +envlist = + check-{style,build} + test{,-pyargs,-warnings,-regtests,-cov}-xdist + build-{docs,dist} + +# tox environments are constructed with so-called 'factors' (or terms) +# separated by hyphens, e.g. test-devdeps-cov. Lines below starting with factor: +# will only take effect if that factor is included in the environment name. To +# see a list of example environments that can be run, along with a description, +# run: +# +# tox -l -v +# + +[testenv:check-style] +description = check code style, e.g. with flake8 +skip_install = true +deps = + flake8 +commands = + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics {posargs} + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics {posargs} + +[testenv:check-build] +description = check build sdist/wheel and a strict twine check for metadata +skip_install = true +deps = + build + twine>=3.3 +commands = + python -m build . + twine check --strict dist/* + +[testenv] +description = + run tests + warnings: treating warnings as errors + regtests: with --bigdata and --slow flags + cov: with coverage + xdist: using parallel processing +passenv = + HOME + CRDS_* + CODECOV_* + TEST_BIGDATA + lref +extras = + test +deps = + cov: pytest-cov + xdist: pytest-xdist +commands_pre = + pip freeze +commands = + pytest --slow \ + regtests: --bigdata \ + cov: --cov --cov-report=xml \ + warnings: -W error \ + xdist: -n auto \ + {posargs} + +[testenv:build-docs] +description = invoke sphinx-build to build the HTML docs +skip_install = true +extras = + docs +commands = + sphinx-build -W docs/source docs/_build + +[testenv:build-dist] +description = build wheel and sdist +skip_install = true +deps = + build +commands = + python -m build . \ No newline at end of file