Skip to content

Merge pull request #33 from City-of-Helsinki/bugfix/permissons #105

Merge pull request #33 from City-of-Helsinki/bugfix/permissons

Merge pull request #33 from City-of-Helsinki/bugfix/permissons #105

# This is a basic workflow to help you get started with Actions
name: Device registry CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
env:
DJANGO_SETTINGS_MODULE: "deviceregistry.settings"
services:
# Label used to access the service container
db:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Tests run directly on the runner so we have to map the port
- 5432:5432
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install ruff pytest
pip install -r requirements.txt
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
ruff check --output-format=github --select=E9,F63,F7,F82 .
# default set of ruff rules with GitHub Annotations
ruff check --output-format=github .
- name: Test with pytest
env:
DATABASE_HOST: localhost
DATABASE_PORT: 5432
MEDIA_ROOT: /tmp
PYTEST_ADDOPTS: "--color=yes"
run: |
python manage.py test devices/tests
pytest devices/tests/test_api_device.py
pytest devices/tests/test_api_devicetype.py