Production update #535
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Service Map API tests | |
on: | |
push: | |
branches: [ master, develop ] | |
pull_request: | |
branches: [ master, develop ] | |
jobs: | |
build: | |
# Ubuntu latest is Ubuntu 20.04 as of 2022/6 | |
runs-on: ubuntu-20.04 | |
env: | |
# Database for tests | |
DATABASE_URL: postgis://postgres:postgres@localhost/smbackend | |
ADDITIONAL_INSTALLED_APPS: smbackend_turku,ptv | |
PTV_ID_OFFSET: 10000000 | |
LAM_COUNTER_API_BASE_URL: https://tie.digitraffic.fi/api/tms/v1/history | |
ECO_COUNTER_STATIONS_URL: https://dev.turku.fi/datasets/ecocounter/liikennelaskimet.geojson | |
ECO_COUNTER_OBSERVATIONS_URL: https://data.turku.fi/cjtv3brqr7gectdv7rfttc/counters-15min.csv | |
TRAFFIC_COUNTER_OBSERVATIONS_BASE_URL: https://data.turku.fi/2yxpk2imqi2mzxpa6e6knq/ | |
CACHE_LOCATION: redis://localhost:6379/0 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10.0 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.10.0 | |
- name: Install required Ubuntu packages | |
run: | | |
sudo apt-get update && sudo apt-get -y --no-install-recommends install gdal-bin voikko-fi libvoikko-dev | |
sudo apt-get install redis-server | |
- name: Create needed postgis extensions | |
run: | | |
psql -h localhost -U postgres template1 -c 'create extension hstore;' | |
psql -h localhost -U postgres template1 -c 'create extension pg_trgm;' | |
- name: Install PyPI dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run Python side code neatness tests | |
run: | | |
flake8 | |
black --check . | |
isort . -c | |
- name: Run pytest code functionality tests | |
run: | | |
pytest --cov=. | |
- name: Generate Report | |
run: | | |
pip install coverage | |
coverage report -m | |
- name: Upload Coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
# Majority of the tests require database | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgis/postgis:13-3.1 | |
# Provide the password for postgres | |
env: | |
POSTGRES_HOST_AUTH_METHOD: trust | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 |