59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
name: Lab3 contracts and application
|
|
on: [push, pull_request]
|
|
permissions:
|
|
contents: read
|
|
jobs:
|
|
contracts:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
- run: python -m pip install -r requirements-dev.txt
|
|
- run: make check validate PYTHON=python
|
|
application:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
- name: Prepare local test secrets
|
|
run: |
|
|
cp .env.example .env
|
|
mkdir -p secrets
|
|
chmod 700 secrets
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
from secrets import token_urlsafe
|
|
from urllib.parse import quote
|
|
|
|
password = token_urlsafe(32)
|
|
Path('secrets/postgres_password').write_text(password + '\n')
|
|
Path('secrets/database_url').write_text(
|
|
f"postgres://messenger:{quote(password, safe='')}@postgres:5432/messenger?sslmode=disable\n"
|
|
)
|
|
PY
|
|
chmod 644 secrets/postgres_password secrets/database_url
|
|
- name: Build and start application
|
|
run: docker compose --env-file .env up -d --build
|
|
- name: Wait for public readiness
|
|
run: |
|
|
for attempt in $(seq 1 90); do
|
|
if curl --fail --silent http://127.0.0.1:8080/health/ready > /dev/null; then
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
docker compose --env-file .env ps --all
|
|
exit 1
|
|
- name: Public smoke
|
|
run: make test BASE_URL=http://127.0.0.1:8080
|
|
- name: Clean up test volumes
|
|
if: always()
|
|
run: |
|
|
if [ -f .env ]; then
|
|
docker compose --env-file .env down -v
|
|
fi
|