Skip to content

Merge pull request #1338 from chris34/forum-split-fix-title-length #411

Merge pull request #1338 from chris34/forum-split-fix-title-length

Merge pull request #1338 from chris34/forum-split-fix-title-length #411

Workflow file for this run

name: Inyoka CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
env:
DEFAULT_BRANCH: 'refs/heads/staging'
REQUIREMENTS_FILE: extra/requirements/linux-py${{ matrix.python-version }}-development.txt
strategy:
matrix:
python-version: ['3.12']
database: ['postgresql', 'sqlite']
theme: ['', 'theme-ubuntuusers']
include:
- python-version: 3.12
database: 'postgresql'
theme: ''
build_docs: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
# - name: Dump github.event.pull_request context
# env:
# GITHUB_CONTEXT: ${{ toJSON(github.event.pull_request) }}
# run: echo "$GITHUB_CONTEXT"
- name: Checkout theme from repo branch # (e.g. staging)
id: checkout-branch
continue-on-error: true
if: ${{ !github.event.pull_request && matrix.theme != '' }}
uses: actions/checkout@v4
with:
repository: inyokaproject/${{ matrix.theme }}
ref: ${{ github.ref }}
path: ${{ matrix.theme }}
persist-credentials: false
- name: Checkout theme in PR
id: checkout-pr
continue-on-error: true
if: ${{ github.event.pull_request && matrix.theme != '' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.owner.login }}/${{ matrix.theme }}
ref: ${{ github.head_ref }}
path: ${{ matrix.theme }}
persist-credentials: false
- name: "Checkout fallback theme: repo theme-ubuntuusers, staging branch"
if: ${{ matrix.theme != '' && (steps.checkout-branch.outcome == 'failure' || steps.checkout-pr.outcome == 'failure') }}
uses: actions/checkout@v4
with:
repository: inyokaproject/${{ matrix.theme }}
ref: staging
path: ${{ matrix.theme }}
persist-credentials: false
# if theme == '', the default theme inside inyoka is used
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache venv
id: cache-venv
uses: actions/cache@v4
with:
path: ~/venv/
key: ${{ runner.os }}-venv-py${{ matrix.python-version }}-${{ hashFiles(env.REQUIREMENTS_FILE) }}
- name: Build virtualenv
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv ~/venv
. ~/venv/bin/activate
python -m pip install --upgrade pip
pip install --no-deps --require-hashes -r ${{ env.REQUIREMENTS_FILE }}
- name: Build static files
run: |
npm ci
npm run all
- name: Link theme
working-directory: ./${{ matrix.theme }}
if: ${{ matrix.theme != '' }}
run: |
. ~/venv/bin/activate
pip install -e .
- name: Build static files theme
working-directory: ./${{ matrix.theme }}
if: ${{ matrix.theme != '' }}
run: |
npm ci
npm run all
- name: Start postgres
if: ${{ matrix.database == 'postgresql' }}
run: |
cat << '__EOF__' | sudo tee /etc/postgresql/14/main/pg_hba.conf > /dev/null
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
__EOF__
sudo systemctl start postgresql.service
pg_isready
- name: Install redis (server and cli)
run: |
sudo apt-get install redis-server
- name: Check for missing migrations (postgresql)
if: ${{ matrix.database == 'postgresql' }}
run: |
. ~/venv/bin/activate
python manage.py makemigrations --check --dry-run --settings tests.settings.${{ matrix.database }}_staticdbname
- name: Check for missing migrations (no postgresql)
if: ${{ matrix.database != 'postgresql' }}
run: |
. ~/venv/bin/activate
python manage.py makemigrations --check --dry-run --settings tests.settings.${{ matrix.database }}
- name: Run Tests
env:
PYTHONWARNINGS: 'always'
INYOKA_THEME: ${{ matrix.theme }}
run: |
. ~/venv/bin/activate
coverage run manage.py test --settings tests.settings.${{ matrix.database }}
coverage html
- name: Compress coverage report
run: zip htmlcov.zip -r htmlcov
- name: Save coverage report for tests
uses: actions/upload-artifact@v4
with:
name: coverage-py${{ matrix.python-version }}-${{ matrix.database }}-${{ matrix.theme }}
path: htmlcov.zip
- name: Run BDD tests
if: ${{ matrix.database == 'postgresql' }}
env:
DJANGO_SETTINGS_MODULE: 'tests.bdd.settings.headless'
INYOKA_THEME: ${{ matrix.theme }}
COVERAGE_RCFILE: 'tests/bdd/settings/.coveragerc'
run: |
. ~/venv/bin/activate
cat << '__EOF__' | sudo tee -a /etc/hosts > /dev/null
127.0.0.1 ubuntuusers.local forum.ubuntuusers.local paste.ubuntuusers.local wiki.ubuntuusers.local planet.ubuntuusers.local ikhaya.ubuntuusers.local static.ubuntuusers.local media.ubuntuusers.local
__EOF__
python manage.py collectstatic --noinput
coverage run -m behave --tags=-skip
coverage html -d bdd_coverage
- name: Compress BDD results
if: ${{ matrix.database == 'postgresql' }}
run: zip bdd_coverage.zip -r bdd_coverage
- name: Save BDD results
if: ${{ matrix.database == 'postgresql' }}
uses: actions/upload-artifact@v4
with:
name: BDD-coverage-py${{ matrix.python-version }}-${{ matrix.database }}-${{ matrix.theme }}
path: bdd_coverage.zip
- name: Build documentation
if: ${{ matrix.build_docs }}
env:
DJANGO_SETTINGS_MODULE: tests.settings.${{ matrix.database }}
INYOKA_THEME: ${{ matrix.theme }}
run: |
. ~/venv/bin/activate
make -C docs html
- name: Compress documentation
if: ${{ matrix.build_docs }}
run: zip doc.zip -r docs/build/html
- name: Save documentation
if: ${{ matrix.build_docs }}
uses: actions/upload-artifact@v4
with:
name: 'Inyoka_Documentation'
path: doc.zip
- name: Lint
run: |
. ~/venv/bin/activate
ruff check
- name: Compress statics
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.build_docs }}
run: zip static-collected.zip -r inyoka/static-collected
- name: Save statics
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.build_docs }}
uses: actions/upload-artifact@v4
with:
name: 'Static_files'
path: static-collected.zip