Skip to content

⬆️(project) upgrade python dependencies #574

⬆️(project) upgrade python dependencies

⬆️(project) upgrade python dependencies #574

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: API
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
build-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Pipenv
run: pipx install pipenv
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pipenv"
cache-dependency-path: "src/api/Pipfile.lock"
- name: Install dependencies
run: |
cd src/api
pipenv install -d .
lint-api:
needs: build-api
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/api
steps:
- uses: actions/checkout@v4
- name: Install pipenv
run: pipx install pipenv
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pipenv"
cache-dependency-path: "src/api/Pipfile.lock"
- name: Lint with Black
run: pipenv run black --check qualicharge tests
- name: Lint with Ruff
run: pipenv run ruff check qualicharge tests
- name: Lint with MyPy
run: pipenv run mypy qualicharge tests
test-database-migrations:
needs: build-api
runs-on: ubuntu-latest
services:
postgresql:
image: timescale/timescaledb-ha:pg14-ts2.14-oss
env:
POSTGRES_DB: test-qualicharge-api
POSTGRES_USER: qualicharge
POSTGRES_PASSWORD: pass
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
defaults:
run:
working-directory: ./src/api
steps:
- uses: actions/checkout@v4
- name: Create postgis extension
run: psql "postgresql://qualicharge:pass@localhost:5432/test-qualicharge-api" -c "create extension postgis;"
- name: Install pipenv
run: pipx install pipenv
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pipenv"
cache-dependency-path: "src/api/Pipfile.lock"
- name: Run migrations
run: pipenv run alembic -c qualicharge/alembic.ini upgrade head
env:
QUALICHARGE_DB_ENGINE: postgresql+psycopg
QUALICHARGE_DB_HOST: localhost
QUALICHARGE_DB_NAME: test-qualicharge-api
QUALICHARGE_TEST_DB_NAME: test-qualicharge-api
# This is a fake setting required to run the app
QUALICHARGE_OIDC_PROVIDER_BASE_URL: http://localhost:8080/fake
QUALICHARGE_OAUTH2_TOKEN_ENCODING_KEY: thisissupersecret
QUALICHARGE_OAUTH2_TOKEN_ISSUER: http://test:8010
QUALICHARGE_EXECUTION_ENVIRONMENT: ci
test-api:
needs: build-api
runs-on: ubuntu-latest
services:
postgresql:
image: timescale/timescaledb-ha:pg14-ts2.14-oss
env:
POSTGRES_DB: test-qualicharge-api
POSTGRES_USER: qualicharge
POSTGRES_PASSWORD: pass
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
defaults:
run:
working-directory: ./src/api
steps:
- uses: actions/checkout@v4
- name: Create postgis extension
run: psql "postgresql://qualicharge:pass@localhost:5432/test-qualicharge-api" -c "create extension postgis;"
- name: Install pipenv
run: pipx install pipenv
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pipenv"
cache-dependency-path: "src/api/Pipfile.lock"
- name: Test with pytest
run: pipenv run pytest
env:
QUALICHARGE_DB_ENGINE: postgresql+psycopg
QUALICHARGE_DB_HOST: localhost
QUALICHARGE_DB_NAME: test-qualicharge-api
QUALICHARGE_TEST_DB_NAME: test-qualicharge-api
# Speed up tests
QUALICHARGE_API_STATIQUE_BULK_CREATE_MAX_SIZE: 10
QUALICHARGE_API_STATUS_BULK_CREATE_MAX_SIZE: 10
QUALICHARGE_API_SESSION_BULK_CREATE_MAX_SIZE: 10
# This is a fake setting required to run the app
QUALICHARGE_OIDC_PROVIDER_BASE_URL: http://localhost:8080/fake
QUALICHARGE_OAUTH2_TOKEN_ENCODING_KEY: thisissupersecret
QUALICHARGE_OAUTH2_TOKEN_ISSUER: http://test:8010
QUALICHARGE_EXECUTION_ENVIRONMENT: ci