+ pyyaml requirement #74
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/cd | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
PROJECT_NAME: pg_upsert | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: 5432 | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: dev | |
jobs: | |
tests: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
python-version: | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
services: | |
postgres: | |
image: postgis/postgis:16-3.4-alpine | |
env: | |
POSTGRES_USER: ${{ env.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
POSTGRES_DB: ${{ env.POSTGRES_DB }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Import PostgreSQL data | |
run: >- | |
psql -h ${{ env.POSTGRES_HOST }} -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} -f tests/data.sql | |
env: | |
PGPASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Test with pytest | |
run: | | |
python -m pip install pytest | |
python -m pytest | |
env: | |
POSTGRES_HOST: ${{ env.POSTGRES_HOST }} | |
POSTGRES_PORT: ${{ env.POSTGRES_PORT }} | |
POSTGRES_USER: ${{ env.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
POSTGRES_DB: ${{ env.POSTGRES_DB }} | |
build: | |
name: Build distribution 📦 | |
runs-on: ubuntu-latest | |
needs: [tests] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Build binary distribution package | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
python -m pip install --upgrade build | |
python -m build --sdist --wheel --outdir dist/ | |
- name: Store the distribution package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
path: dist/ | |
publish: | |
name: PyPI Publish 🚀 | |
needs: [build] | |
runs-on: ubuntu-latest | |
# if: startsWith(github.ref, 'refs/tags/v') | |
environment: | |
name: pypi | |
url: https://pypi.org/p/${{ env.PROJECT_NAME }} | |
permissions: | |
id-token: write | |
steps: | |
- name: Download the dist | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
path: dist/ | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
docker-build: | |
name: Docker Build+Push | |
needs: [build] | |
uses: geocoug/github-actions-templates/.github/workflows/docker-build.yml@main | |
# if: startsWith(github.ref, 'refs/tags/v') | |
permissions: | |
contents: read | |
packages: write | |
pull-requests: write | |
with: | |
ghcr-enable: true | |
image-names: | | |
ghcr.io/${{ github.repository }} | |
tag-rules: | | |
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} | |
type=ref,event=pr | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=raw,value=gha-${{ github.run_id }} | |
platforms: linux/amd64,linux/arm64 |