diff --git a/.coveragerc b/.coveragerc index d0a34a3..d3616aa 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,6 +2,7 @@ [report] show_missing = True omit = + /usr/* venv/* tests/* src/fastapi_quickcrud/misc/abstract_execute.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..253caa7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,182 @@ +# This is a basic workflow to help you get started with Actions + +name: Publish Python 🐍 distributions 📦 to PyPI + +on: + push: + tags: + - '**' + +jobs: + ciPython37: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ 3.7 ] + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: ci_db_test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Enable Postgres Trigram Extension + run: | + PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" + - name: Test with unittest + env: + TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test + TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test + run: | + python -m unittest discover -s ./tests/test_implementations + ciPython38: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ 3.8 ] + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: ci_db_test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Enable Postgres Trigram Extension + run: | + PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" + - name: Test with unittest + env: + TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test + TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test + run: | + python -m unittest discover -s ./tests/test_implementations + ciPython39: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ 3.9 ] + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: ci_db_test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Enable Postgres Trigram Extension + run: | + PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" + - name: Test with unittest + env: + TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test + TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test + run: | + python -m unittest discover -s ./tests/test_implementations + ciPython310: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.10' ] + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: ci_db_test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Enable Postgres Trigram Extension + run: | + PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" + - name: Test with unittest + env: + TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test + TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test + run: | + python -m unittest discover -s ./tests/test_implementations + build-n-publish: + needs: [ciPython37, ciPython38, ciPython39,ciPython310] + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.7 + uses: actions/setup-python@v3 + with: + python-version: "3.7" + - name: Set release version env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Release version + run: | + echo $RELEASE_VERSION + echo ${{ env.RELEASE_VERSION }} + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file