68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
name: Continuous Integration and Container Build
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test-and-package:
|
|
name: Test Backend, Build Frontend, Lint Helm & Build Container
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_USER: tryme
|
|
POSTGRES_PASSWORD: tryme_ci_password
|
|
POSTGRES_DB: trymedb_test
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 5s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.11
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install Python dependencies and run pytest
|
|
run: |
|
|
python -m venv venv
|
|
venv/bin/pip install --upgrade pip
|
|
venv/bin/pip install -e ".[dev]"
|
|
DATABASE_URL="postgresql+psycopg://tryme:tryme_ci_password@localhost:5432/trymedb_test" venv/bin/alembic upgrade head
|
|
venv/bin/pytest -v
|
|
|
|
- name: Set up Node.js 22 and build SPA
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
cache: "npm"
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Build frontend bundle
|
|
working-directory: frontend
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Extract version from version.ini and build Docker image
|
|
run: |
|
|
VERSION=$(awk -F'=[ \t]*' '/^version[ \t]*=/ {gsub(/[ \t"'\''\r]/, "", $2); print $2}' version.ini)
|
|
echo "Building trymeapp:${VERSION}"
|
|
docker build -t "trymeapp:${VERSION}" .
|
|
|
|
- name: Lint and template Helm chart (PostgreSQL and SQLite PVC modes)
|
|
run: |
|
|
helm lint ./helm-chart
|
|
helm template tryme ./helm-chart > /dev/null
|
|
helm template tryme-sqlite ./helm-chart --set database.mode=sqlite | grep -q "PersistentVolumeClaim"
|