Skip to content

Commit

Permalink
CI: Add job configuration for "python-flask"
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Nov 23, 2023
1 parent f081b5c commit 8d56fd5
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/test-python-flask.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Python / Flask

on:
pull_request:
branches: ~
paths:
- '.github/workflows/test-python-flask.yml'
- 'python-flask/**'
- 'requirements.txt'
push:
branches: [ main ]
paths:
- '.github/workflows/test-python-flask.yml'
- 'python-flask/**'
- 'requirements.txt'

# Allow job to be triggered manually.
workflow_dispatch:

# Run job each night after CrateDB nightly has been published.
schedule:
- cron: '0 3 * * *'

# Cancel in-progress jobs when pushing to the same branch.
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
test:
name: "
Python: ${{ matrix.python-version }}
CrateDB: ${{ matrix.cratedb-version }}
on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
python-version: [ '3.8', '3.12' ]
cratedb-version: [ 'nightly' ]

steps:

- name: Acquire sources
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: |
python-flask/pyproject.toml
- name: Install utilities
run: |
pip install -r requirements.txt
- name: Validate python-flask
run: |
ngr test --accept-no-venv python-flask
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
!go-gin/.idea
.venv*
*.pyc
6 changes: 6 additions & 0 deletions python-flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import base64
import hashlib
import typing as t
import sys

from datetime import datetime
from tempfile import TemporaryFile
Expand Down Expand Up @@ -400,4 +401,9 @@ def run():


if __name__ == '__main__':
if "--info" in sys.argv[1:]:
from importlib.metadata import version
app_version = version("cratedb-python-flask-guestbook-demo")
print(f"Backend API implementation of the CrateDB guestbook demo application, version {app_version}")
sys.exit(0)
run()
5 changes: 5 additions & 0 deletions python-flask/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ install = [
run = [
{cmd=".venv/bin/python app.py"},
]
check = [
{cmd="python -m py_compile app.py"},
{cmd="ruff --ignore=E713 app.py"},
{cmd="python app.py --info"},
]
2 changes: 2 additions & 0 deletions python-flask/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
poethepoet<0.25
ruff==0.1.6

0 comments on commit 8d56fd5

Please sign in to comment.