main #21
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
| # main workflow; ported from .travis.yaml | |
| name: main | |
| on: | |
| push: | |
| branches: [ '*', $default-branch ] | |
| tags: 'v*' | |
| pull_request: | |
| branches: [ $default-branch ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash -l {0} | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.13'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y build-essential libopenmpi-dev openmpi-bin python3-numpy cython3 python3-mpi4py | |
| python -m pip install --upgrade pip | |
| pip install pfft-python mpsort numba | |
| pip install build pytest pytest-mpi | |
| - name: Build | |
| run: | | |
| python -m build | |
| - name: Install | |
| run: | | |
| python -m pip install --user dist/pmesh*whl | |
| - name: Build in place for tests | |
| run: | | |
| python setup.py build_ext --inplace | |
| - name: Non-MPI python unit tests #So that the MPI_XFAIL tests run | |
| run: | | |
| python -m pytest | |
| - name: Python unit tests w varying rank | |
| run: | | |
| mpirun -n 1 python -m pytest --with-mpi | |
| mpirun -n 2 python -m pytest --with-mpi | |
| mpirun -n 4 --oversubscribe python -m pytest --with-mpi | |
| - name: Version | |
| run: bash check_tag.sh pmesh/version.py | |
| - name: Store the distribution packages | |
| if: matrix.python-version == '3.10' #Only do this once! | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/pmesh*.tar.gz | |
| #From https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
| publish-to-pypi: | |
| name: Publish to PyPI | |
| if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pmesh | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download the source dist | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |