CI #70
This file contains 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 | |
on: | |
workflow_dispatch: {} | |
push: | |
branches: [master] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: snyk/actions/setup@master | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Setup environment | |
run: | | |
echo "ARTEFACT=alph" >> $GITHUB_ENV | |
echo "ROOT_PACKAGE=alph" >> $GITHUB_ENV | |
- name: Install and configure poetry | |
run: | | |
python -m pip install poetry | |
python -m poetry config virtualenvs.in-project true | |
- name: Install deps | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
sudo apt install graphviz graphviz-dev | |
poetry install --no-root --all-extras | |
poetry add cython git+https://github.com/connectedcompany/forceatlas2.git | |
- name: Unit tests | |
run: | | |
PYTHONPATH=. poetry run pytest -s --nbmake --ignore=examples/5_flight_routes.ipynb tests/ examples/ | |
- name: Snyk package deps scan | |
run: | | |
snyk test --file=poetry.lock | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
- name: Tag and push | |
run: | | |
# remove optional dependencies that we don't distribute | |
poetry remove cython fa2 | |
# get git user deets from last commit | |
git config --local user.email "$(git log --format='%ae' HEAD^!)" | |
git config --local user.name "$(git log --format='%an' HEAD^!)" | |
poetry version patch | |
git tag v$(poetry version --short) -m "Version $(poetry version --short)" | |
git add pyproject.toml poetry.lock && git commit -m "Version $(poetry version --short)" | |
git push --follow-tags | |
- name: Build the package | |
run: | | |
poetry build | |
- name: Publish distribution 📦 to Test PyPI | |
run: | | |
poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
poetry publish --repository testpypi | |
env: | |
POETRY_HTTP_BASIC_TESTPYPI_USERNAME: __token__ | |
POETRY_HTTP_BASIC_TESTPYPI_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
# REMOVING this step as waiting for test pypi-published artefact to become available | |
# seems to take variable amounts of time - from near immediate to > 2min. | |
# If reinstated, needs to be made to work with pypi | |
# | |
# - name: Test install | |
# run: | | |
# python -mvenv venv-test-pypi | |
# source venv-test-pypi/bin/activate | |
# pip install -U pip wheel # wheel allows us to test the licence is included | |
# sleep 2m # sometimes this is needed for test pypi to catch up | |
# pip install \ | |
# --index-url https://test.pypi.org/simple/ \ | |
# --extra-index-url https://pypi.org/simple \ | |
# $ARTEFACT==$VERSION | |
# # check import | |
# python -c "import $ROOT_PACKAGE.__version__; print($ROOT_PACKAGE.__version__.__version__)" | |
# # ensure license is include | |
# # **note** the Python version and update as needed | |
# head -3 venv-test-pypi/lib/python3.8/site-packages/alph-$VERSION.dist-info/LICENSE | |
- name: Publish distribution 📦 to PyPI with Poetry | |
run: | | |
poetry publish | |
env: | |
POETRY_HTTP_BASIC_PYPI_USERNAME: __token__ | |
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |