Skip to content

Continuous Integration #5044

Continuous Integration

Continuous Integration #5044

name: Continuous Integration
on:
pull_request:
branches:
- main
- 'feature/**'
- 'staging/**'
merge_group:
types: [checks_requested]
env:
PYTHON_VERSION: 3.10.x
DATASTORE_COMMIT_HASH: main # will be set during job
AUTH_COMMIT_HASH: main # will be set during job
jobs:
build-production-image:
name: Build and test production docker image
runs-on: ubuntu-22.04
defaults:
run:
working-directory: .github/docker-compose
steps:
- uses: actions/checkout@v4
- name: Create secrets for datastore
run: mkdir secrets && echo -n "openslides" > secrets/postgres_password
- name: Run docker production image
run: docker compose -f docker-compose.prod.yml up --build -d
- name: Wait for action service
# we have to execute this inside the container since the port to the outside is opened directly after the
# container started, while the code itself is not ready yet
run: docker compose -f docker-compose.prod.yml exec -T backend-action scripts/wait.sh backend-action 9002
- name: Wait for presenter service
# we have to execute this inside the container since the port to the outside is opened directly after the
# container started, while the code itself is not ready yet
run: docker compose -f docker-compose.prod.yml exec -T backend-presenter scripts/wait.sh backend-presenter 9003
- name: Fire a test request to actions component
run: curl localhost:9002/system/action/health
- name: Fire a test request to presenter component
run: curl localhost:9003/system/presenter/health
build-and-test-dev-image:
name: Build and test development docker image with Docker Compose
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: dev/run-tests.sh
test-local-setup:
name: Build and test local dev setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: openslides-backend
- name: Set env vars
working-directory: openslides-backend/requirements
run: |
. export_service_commits.sh
echo "DATASTORE_COMMIT_HASH=$(echo $DATASTORE_COMMIT_HASH)" >> $GITHUB_ENV
echo "AUTH_COMMIT_HASH=$(echo $AUTH_COMMIT_HASH)" >> $GITHUB_ENV
- name: Clone datastore
uses: actions/checkout@v4
with:
repository: OpenSlides/openslides-datastore-service
ref: ${{ env.DATASTORE_COMMIT_HASH }}
path: openslides-datastore-service
- name: Clone auth service
uses: actions/checkout@v4
with:
repository: OpenSlides/openslides-auth-service
ref: ${{ env.AUTH_COMMIT_HASH }}
path: openslides-auth-service
- name: Clone vote service
uses: actions/checkout@v4
with:
repository: OpenSlides/openslides-vote-service
ref: main
path: openslides-vote-service
- name: Run local setup
working-directory: openslides-backend
run: dev/run-local.sh
check-coding-style:
name: Check coding style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install requirements
run: . requirements/export_service_commits.sh && pip install --requirement requirements/requirements_development.txt
- name: Check black
if: always()
run: make check-black
- name: Check isort
if: always()
run: make check-isort
- name: Check flake8
if: always()
run: make flake8
- name: Check mypy
if: always()
run: make mypy
- name: Check pyupgrade
if: always()
run: make pyupgrade
check-models-all:
name: Check from models.yml up to permissions and jsons
runs-on: ubuntu-latest
env:
PYTHONPATH: .
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install requirements
run: . requirements/export_service_commits.sh && pip install --requirement requirements/requirements_development.txt
- name: Check for up to date models.py
if: always()
run: make check-models
- name: Check for up to date permissions.py
if: always()
run: make check-permissions
- name: Check initial-data.json
if: always()
run: make check-initial-data-json
- name: Check example-data.json
if: always()
run: make check-example-data-json