From 7c55f320d87a614ef09f0e5c98eabfc39b64584b Mon Sep 17 00:00:00 2001 From: Federico Justus Denkena Date: Fri, 18 Oct 2024 03:04:14 +0200 Subject: [PATCH] add testing to the codebase --- .gitea/workflows/test.yaml | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .gitea/workflows/test.yaml diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 00000000..b8c9c5dc --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,44 @@ +name: Code Tests +on: [push] +jobs: + run_tests: + runs-on: ubuntu-latest + container: + image: git.denkena-consulting.com/denkena-consulting/docker-base:latest + credentials: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_TOKEN }} + env: + POSTGRES_PASSWORD: testrunner + PGPORT: 5433 + strategy: + fail-fast: false + matrix: + python-version: ["3.11", "3.12", "3.10"] + steps: + - name: Checkout Codebase + uses: actions/checkout@v4 + + - name: Configure and install deps + run: | + apt update + apt install -y sudo python3.11-venv + chmod +x /usr/local/bin/docker-enforce-initdb.sh && /usr/local/bin/docker-enforce-initdb.sh + sudo -u postgres /usr/lib/postgresql/16/bin/pg_ctl -D /var/lib/postgresql/data -o "-c listen_addresses='' -c port=5433" start + sudo -u postgres psql -h '/var/run/postgresql/' -p 5433 -U postgres -d postgres -c "alter user postgres with password 'testrunner';" + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + token: ${{ secrets.GH_TOKEN }} + - name: Install dependencies + run: cd ${{ gitea.workspace }} && pip install -r requirements.txt --root-user-action=ignore + + - name: Run Django tests + env: + DB_HOST: '/var/run/postgresql/' + DB_NAME: 'testdb' + DB_USER: 'postgres' + DB_PASSWORD: 'testrunner' + DB_PORT: 5433 + run: | + cd ${{ gitea.workspace }} && python3 manage.py test --settings=denkena_aas.settings-ci