Skip to content

Improve reservation ical generation #1895

Improve reservation ical generation

Improve reservation ical generation #1895

Workflow file for this run

name: "Tests"
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
# Cancel a workflow from the same PR, branch or tag when a new workflow is triggered.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
name: "Run tests and SonarCloud scan"
runs-on: ubuntu-latest
env:
POETRY_VERSION: 1.7.1
services:
postgres:
image: postgis/postgis:13-3.3-alpine
env:
POSTGRES_USER: tvp
POSTGRES_PASSWORD: tvp
POSTGRES_DB: tvp
DEBUG: true
SECRET_KEY: build_secret
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432
redis:
image: redis:7-alpine
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 10
ports:
- 6379:6379
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:8.8.0
env:
xpack.security.enabled: false
discovery.type: single-node
ports:
- 9200:9200
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
# Disable shallow cloning to improve relevancy of reporting in SonarCloud
fetch-depth: 0
- name: "Set up python"
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: "Load cached poetry installation"
uses: actions/cache@v4
id: poetry-cache
with:
path: |
/home/runner/.local/share/pypoetry
/home/runner/.local/bin
key: cache-poetry-${{ env.POETRY_VERSION }}-python${{ steps.setup-python.outputs.python-version }}-v1
- name: "Install poetry"
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | POETRY_VERSION=${{ env.POETRY_VERSION }} python - -y
- name: "Add poetry to PATH"
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: "Configure poetry"
run: poetry config virtualenvs.in-project true
- name: "Install additional libraries"
run: |
sudo apt-get update
sudo apt install -y --no-install-recommends gdal-bin gettext
- name: "Load cached poetry environment"
uses: actions/cache@v4
with:
path: .venv
key: cache-venv-python${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-v1
- name: "Install dependencies"
run: poetry install
- name: "Test for migration issues"
run: poetry run python manage.py makemigrations --check --no-color --no-input --dry-run
env:
DJANGO_SETTINGS_ENVIRONMENT: CI
DATABASE_URL: postgis://tvp:tvp@localhost:5432/tvp
- name: "Test for missing translation"
run: poetry run python -m tilavarauspalvelu.hooks.translations_done
env:
DJANGO_SETTINGS_ENVIRONMENT: CI
DATABASE_URL: postgis://tvp:tvp@localhost:5432/tvp
- name: "Run pytest with coverage"
run: poetry run pytest --cov=. --cov-report=xml --cov-branch --disable-warnings --skip-slow
env:
DJANGO_SETTINGS_ENVIRONMENT: AutomatedTests
# Without this workaround, SonarCloud reports a warning about an incorrect source path
- name: "Override coverage report source path for SonarCloud"
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
- name: "SonarCloud Scan"
uses: SonarSource/sonarcloud-github-action@master
# Dependabot cannot access repository secrets (would need its own secrets),
# so we just skip SonarCloud analysis for dependabot PRs.
if: github.actor != 'dependabot[bot]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}