PyMC 5 migration #55
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: PyPI release | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Build the sdist and the wheel | |
| run: | | |
| pip install build | |
| python -m build | |
| - name: Check the sdist installs and imports | |
| run: | | |
| mkdir -p test-sdist | |
| cd test-sdist | |
| python -m venv venv-sdist | |
| venv-sdist/bin/python -m pip install ../dist/homepy*.tar.gz | |
| echo "Checking import and version number (on release)" | |
| venv-sdist/bin/python -c "import homepy; assert homepy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else homepy.__version__; print(homepy.__version__)" | |
| cd .. | |
| - name: Check the bdist installs and imports | |
| run: | | |
| mkdir -p test-bdist | |
| cd test-bdist | |
| python -m venv venv-bdist | |
| venv-bdist/bin/python -m pip install ../dist/homepy*.whl | |
| echo "Checking import and version number (on release)" | |
| venv-bdist/bin/python -c "import homepy; assert homepy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else homepy.__version__; print(homepy.__version__)" | |
| cd .. | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: artifact | |
| path: dist/* | |
| integration_test: | |
| name: Run integration tests on release candidate | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| strategy: | |
| fail-fast: true | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Cache conda | |
| uses: actions/cache@v3 | |
| env: | |
| # Increase this value to reset cache if environment-test.yml has not changed | |
| CACHE_NUMBER: 0 | |
| with: | |
| path: ~/conda_pkgs_dir | |
| key: ${{ runner.os }}-py3.10-conda-${{ env.CACHE_NUMBER }}-${{ | |
| hashFiles('envs/environment-test.yml') }} | |
| - uses: conda-incubator/setup-miniconda@v2 | |
| with: | |
| miniforge-variant: Mambaforge | |
| miniforge-version: latest | |
| mamba-version: "*" | |
| activate-environment: homepy | |
| channel-priority: strict | |
| environment-file: envs/environment-test.yml | |
| python-version: '3.10' | |
| use-mamba: true | |
| use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! | |
| - name: Install-package | |
| run: | | |
| pip install -e .[dev] | |
| python --version | |
| # Verify PyMC v5 is installed | |
| python -c "import pymc; print(f'PyMC version: {pymc.__version__}'); assert pymc.__version__.startswith('5'), 'PyMC v5 required'" | |
| - name: Run tests | |
| run: | | |
| conda activate homepy | |
| python homepy/tests/integration_test.py | |
| pypi_test: | |
| name: Upload to Test PyPI | |
| needs: [integration_test] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| steps: | |
| - uses: actions/download-artifact@v3 | |
| with: | |
| name: artifact | |
| path: dist | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip_existing: true | |
| user: __token__ | |
| password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
| repository_url: https://test.pypi.org/legacy/ | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Test pip install from test.pypi | |
| run: | | |
| # Give time to test.pypi to update its index. If we don't wait, | |
| # we might request to install before test.pypi is aware that it actually has the package | |
| sleep 5s | |
| python -m venv venv-test-pypi | |
| venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple homepy | |
| # check import | |
| venv-test-pypi/bin/python -c "import homepy; assert homepy.__version__ == '${{ github.ref_name }}'" | |
| publish: | |
| name: Upload release to PyPI | |
| needs: [pypi_test] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| steps: | |
| - uses: actions/download-artifact@v3 | |
| with: | |
| name: artifact | |
| path: dist | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} |