Skip to content

Commit

Permalink
Combine validate and pytest.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed Jun 6, 2024
1 parent 1d99df1 commit 357a5e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 51 deletions.
62 changes: 18 additions & 44 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,40 @@ jobs:
- name: Untar install
run: tar --use-compress-program='zstd -10 -T0' -xvf install.tar

### Unit tests
- name: Run pytest (serial)
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1

- name: Run pytest (mpi)
if: ${{ contains(inputs.config, 'mpi') }}
run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 || (( cat pytest.out.1 && exit 1 ))

- name: Run pytest (serial without cupy)
if: ${{ contains(inputs.config, 'cuda') }}
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -m cupy_optional
env:
_HOOMD_DISALLOW_CUPY_: 1

- name: Run pytest (mpi without cupy)
if: ${{ contains(inputs.config, 'cuda') && contains(inputs.config, 'mpi') }}
run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -m cupy_optional || (( cat pytest.out.1 && exit 1 ))
env:
_HOOMD_DISALLOW_CUPY_: 1

### Validation tests
- name: Run pytest (serial)
if: ${{ !contains(inputs.config, 'mpi') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }}
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate

- name: Run pytest (mpi)
if: ${{ contains(inputs.config, 'mpi') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }}
run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate || (( cat pytest.out.1 && exit 1 ))

- name: Run howto guides (serial)
if: ${{ contains(inputs.config, 'llvm') && contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }} # some examples require LLVM
run: 'for i in *.py; do echo "Running howto: $i" && python3 $i || exit 1; done'
working-directory: code/sphinx-doc/howto

- name: Clean workspace
run: ( shopt -s dotglob nullglob; rm -rf ./* )
shell: bash
Expand Down Expand Up @@ -218,47 +236,3 @@ jobs:
- name: Clean HOME
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* )
shell: bash


validate:
needs: build
runs-on: ${{ fromJson(inputs.test_runner) }}
container:
image: glotzerlab/ci:2024.06.04-${{ inputs.container_prefix }}
options: ${{ inputs.test_docker_options }} -e CUDA_VISIBLE_DEVICES

if: ${{ contains(github.event.pull_request.labels.*.name, 'validate') && inputs.validate == 'true' }}
steps:
- name: Clean workspace
run: ( shopt -s dotglob nullglob; rm -rf ./* )
shell: bash
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
path: code
submodules: true

- name: Download install
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: install-${{ inputs.config }}-${{ github.sha }}
- name: Untar install
run: tar --use-compress-program='zstd -10 -T0' -xvf install.tar

- name: Run pytest (serial)
if: ${{ !contains(inputs.config, 'mpi') }}
run: python3 -m pytest --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate
- name: Run pytest (mpi)
if: ${{ contains(inputs.config, 'mpi') }}
run: mpirun -n 2 ${GITHUB_WORKSPACE}/install/hoomd/pytest/pytest-openmpi.sh --pyargs hoomd -x -v -ra --durations=0 --durations-min=0.1 -p hoomd.pytest_plugin_validate -m validate --validate || (( cat pytest.out.1 && exit 1 ))
- name: Run howto guides (serial)
if: ${{ contains(inputs.config, 'llvm') }} # some examples require LLVM
run: 'for i in *.py; do echo "Running howto: $i" && python3 $i || exit 1; done'
working-directory: code/sphinx-doc/howto

- name: Clean workspace
run: ( shopt -s dotglob nullglob; rm -rf ./* )
shell: bash
- name: Clean HOME
run: ( shopt -s dotglob nullglob; rm -rf $HOME/* )
shell: bash
15 changes: 8 additions & 7 deletions .github/workflows/tests_new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ on:
jobs:
start_action_runners:
name: Start action runners
runs-on: ubuntu-latest
steps:
- name: Use jetstream2-admin/start
uses: glotzerlab/jetstream2-admin/[email protected]
with:
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
uses: glotzerlab/jetstream2-admin/.github/workflows/start.yaml@c5d1d59b0b3e069b611f4002bbba4d5ff8e01c60
secrets: inherit

typical:
name: "${{ join(matrix.config, '_') }}"
needs: start_action_runners
uses: ./.github/workflows/build_and_test.yaml
with:
config: ${{ join(matrix.config, '_') }}
Expand Down Expand Up @@ -72,6 +68,7 @@ jobs:
release:
if: ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
name: "${{ join(matrix.config, '_') }}"
needs: start_action_runners
uses: ./.github/workflows/build_and_test.yaml
with:
config: ${{ join(matrix.config, '_') }}
Expand All @@ -82,6 +79,10 @@ jobs:
# Default to false when unset
validate: ${{ matrix.validate == '' && 'false' || matrix.validate }}

# TODO: possible to implelemtn fallback to `ubuntu-latest` when actions runners are offline?

# runs-on: ${{ needs.start_workflow.outputs.exit_code == 3 && 'ubuntu-20.04' || 'ubuntu-24.04' }}

strategy:
fail-fast: false
matrix:
Expand Down

0 comments on commit 357a5e9

Please sign in to comment.