Skip to content

replace usage of tox with direct pytest commands #147

replace usage of tox with direct pytest commands

replace usage of tox with direct pytest commands #147

Workflow file for this run

name: tests
on:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: micromamba-shell {0}
env:
PYSYN_CDBS: /tmp/trds
jref: https://ssb.stsci.edu/trds_open/jref
CRDS_CLIENT_RETRY_COUNT: 3
CRDS_CLIENT_RETRY_DELAY_SECONDS: 20
LD_LIBRARY_PATH: /usr/local/lib
jobs:
build:
uses: ./.github/workflows/build.yaml
unit_tests:
needs: [ build, crds_contexts ]
strategy:
fail-fast: false
matrix:
package: [ acstools, asdf, calcos, ccdproc, costools, jwst, reftools, synphot, wfpc2tools ]
# the macOS 13 runner is on Intel hardware
runs-on: [ ubuntu-latest, macos-13, macos-latest ]
python-version: [ '3.10', '3.11', '3.12' ]
include:
- package: acstools
extras: [ all, test ]
pytest-args: --remote-data -v
- package: asdf
extras: [ all, tests ]
pytest-args: --remote-data --durations=10
- package: calcos
extras: [ test ]
pytest-args: --slow
- package: ccdproc
extras: [ test ]
pytest-args: -W ignore
- package: costools
extras: [ test ]
- package: jwst
extras: [ test ]
observatory: jwst
#- package: pysynphot
# extras: [ test ]
- package: reftools
extras: [ test ]
- package: synphot
extras: [ test ]
pytest-args: --remote-data
- package: wfpc2tools
exclude:
- runs-on: macos-13
python-version: '3.10'
- runs-on: macos-13
python-version: '3.11'
- runs-on: macos-latest
python-version: '3.10'
- runs-on: macos-latest
python-version: '3.11'
runs-on: ${{ matrix.runs-on }}
name: "`${{ matrix.package }}` (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})"
env:
CRDS_PATH: /tmp/crds_cache
steps:
- if: matrix.crds_observatory != ''
run: |
echo CRDS_OBSERVATORY=${{ matrix.crds_observatory }} >> $GITHUB_ENV
echo CRDS_SERVER_URL=${{ matrix.crds_observatory }}-crds.stsci.edu >> $GITHUB_ENV
echo CRDS_CONTEXT=${{ matrix.crds_observatory == 'hst' && needs.crds_contexts.outputs.hst || matrix.crds_observatory == 'jwst' && needs.crds_contexts.outputs.jwst || matrix.crds_observatory == 'roman' && needs.crds_contexts.outputs.roman || '' }} >> $GITHUB_ENV
shell: bash
- if: env.CRDS_CONTEXT != ''
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}
key: crds-${{ matrix.package }}-${{ env.CRDS_CONTEXT }}
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: stenv-${{ runner.os }}-py${{ matrix.python-version }}
environment-file: environment.yaml
create-args: >-
python=${{ matrix.python-version }}
cache-downloads: true
cache-downloads-key: downloads-${{ needs.build.outputs.date }}
cache-environment: true
cache-environment-key: environment-${{ needs.build.outputs.date }}
init-shell: none
generate-run-shell: true
- if: matrix.extras != ''
run: pip install "${{ matrix.package }}[${{ join(matrix.extras, ',') }}]"
- run: pip install pytest-xdist
- run: pip list
- run: pytest -n auto ${{ matrix.pytest-args }}
unit_tests_from_source:
needs: [ build, crds_contexts ]
strategy:
matrix:
package: [ hstcal ]
# the macOS 13 runner is on Intel hardware
runs-on: [ ubuntu-latest, macos-13, macos-latest ]
python-version: [ '3.10', '3.11', '3.12' ]
include:
#- package: drizzlepac
# repository: spacetelescope/drizzlepac
# extras: [ test ]
- package: hstcal
repository: spacetelescope/hstcal
dependencies: crds ci_watson pytest pytest-xdist
pytest-args: --slow
test_directory: tests
crds_observatory: hst
#- package: stistools
# repository: spacetelescope/stistools
# - package: stsynphot
# repository: spacetelescope/stsynphot_refactor
# extras: [ test ]
exclude:
- runs-on: macos-13
python-version: '3.10'
- runs-on: macos-13
python-version: '3.11'
- runs-on: macos-latest
python-version: '3.10'
- runs-on: macos-latest
python-version: '3.11'
fail-fast: false
runs-on: ${{ matrix.runs-on }}
name: "`${{ matrix.package }}` (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})"
env:
CRDS_PATH: /tmp/crds_cache
steps:
- if: matrix.crds_observatory != ''
run: |
echo CRDS_OBSERVATORY=${{ matrix.crds_observatory }} >> $GITHUB_ENV
echo CRDS_SERVER_URL=${{ matrix.crds_observatory }}-crds.stsci.edu >> $GITHUB_ENV
echo CRDS_CONTEXT=${{ matrix.crds_observatory == 'hst' && needs.crds_contexts.outputs.hst || matrix.crds_observatory == 'jwst' && needs.crds_contexts.outputs.jwst || matrix.crds_observatory == 'roman' && needs.crds_contexts.outputs.roman || '' }} >> $GITHUB_ENV
shell: bash
- if: env.CRDS_CONTEXT != ''
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}
key: crds-${{ matrix.package }}-${{ env.CRDS_CONTEXT }}
- uses: actions/checkout@v4
with:
path: stenv
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: stenv-${{ runner.os }}-py${{ matrix.python-version }}
environment-file: stenv/environment.yaml
create-args: >-
python=${{ matrix.python-version }}
cache-downloads: true
cache-downloads-key: downloads-${{ needs.build.outputs.date }}
cache-environment: true
cache-environment-key: environment-${{ needs.build.outputs.date }}
init-shell: none
generate-run-shell: true
- run: echo "version=$(pip list | awk '$1 == "${{ matrix.package }}" {print $2}')" >> $GITHUB_OUTPUT
id: package_version
# TODO: figure out a better way to use package version when checking out a Git ref
- uses: actions/checkout@v4
with:
path: ${{ matrix.package }}
repository: ${{ matrix.repository }}
ref: ${{ steps.package_version.outputs.version }}
fetch-depth: 0
- if: matrix.extras != ''
run: pip install -e ".[${{ join(matrix.extras, ',') }}]"
working-directory: ${{ matrix.package }}
- if: matrix.dependencies != ''
run: pip install ${{ matrix.dependencies }}
- run: pip list
- if: matrix.pre_command != ''
run: ${{ matrix.pre_command }}
working-directory: ${{ matrix.package }}
- run: pytest -n auto ${{ matrix.pytest-args }} ${{ matrix.test_directory }}
working-directory: ${{ matrix.package }}
crds_contexts:
uses: spacetelescope/crds/.github/workflows/contexts.yml@master
crds_test_cache:
uses: spacetelescope/crds/.github/workflows/cache.yml@master
crds_tests:
needs: [ build, crds_test_cache ]
strategy:
fail-fast: false
matrix:
package: [ crds ]
# the macOS 13 runner is on Intel hardware
runs-on: [ ubuntu-latest, macos-13, macos-latest ]
python-version: [ '3.10', '3.11', '3.12' ]
include:
- package: crds
repository: spacetelescope/crds
exclude:
- runs-on: macos-13
python-version: '3.10'
- runs-on: macos-13
python-version: '3.11'
- runs-on: macos-latest
python-version: '3.10'
- runs-on: macos-latest
python-version: '3.11'
runs-on: ${{ matrix.runs-on }}
name: "`${{ matrix.package }}` (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})"
env:
CRDS_PATH: /tmp/crds-cache-default-test
CRDS_TEST_ROOT: /tmp
CRDS_TESTING_CACHE: /tmp/crds-cache-test
CRDS_SERVER_URL: https://hst-crds.stsci.edu
steps:
- uses: actions/checkout@v4
with:
path: stenv
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: stenv-${{ runner.os }}-py${{ matrix.python-version }}
environment-file: stenv/environment.yaml
create-args: >-
python=${{ matrix.python-version }}
cache-downloads: true
cache-downloads-key: downloads-${{ needs.build.outputs.date }}
cache-environment: true
cache-environment-key: environment-${{ needs.build.outputs.date }}
init-shell: none
generate-run-shell: true
- run: micromamba install -y filelock requests
- run: pip install parsely roman-datamodels git+https://github.com/spacetelescope/jwst
- run: pip list
- run: echo "version=$(pip list | awk '$1 == "${{ matrix.package }}" {print $2}')" >> $GITHUB_OUTPUT
id: package_version
# TODO: figure out a better way to use package version when checking out a Git ref
- uses: actions/checkout@v4
with:
path: ${{ matrix.package }}
repository: ${{ matrix.repository }}
ref: ${{ steps.package_version.outputs.version }}
fetch-depth: 0
- run: pip uninstall --yes crds && ./install && pip install .[submission,test,docs,synphot]
working-directory: ${{ matrix.package }}
- uses: actions/cache@v4
with:
path: |
${{ needs.crds_test_cache.outputs.path }}
${{ needs.crds_test_cache.outputs.testing_cache }}
key: ${{ needs.crds_test_cache.outputs.key }}
- run: ./runtests --cover
working-directory: ${{ matrix.package }}
smoke_tests:
needs: [ build ]
strategy:
matrix:
package: [ calcos, drizzlepac ]
# the macOS 13 runner is on Intel hardware
runs-on: [ ubuntu-latest, macos-13, macos-latest ]
python-version: [ '3.10', '3.11', '3.12' ]
include:
- package: calcos
run: calcos la8n01qkq_rawtag_a.fits
crds_observatory: hst
jref: hst/references/hst
- package: drizzlepac
run: pytest -n auto tests/test_drizzlepac.py
crds_observatory: hst
jref: hst/references/hst
exclude:
- runs-on: macos-13
python-version: '3.10'
- runs-on: macos-13
python-version: '3.11'
- runs-on: macos-latest
python-version: '3.10'
- runs-on: macos-latest
python-version: '3.11'
fail-fast: false
runs-on: ${{ matrix.runs-on }}
name: "smoke test `${{ matrix.package }}` (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})"
env:
CRDS_PATH: /tmp/crds_cache
jref: /tmp/crds_cache/${{ matrix.jref }}
steps:
- if: matrix.crds_observatory != ''
run: |
echo CRDS_OBSERVATORY=${{ matrix.crds_observatory }} >> $GITHUB_ENV
echo CRDS_SERVER_URL=${{ matrix.crds_observatory }}-crds.stsci.edu >> $GITHUB_ENV
echo CRDS_CONTEXT=${{ matrix.crds_observatory == 'hst' && needs.crds_contexts.outputs.hst || matrix.crds_observatory == 'jwst' && needs.crds_contexts.outputs.jwst || matrix.crds_observatory == 'roman' && needs.crds_contexts.outputs.roman || '' }} >> $GITHUB_ENV
shell: bash
- if: env.CRDS_CONTEXT != ''
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}
key: crds-${{ matrix.package }}-${{ env.CRDS_CONTEXT }}
- uses: actions/checkout@v4
with:
lfs: true
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: stenv-${{ runner.os }}-py${{ matrix.python-version }}
environment-file: environment.yaml
create-args: >-
python=${{ matrix.python-version }}
cache-downloads: true
cache-downloads-key: downloads-${{ needs.build.outputs.date }}
cache-environment: true
cache-environment-key: environment-${{ needs.build.outputs.date }}
init-shell: none
generate-run-shell: true
- if: matrix.extras != ''
run: pip install ".[${{ join(matrix.extras, ',') }}]"
- run: pip install pytest-xdist
- run: pip list
- uses: actions/cache@v4
with:
path: tests/data/
key: data-${{ hashFiles('tests/data/*') }}
- run: ${{ matrix.run }}