fix syntax #2088
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI Tests | |
| on: [push] | |
| jobs: | |
| tests: | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| mpi: ["none", openmpi] # mpich | |
| python: ["3.10", "3.13"] | |
| exclude: | |
| - os: macos-latest | |
| mpi: mpich | |
| python: "3.10" | |
| # Only run tests if there is no [skipci] or [skip ci] in the commit message | |
| if: | | |
| !startsWith(github.event.head_commit.message, '[skip ci]') && | |
| !startsWith(github.event.head_commit.message, '[skipci]') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| enable-cache: true | |
| prune-cache: false | |
| cache-dependency-glob: | | |
| pyproject.toml | |
| uv.lock | |
| - name: Cache virtual environment | |
| uses: actions/cache@v5 | |
| id: cache-venv | |
| with: | |
| path: .venv | |
| key: venv-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }} | |
| # Unfortunately we must use different keys to store the same data, | |
| # otherwise GitHub will complain when multiple jobs are going to | |
| # store it | |
| - name: Cache PySM3 data files | |
| id: cache-pysm3 | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/pysm3-data | |
| key: pysm3-data-${{ runner.os }}-${{ matrix.python }}-${{ matrix.mpi }}-${{ secrets.CACHE_VERSION }} | |
| - name: Register PySM3 data path | |
| run: | | |
| echo "PYSM_LOCAL_DATA=$HOME/pysm3-data" >> $GITHUB_ENV | |
| - name: Download PySM3 data files | |
| if: steps.cache-pysm3.outputs.cache-hit != 'true' | |
| run: | | |
| if [ ! -d "$PYSM_LOCAL_DATA" ] || [ -z "$(ls -A "$PYSM_LOCAL_DATA" 2>/dev/null)" ]; then | |
| git clone --depth 1 https://github.com/galsci/pysm-data "$PYSM_LOCAL_DATA" | |
| else | |
| echo "PySM data directory already exists and is not empty, skipping clone" | |
| fi | |
| - name: Install basic dependencies (MPI, FFTW, IMO) | |
| run: | | |
| ./bin/install-deps.sh ${{ matrix.mpi }} | |
| mkdir -p $HOME/.config/litebird_imo | |
| echo -e "[[repositories]]\nlocation = \"$(pwd)/test/mock_imo/\"\nname = \"Mock IMO\"" | tee $HOME/.config/litebird_imo/imo.toml | |
| - name: Install litebird_sim dependencies | |
| run: | | |
| EXTRAS="--extra dev --extra docs" | |
| if [ "${{ matrix.mpi }}" != "none" ]; then | |
| EXTRAS="$EXTRAS --extra mpi" | |
| fi | |
| uv sync $EXTRAS --locked | |
| env: | |
| DUCC0_OPTIMIZATION: none | |
| - name: Install BrahMap | |
| if: matrix.mpi != 'none' && matrix.os == 'ubuntu-latest' | |
| # if: steps.cache-venv.outputs.cache-hit != 'true' && matrix.mpi != 'none' && matrix.os == 'ubuntu-latest' | |
| run: | | |
| git clone --recursive https://github.com/anand-avinash/BrahMap.git | |
| cd BrahMap | |
| uv pip install . | |
| cd .. | |
| rm -rf BrahMap | |
| uv run python -c "import brahmap" | |
| env: | |
| DUCC0_OPTIMIZATION: none | |
| PIP_CACHE_DIR: ${{ env.UV_CACHE_DIR }} | |
| - name: Tests | |
| run: | | |
| set -euo pipefail | |
| uv run python -m pytest --cov=litebird_sim --cov-report=xml --cov-report=term --durations=5 -vv | |
| - name: Tests MPICH | |
| if: ${{ matrix.mpi == 'mpich' }} | |
| run: | | |
| # See issue #457: <https://github.com/litebird/litebird_sim/issues/457> | |
| if [[ "$(uname)" == "Darwin" ]]; then | |
| export HDF5_USE_FILE_LOCKING=FALSE | |
| fi | |
| for proc in 1 2 ; do | |
| echo "Running MPI test ($MPI) with $proc processes" | |
| PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_mpi.py | |
| PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_detector_blocks.py | |
| done | |
| echo "Running MPI test ($MPI) with 4 processes" | |
| PYTHONPATH=. mpiexec --map-by :OVERSUBSCRIBE -n 4 uv run python ./test/test_mpi_n4.py | |
| PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_detector_blocks.py | |
| - name: Tests OpenMPI | |
| if: ${{ matrix.mpi == 'openmpi' }} | |
| run: | | |
| # See issue #457: <https://github.com/litebird/litebird_sim/issues/457> | |
| if [[ "$(uname)" == "Darwin" ]]; then | |
| export HDF5_USE_FILE_LOCKING=FALSE | |
| fi | |
| for proc in 1 2 ; do | |
| echo "Running MPI test ($MPI) with $proc processes" | |
| PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_mpi.py | |
| PYTHONPATH=. mpiexec -n $proc uv run python ./test/test_detector_blocks.py | |
| done | |
| echo "Running MPI test ($MPI) with 4 processes" | |
| PYTHONPATH=. mpiexec --map-by :OVERSUBSCRIBE -n 4 uv run python ./test/test_mpi_n4.py | |
| - name: Coverage comment | |
| uses: py-cov-action/python-coverage-comment-action@v3 | |
| if: runner.os == 'Linux' | |
| with: | |
| GITHUB_TOKEN: ${{ github.token }} |