Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests pipeline #22

Closed
wants to merge 18 commits into from
61 changes: 61 additions & 0 deletions .github/docker/compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
services:
tests:
image: ${image}
environment:
- DEBUG=False
- [email protected]
- ADMIN_PASSWORD=123
- CACHE_URL=redis://redis:6379/1
- CELERY_BROKER_URL=redis://redis:6379/9
- CELERY_TASK_ALWAYS_EAGER=False
- DATABASE_URL=postgres://hcw:password@db:5432/hope_country_workspace
- DJANGO_SETTINGS_MODULE=hope_country_workspace.config.settings
- MEDIA_ROOT=/var/hope_country_workspace/media
- PYTHONPATH=/code/src/:/code/__pypackages__/3.12/lib/
- SECRET_KEY=sensitive-secret-key
- STATIC_ROOT=/var/hope_country_workspace/static
restart: no
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
command: >
bash -c "
pytest -vvv ./tests
wozniakpl marked this conversation as resolved.
Show resolved Hide resolved
"
volumes:
- ../../tests:/code/tests
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/healthcheck"]
interval: 10s
timeout: 5s
retries: 5

db:
image: postgres:16
environment:
- POSTGRES_USER=hcw
- POSTGRES_PASSWORD=password
- POSTGRES_DB=hope_country_workspace
restart: always
healthcheck:
test: ["CMD", "pg_isready", "-U", "hcw", "-d", "hope_country_workspace"]
start_period: 5s
start_interval: 1s
interval: 5s
timeout: 4s
retries: 5

redis:
image: redis:7.2
ports:
- 6379:6379
restart: always
healthcheck:
test: ["CMD", "redis-cli", "ping"]
start_period: 5s
start_interval: 1s
interval: 5s
timeout: 4s
retries: 5
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI
on:
pull_request:
branches: [develop] # If more branches are needed, add them here.
types: [synchronize, opened, reopened, ready_for_review]
push:
branches: [develop] # If more branches are needed, add them here.
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ensure cache directory exists
run: mkdir -p /tmp/.buildx-cache
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
wozniakpl marked this conversation as resolved.
Show resolved Hide resolved
restore-keys: |
${{ runner.os }}-buildx-
- name: Build the Docker image
run: |
docker buildx create --use
docker buildx build \
--tag unicef/hope_country_workspace:${{ github.sha }} \
--load \
--target python_dev_deps \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
-f ./docker/Dockerfile \
./
- name: Run the tests
run: |-
image=unicef/hope_country_workspace:${{ github.sha }} docker compose -f ./.github/docker/compose.ci.yml up --exit-code-from tests
wozniakpl marked this conversation as resolved.
Show resolved Hide resolved
Loading