147 lines
4.4 KiB
YAML
147 lines
4.4 KiB
YAML
name: Main Workflow
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- "*"
|
|
|
|
jobs:
|
|
check-changelog:
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
contains(github.event.pull_request.labels.*.name, 'noChangeLog') == false &&
|
|
github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 50
|
|
- name: Check that the CHANGELOG has been modified in the current branch
|
|
run: git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.after }} | grep 'CHANGELOG.md'
|
|
|
|
lint-changelog:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
- name: Check CHANGELOG max line length
|
|
run: |
|
|
max_line_length=$(cat CHANGELOG.md | grep -Ev "^\[.*\]: https://github.com" | wc -L)
|
|
if [ $max_line_length -ge 80 ]; then
|
|
echo "ERROR: CHANGELOG has lines longer than 80 characters."
|
|
exit 1
|
|
fi
|
|
|
|
lint-back:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: src/backend
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
- name: "Set up Python"
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version-file: "src/backend/pyproject.toml"
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
- name: Install the project
|
|
run: uv sync --locked --all-extras
|
|
|
|
- name: Check code formatting with ruff
|
|
run: uv run ruff format . --diff
|
|
- name: Lint code with ruff
|
|
run: uv run ruff check .
|
|
- name: Lint code with pylint
|
|
run: uv run pylint .
|
|
|
|
test-back:
|
|
runs-on: ubuntu-latest
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: src/backend
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_DB: calendars
|
|
POSTGRES_USER: pgroot
|
|
POSTGRES_PASSWORD: pass
|
|
ports:
|
|
- 5432:5432
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
|
|
env:
|
|
DJANGO_CONFIGURATION: Test
|
|
DJANGO_SETTINGS_MODULE: calendars.settings
|
|
DJANGO_SECRET_KEY: ThisIsAnExampleKeyForTestPurposeOnly
|
|
OIDC_OP_JWKS_ENDPOINT: /endpoint-for-test-purpose-only
|
|
DJANGO_EMAIL_HOST: mailcatcher
|
|
DB_HOST: localhost
|
|
DB_NAME: calendars
|
|
DB_USER: pgroot
|
|
DB_PASSWORD: pass
|
|
DB_PORT: 5432
|
|
CALDAV_URL: http://localhost:80
|
|
CALDAV_OUTBOUND_API_KEY: test-outbound-key
|
|
CALDAV_INBOUND_API_KEY: test-inbound-key
|
|
CALDAV_CALLBACK_HOST: localhost
|
|
TRANSLATIONS_JSON_PATH: ${{ github.workspace }}/src/frontend/apps/calendars/src/features/i18n/translations.json
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Create writable /data
|
|
run: |
|
|
sudo mkdir -p /data/media && \
|
|
sudo mkdir -p /data/static
|
|
|
|
- name: Build and start CalDAV server
|
|
working-directory: .
|
|
run: |
|
|
docker build -t caldav-test docker/sabredav
|
|
docker run -d --name caldav-test \
|
|
--network host \
|
|
-e PGHOST=localhost \
|
|
-e PGPORT=5432 \
|
|
-e PGDATABASE=calendars \
|
|
-e PGUSER=pgroot \
|
|
-e PGPASSWORD=pass \
|
|
-e CALDAV_BASE_URI=/api/v1.0/caldav/ \
|
|
-e CALDAV_INBOUND_API_KEY=test-inbound-key \
|
|
-e CALDAV_OUTBOUND_API_KEY=test-outbound-key \
|
|
caldav-test \
|
|
sh -c "/usr/local/bin/init-database.sh && apache2-foreground"
|
|
|
|
- name: Wait for CalDAV to be ready
|
|
run: |
|
|
timeout 30 bash -c 'until curl -s -o /dev/null http://localhost:80/; do sleep 1; done'
|
|
echo "CalDAV server is ready"
|
|
|
|
- name: "Set up Python"
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version-file: "src/backend/pyproject.toml"
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
- name: Install the dependencies
|
|
run: uv sync --locked --all-extras
|
|
|
|
- name: Install gettext (required to compile messages) and MIME support
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gettext pandoc shared-mime-info media-types
|
|
|
|
- name: Generate a MO file from strings extracted from the project
|
|
run: uv run python manage.py compilemessages
|
|
|
|
- name: Run tests
|
|
run: uv run pytest -n 2
|