Skip to content

Refactor to use cplus core package #290

Refactor to use cplus core package

Refactor to use cplus core package #290

name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version:
- 3.11.8
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Test installing development dependencies
working-directory: deployment/docker
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run Flake8 test
run: flake8 .
django_test:
needs: lint
name: 'Django Test'
runs-on: ubuntu-22.04
strategy:
matrix:
python-version:
- 3.11.8
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build test image
uses: docker/build-push-action@v4
with:
context: .
file: deployment/docker/Dockerfile
push: false
load: true
target: dev
tags: kartoza/cplus-api:test
cache-from: |
type=gha,scope=test
type=gha,scope=dev
cache-to: type=gha,scope=test
- name: Run docker-compose services
working-directory: deployment
run: |
echo "Override docker-compose for testing purposes"
cp docker-compose.override.test.yml docker-compose.override.yml
cp .template.test.env .env
cd ../
make dev
make init-bucket
make wait-db
make sleep
make migrate
- name: Run Coverage test
working-directory: deployment
run: |
cat << EOF | docker compose exec -T dev bash
python manage.py makemigrations
python manage.py migrate
python manage.py collectstatic --noinput --verbosity 0
export DJANGO_SETTINGS_MODULE=core.settings.test && coverage run manage.py test && coverage xml
EOF
docker cp cplus-api-dev-django:/home/web/django_project/coverage.xml ../coverage.xml
- name: Show Coverage
if: ${{ github.event_name == 'pull_request' }}
uses: orgoro/coverage@v3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true