Skip to content

Add test for API stability for a CausalPy example in Causal Inference and Discovery in Python by Aleksander Molak #625

Add test for API stability for a CausalPy example in Causal Inference and Discovery in Python by Aleksander Molak

Add test for API stability for a CausalPy example in Causal Inference and Discovery in Python by Aleksander Molak #625

Workflow file for this run

name: PyPI release
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]
release:
types: [published]
jobs:
build:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.11
- 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/causalpy*.tar.gz
echo "Checking import and version number (on release)"
venv-sdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__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/CausalPy*.whl
echo "Checking import and version number (on release)"
venv-bdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
cd ..
- uses: actions/upload-artifact@v3
with:
name: artifact
path: dist/*
test:
name: Upload to Test PyPI
permissions:
id-token: write
needs: [build]
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
repository_url: https://test.pypi.org/legacy/
- uses: actions/setup-python@v5
with:
python-version: 3.11
- 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 causalpy
echo "Checking import and version number"
venv-test-pypi/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
publish:
environment: release
permissions:
id-token: write
name: Upload release to PyPI
needs: [build, 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