Skip to content

[pre-commit.ci] pre-commit autoupdate #50

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #50

Workflow file for this run

# Since some of the classes is still coupled to MPI, we need to run the unit tests with/without MPI.
# Also upload the code coverage report to codecov
name: unit test
permissions:
contents: read
on:
push:
branches: [ "main" ]
paths-ignore:
- 'doc/**'
- '**.md'
pull_request:
branches: [ "main" ]
paths-ignore:
- 'doc/**'
- '**.md'
workflow_dispatch:
jobs:
mpi-unit-test:
name: parallel
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
mpi_compiler: ['openmpi', 'mpich']
python_version: ['3.10']
lcov_cmd: ['--ignore-errors mismatch']
build_options:
- "-DINTERACTIVE_MODE=ON -DLIBYT_RUN_TEST=ON -DCODE_COVERAGE=ON -DUSE_PYBIND11=ON"
- "-DINTERACTIVE_MODE=ON -DLIBYT_RUN_TEST=ON -DCODE_COVERAGE=ON -DUSE_PYBIND11=OFF"
steps:
- uses: actions/checkout@v4
- name: Setup MPI ${{ matrix.mpi_compiler }} environment
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.mpi_compiler }}
- name: Setup Python ${{ matrix.python_version }} environment
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install Python packages
uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}/lib/python${{ matrix.python_version }}/site-packages/*
key: ${{ runner.os }}-pip-python${{ matrix.python_version }}-${{ matrix.mpi_compiler }}
- if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install numpy mpi4py
pip list -v
- name: Install other dependencies
run: |
sudo apt-get install -y libreadline-dev lcov
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=build-unittest-mpi" >> "$GITHUB_OUTPUT"
- name: Configure CMake (${{ matrix.build_options }})
run: |
cd ${{ github.workspace }}
rm -rf ${{ steps.strings.outputs.build-output-dir }}
cmake ${{ matrix.build_options }} -B ${{ steps.strings.outputs.build-output-dir }} -S .
- name: Build
run: |
cd ${{ github.workspace }}
cmake --build ${{ steps.strings.outputs.build-output-dir }}
- name: Run test (MPI and RMA)
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test/unit_test
run: |
OMPI_MCA_osc=sm,pt2pt mpirun -np 3 ./TestCommMPI
- name: Run test (PythonShell - MPI)
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test/unit_test
run: |
OMPI_MCA_osc=sm,pt2pt mpirun -np 3 ./TestPythonShellWithCommMPI
- name: Run test (DataStructure - MPI)
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test/unit_test
run: |
OMPI_MCA_osc=sm,pt2pt mpirun -np 3 ./TestDataStructureAmrWithCommMpi
- name: Generate code coverage report
working-directory: ${{ steps.strings.outputs.build-output-dir }}/src/CMakeFiles/yt.dir
run: |
lcov --directory . --capture ${{ matrix.lcov_cmd }} --output-file coverage.info
lcov --extract coverage.info "*/libyt/src/*" "*/libyt/include/*" -o coverage-project-only.info
- name: Upload code coverage report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ steps.strings.outputs.build-output-dir }}/src/CMakeFiles/yt.dir/coverage-project-only.info
verbose: true
unit-test:
name: serial
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
python_version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
lcov_cmd: ['--ignore-errors mismatch']
build_options:
- "-DSERIAL_MODE=ON -DINTERACTIVE_MODE=ON -DLIBYT_RUN_TEST=ON -DCODE_COVERAGE=ON -DUSE_PYBIND11=ON"
- "-DSERIAL_MODE=ON -DINTERACTIVE_MODE=ON -DLIBYT_RUN_TEST=ON -DCODE_COVERAGE=ON -DUSE_PYBIND11=OFF"
include:
- os: ubuntu-22.04
python_version: '3.7'
build_options: "-DSERIAL_MODE=ON -DINTERACTIVE_MODE=ON -DLIBYT_RUN_TEST=ON -DCODE_COVERAGE=ON -DUSE_PYBIND11=ON"
- os: ubuntu-22.04
python_version: '3.7'
build_options: "-DSERIAL_MODE=ON -DINTERACTIVE_MODE=ON -DLIBYT_RUN_TEST=ON -DCODE_COVERAGE=ON -DUSE_PYBIND11=OFF"
steps:
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python_version }} environment
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
cache: 'pip'
- run: |
python -m pip install --upgrade pip
pip install numpy
- name: Install other dependencies
run: |
sudo apt-get install -y libreadline-dev lcov
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=build-unittest" >> "$GITHUB_OUTPUT"
- name: Configure CMake (${{ matrix.build_options }})
run: |
cd ${{ github.workspace }}
rm -rf ${{ steps.strings.outputs.build-output-dir }}
cmake ${{ matrix.build_options }} -B ${{ steps.strings.outputs.build-output-dir }} -S .
- name: Build
run: |
cd ${{ github.workspace }}
cmake --build ${{ steps.strings.outputs.build-output-dir }}
- name: Run test (NumPyController)
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test/unit_test
run: |
./TestNumPyController
- name: Run test (PythonShell)
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test/unit_test
run: |
./TestPythonShell
- name: Run test (DataStructureAmr)
working-directory: ${{ steps.strings.outputs.build-output-dir }}/test/unit_test
run: |
./TestDataStructureAmr
- name: Generate code coverage report
working-directory: ${{ steps.strings.outputs.build-output-dir }}/src/CMakeFiles/yt.dir
run: |
lcov --directory . --capture ${{ matrix.lcov_cmd }} --output-file coverage.info
lcov --extract coverage.info "*/libyt/src/*" "*/libyt/include/*" -o coverage-project-only.info
- name: Upload code coverage report to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ steps.strings.outputs.build-output-dir }}/src/CMakeFiles/yt.dir/coverage-project-only.info
verbose: true