From 5e6bda69f1b36818139a215164dc4997373484ce Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Wed, 30 Jun 2021 19:30:06 +0200 Subject: [PATCH] ci: Test against live mreg instance. * .github/workflows/test.yml (jobs)[integration]: New job. --- .github/workflows/test.yml | 65 +++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 96f43b8d..c19fce49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: [push, pull_request] name: CI jobs: test: - name: Test + name: Fixtures runs-on: ${{ matrix.os }} strategy: matrix: @@ -35,3 +35,66 @@ jobs: pip install -e . - name: Test run: mreg-cli --playback testsuite-result.json + + integration: + name: Integration + runs-on: ubuntu-latest + strategy: + matrix: + postgresql-version: [11, 12, 13] + services: + postgres: + image: postgres:${{ matrix.postgresql-version }} + env: + POSTGRES_USER: mreg + POSTGRES_DB: mreg + POSTGRES_PASSWORD: postgres + # Add health checks and trick it into creating the citext + # extension when ready. + options: >- + --health-cmd "pg_isready && PGPASSWORD=$POSTGRES_PASSWORD psql -U mreg -c 'CREATE EXTENSION IF NOT EXISTS citext;' mreg || exit 1" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + mreg: + image: ghcr.io/unioslo/mreg:latest + options: >- + --name mreg + env: + GUNICORN_ARGS: --bind=0.0.0.0 + MREG_DB_HOST: postgres + MREG_DB_PASSWORD: postgres + ports: + - 8000:8000 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: v1-pip-${{ runner.os }}-${{ hashFiles('requirements-*.txt') }} + restore-keys: | + v1-pip-${{ runner.os }} + v1-pip- + - name: Install + run: | + pip install -r requirements.txt + pip install -e . + - name: Create superuser + run: | + echo -ne ' + from django.conf import settings + from django.contrib.auth import get_user_model + from django.contrib.auth.models import Group + user = get_user_model().objects.create_user( + username="ci",password="test") + user.groups.clear() + su = getattr(settings, "SUPERUSER_GROUP", None) + group, created = Group.objects.get_or_create(name=su) + group.user_set.add(user) + ' | docker exec -i mreg python /app/manage.py shell + - name: Run tests + run: > + echo -ne 'test\nsource testsuite\nquit\n' + | mreg-cli -u ci -d example.org --url http://localhost:8000