83 lines
2.3 KiB
YAML
83 lines
2.3 KiB
YAML
name: CI/CD
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_DB: pokedexter
|
|
POSTGRES_USER: pokedexter
|
|
POSTGRES_PASSWORD: pokedexter_secret
|
|
options: >-
|
|
--health-cmd "pg_isready -U pokedexter"
|
|
--health-interval 5s
|
|
--health-timeout 3s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
- name: Checkout
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
|
|
run: |
|
|
git clone http://glennigen:${GITEA_TOKEN}@00-gitea-server:3000/glennigen/pokedexter.git .
|
|
git config advice.detachedHead false
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Setup Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install --upgrade pip
|
|
pip install -r backend/requirements.txt
|
|
|
|
- name: Run tests
|
|
env:
|
|
DATABASE_URL: "postgresql+asyncpg://pokedexter:pokedexter_secret@postgres/pokedexter"
|
|
run: |
|
|
cd backend
|
|
pytest -v --cov=app --cov-report=term --cov-report=xml
|
|
|
|
- name: Upload coverage
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: coverage
|
|
path: backend/coverage.xml
|
|
|
|
build:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
|
|
run: |
|
|
git clone http://glennigen:${GITEA_TOKEN}@00-gitea-server:3000/glennigen/pokedexter.git .
|
|
git config advice.detachedHead false
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Build backend image
|
|
run: |
|
|
docker build -t pokedexter-backend:${{ github.sha }} -t pokedexter-backend:latest -f Dockerfile_backend .
|
|
|
|
- name: Build nginx image
|
|
run: |
|
|
docker build -t pokedexter-nginx:${{ github.sha }} -t pokedexter-nginx:latest -f Dockerfile_nginx .
|
|
|
|
- name: Log build info
|
|
run: |
|
|
echo "Backend image: pokedexter-backend:${{ github.sha }}"
|
|
echo "Nginx image: pokedexter-nginx:${{ github.sha }}" |