Skip to content

Speed up Github Ci Tests #5616

Speed up Github Ci Tests

Speed up Github Ci Tests #5616

Workflow file for this run

name: Django CI
on:
workflow_run:
workflows: ["Build and Push CI Base Image"]
types: [completed]
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-24.04
# Use your self-built image as container for the entire job
container: ghcr.io/${{ github.repository }}/ci-base:latest
steps:
- uses: actions/checkout@v4
- name: Start PostgreSQL
run: |
sudo service postgresql start
- name: Test Postgres
env:
PGPASSWORD: postgres
PGHOSTADDR: 127.0.0.1
run: |
# Test postgres user
psql -h localhost -U postgres -d django -c "SELECT version();"
psql -h localhost -U postgres -d django_test -c "SELECT 1;"
# Test PostGIS extension
psql -h localhost -U postgres -d django -c "SELECT PostGIS_version();"
psql -h localhost -U postgres -d django_test -c "SELECT PostGIS_version();"
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Cache node packages
uses: actions/cache@v4
env:
cache-name: cache-node-packages
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache uv packages
uses: actions/cache@v4
env:
cache-name: cache-uv-packages
with:
path: ~/.cache/uv
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/requirements/dev.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache testmon data
id: cache-testmon
uses: actions/cache@v4
with:
path: .testmondata
key: ${{ runner.os }}-testmon-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/requirements/dev.txt', 'adhocracy-plus/config/settings/*.py', 'pytest.ini') }}
restore-keys: |
${{ runner.os }}-testmon-${{ steps.setup-python.outputs.python-version }}-
- name: Show testmon cache status
run: |
echo "testmon cache hit: ${{ steps.cache-testmon.outputs.cache-hit }}"
ls -la .testmondata || true
- name: check a4 hashes equal
run: |
./scripts/a4-check.sh
- name: Install Python Dependencies
run: |
uv pip install -r requirements/dev.txt --system
uv pip install coveralls --system
- name: Run Tests
env:
PGPASSWORD: postgres
PGHOSTADDR: 127.0.0.1
run: |
python manage.py collectstatic > /dev/null
# Einmalig Cache löschen, um Settings-Mismatch auszuschließen
py.test --ds=adhocracy-plus.config.settings.travis --testmon --cov
isort --diff -c adhocracy-plus tests
python manage.py makemigrations --dry-run --check --noinput
flake8 adhocracy-plus tests --exclude migrations,settings
- name: Configure Git for Coveralls
run: |
git config --global --add safe.directory /__w/adhocracy-plus/adhocracy-plus
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Coveralls
env:
COVERALLS_SERVICE_NAME: github-actions
GITHUB_TOKEN: ${{ secrets.COV }}
run: |
coveralls
- name: Install NPM Dependencies
run: |
npm install
- name: Build NPM
run: |
npm run build
- name: Run Frontend Tests
run: |
npm test
npm run lint
- name: Deploy
if: github.ref == 'refs/heads/main'
env:
TRAVIS_SSH_SECRET: ${{ secrets.DEPLOY }}
run: |
./scripts/deploy.sh