Merge branch 'release/0.5' #85
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Python package | |
on: | |
push: | |
branches: [main] | |
tags: ["*"] | |
pull_request: | |
branches: [main] | |
jobs: | |
get-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get-version.outputs.version }} | |
steps: | |
- name: Check PEP-440 style version | |
id: get-version | |
run: | | |
PEP440_VERSION="" | |
VERSION_PREFIX="v" | |
BRANCH_OR_TAG="$(echo ${{ github.event.ref }} | cut -d / -f 3)" | |
if [[ "${BRANCH_OR_TAG}" =~ ^v?(([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*(\.?(a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?)$ ]] | |
then | |
PEP440_VERSION="${BRANCH_OR_TAG#$VERSION_PREFIX}" | |
fi | |
echo "PEP440_VERSION: ${PEP440_VERSION}" | |
echo "version=${PEP440_VERSION}" >> $GITHUB_OUTPUT | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
sqlalchemy-requires: | |
- SQLAlchemy[asyncio]>=1.4.3,<2.0 | |
- SQLAlchemy[asyncio]>=2.0,<3.0 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Startup databases | |
shell: bash | |
run: | | |
(cd .github && docker-compose up -d) | |
sh scripts/wait-for-postgres.sh 127.0.0.1 test | |
sh scripts/wait-for-mysql.sh 127.0.0.1 test test test | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: pip | |
- name: Install Python project | |
run: pip install -e . "${{ matrix.sqlalchemy-requires }}" | |
- name: Install Python testing requires | |
run: pip install flake8 pytest pytest-cov python-dotenv[cli] -r tests/requirements.txt | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Test with PyTest | |
shell: bash | |
run: | | |
export TEST_URLS="mysql://test:test@127.0.0.1:3306/test postgresql://postgres:test@127.0.0.1:5432/" | |
export TEST_ASYNC_URLS="mysql+aiomysql://test:test@127.0.0.1:3306/test postgresql+asyncpg://postgres:test@127.0.0.1:5432/" | |
pytest --cov src/ --cov-report xml . | |
- name: Shutdown databases | |
shell: bash | |
run: (cd .github && docker-compose down -v) | |
- name: Upload coverage reports to CodeCov with GitHub Action | |
uses: codecov/codecov-action@v3 | |
build: | |
runs-on: ubuntu-latest | |
needs: [get-version, test] | |
if: needs.get-version.outputs.version != '' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
cache: pip | |
- name: Install builder | |
run: pip install build | |
- name: Build package distributions | |
run: pyproject-build | |
- name: Upload package distributions to artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: sqlalchemy_dlock-dist-${{ needs.get-version.outputs.version }} | |
path: dist | |
if-no-files-found: error | |
retention-days: 1 | |
publish: | |
runs-on: ubuntu-latest | |
needs: [get-version, build] | |
if: needs.get-version.outputs.version != '' | |
steps: | |
- name: Download package distributions from artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: sqlalchemy_dlock-dist-${{needs.get-version.outputs.version}} | |
path: dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |