Skip to content

use tox

use tox #37

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:
CRDS_PATH: /tmp/crds_cache
PYSYN_CDBS: /tmp/trds
jobs:
build:
uses: ./.github/workflows/build.yaml
unit_tests:
needs: [ build ]
strategy:
fail-fast: false
matrix:
package: [ wfpc2tools ]
runs-on: [ ubuntu-latest, macos-latest ]
python-version: [ '3.9', '3.10', '3.11' ]
include:
#- package: pysynphot
# extras: [ test ]
- package: wfpc2tools
exclude:
- runs-on: macos-latest
python-version: '3.9'
- runs-on: macos-latest
python-version: '3.10'
runs-on: ${{ matrix.runs-on }}
name: ${{ matrix.package }} (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})
steps:
- 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 }}
conda
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: conda env export --no-build | grep -v "name:" | grep -v "prefix:"
- if: matrix.env.CRDS_SERVER_URL != ''
run: echo "context=$(crds list --operational-context)" >> $GITHUB_OUTPUT
id: crds-context
env:
CRDS_SERVER_URL: ${{ matrix.env.CRDS_SERVER_URL }}
- if: steps.crds-context.outputs.context != ''
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}
key: crds-${{ matrix.package }}-${{ steps.crds-context.outputs.context }}
- run: pytest -n auto ${{ matrix.args }} --pyargs ${{ matrix.package }}
env:
CRDS_SERVER_URL: ${{ matrix.env.CRDS_SERVER_URL }}
unit_tests_from_source:
needs: [ build ]
strategy:
matrix:
package: [ hstcal ]
runs-on: [ ubuntu-latest, macos-latest ]
python-version: [ '3.9', '3.10', '3.11' ]
include:
#- package: crds
# repository: spacetelescope/crds
# extras: [ test ]
# env:
# CRDS_SERVER_URL: https://hst-crds.stsci.edu
# pre_command: './setup_test_cache $HOME && source envs/hst-crds-ops.sh'
#- package: drizzlepac
# repository: spacetelescope/drizzlepac
# extras: [ test ]
- package: hstcal
repository: spacetelescope/hstcal
args: --slow
test_directory: tests
env:
CRDS_SERVER_URL: https://hst-crds.stsci.edu
#- package: stistools
# repository: spacetelescope/stistools
# - package: stsynphot
# repository: spacetelescope/stsynphot_refactor
# extras: [ test ]
exclude:
- runs-on: macos-latest
python-version: '3.9'
- runs-on: macos-latest
python-version: '3.10'
fail-fast: false
runs-on: ${{ matrix.runs-on }}
name: ${{ matrix.package }} (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})
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 }}
conda
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=$(conda 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 }}
- if: matrix.extras != ''
run: pip install -e ".[${{ join(matrix.extras, ',') }}]"
working-directory: ${{ matrix.package }}
- run: conda env export --no-build | grep -v "name:" | grep -v "prefix:"
- if: matrix.env.CRDS_SERVER_URL != ''
run: echo "context=$(crds list --operational-context)" >> $GITHUB_OUTPUT
id: crds-context
env:
CRDS_SERVER_URL: ${{ matrix.env.CRDS_SERVER_URL }}
- if: steps.crds-context.outputs.context != ''
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}
key: crds-${{ matrix.package }}-${{ steps.crds-context.outputs.context }}
- if: matrix.pre_command != ''
run: ${{ matrix.pre_command }}
working-directory: ${{ matrix.package }}
- run: pytest -n auto ${{ matrix.args }} ${{ matrix.test_directory }}
env:
CRDS_SERVER_URL: ${{ matrix.env.CRDS_SERVER_URL }}
working-directory: ${{ matrix.package }}
unit_tests_via_tox:
needs: [ build ]
strategy:
matrix:
package: [ acstools, asdf, calcos, ccdproc, costools, synphot, jwst ]
runs-on: [ ubuntu-latest, macos-latest ]
python-factor: [ py39, py310, py311 ]
include:
- package: acstools
repository: spacetelescope/acstools
default_factors: test-alldeps
args: --remote-data -v
- package: asdf
repository: asdf-format/asdf
default_factors: parallel
- package: calcos
repository: spacetelescope/calcos
default_factors: xdist
- package: ccdproc
repository: astropy/ccdproc
default_factors: alldeps
- package: costools
repository: spacetelescope/costools
default_factors: xdist
- package: reftools
repository: spacetelescope/reftools
default_factors: test
args: --remote-data
- package: jwst
repository: spacetelescope/jwst
default_factors: xdist
args: --slow -k "not test_cmdline_status"
exclude:
- runs-on: macos-latest
python-factor: py39
- runs-on: macos-latest
python-factor: py310
fail-fast: false
runs-on: ${{ matrix.runs-on }}
name: ${{ matrix.package }} (tox ${{ matrix.python-factor }}, ${{ matrix.runs-on }})
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 }}
conda
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=$(conda 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 }}
- run: micromamba install tox
- run: conda env export --no-build | grep -v "name:" | grep -v "prefix:"
- if: matrix.env.CRDS_SERVER_URL != ''
run: echo "context=$(crds list --operational-context)" >> $GITHUB_OUTPUT
id: crds-context
env:
CRDS_SERVER_URL: ${{ matrix.env.CRDS_SERVER_URL }}
- if: steps.crds-context.outputs.context != ''
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}
key: crds-${{ matrix.package }}-${{ steps.crds-context.outputs.context }}
- run: tox -e ${{ matrix.python-factor }}${{ matrix.default_factors != '' || '-' }}${{ matrix.default_factors }}${{ matrix.args != '' || ' -- ' }}${{ matrix.args }}
working-directory: ${{ matrix.package }}
smoke_tests:
needs: [ build ]
strategy:
matrix:
package: [ calcos, drizzlepac ]
runs-on: [ ubuntu-latest, macos-latest ]
python-version: [ '3.9', '3.10', '3.11' ]
include:
- package: calcos
run: calcos la8n01qkq_rawtag_a.fits
env:
CRDS_SERVER_URL: https://hst-crds.stsci.edu
jref: hst/references/hst/
- package: drizzlepac
run: pytest -n auto tests/test_drizzlepac.py
env:
CRDS_SERVER_URL: https://hst-crds.stsci.edu
jref: hst/references/hst/
exclude:
- runs-on: macos-latest
python-version: 3.9
- runs-on: macos-latest
python-version: 3.10
fail-fast: false
runs-on: ${{ matrix.runs-on }}
name: ${{ matrix.package }} (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})
steps:
- 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 }}
conda
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: conda env export --no-build | grep -v "name:" | grep -v "prefix:"
- if: matrix.env.CRDS_SERVER_URL != ''
run: echo "context=$(crds list --operational-context)" >> $GITHUB_OUTPUT
id: crds-context
env:
CRDS_SERVER_URL: ${{ matrix.env.CRDS_SERVER_URL }}
- if: steps.crds-context.outputs.context != ''
uses: actions/cache@v4
with:
path: ${{ env.CRDS_PATH }}
key: crds-${{ matrix.package }}-${{ steps.crds-context.outputs.context }}
- uses: actions/cache@v4
with:
path: tests/data/
key: data-${{ hashFiles('tests/data/*') }}
- run: ${{ matrix.run }}
env:
CRDS_SERVER_URL: ${{ matrix.env.CRDS_SERVER_URL }}
jref: ${{ env.CRDS_PATH }}/${{ matrix.env.jref }}