2020-07-21 11:02:29 +00:00
|
|
|
name: Flask CI
|
2020-05-05 22:23:35 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [master, testing]
|
|
|
|
pull_request:
|
|
|
|
branches: [master, testing]
|
2020-07-21 11:02:29 +00:00
|
|
|
|
2020-05-05 22:23:35 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
# Service containers to run with `container-job`
|
|
|
|
services:
|
|
|
|
# Label used to access the service container
|
|
|
|
postgres:
|
|
|
|
# Docker Hub image
|
|
|
|
image: postgres:11
|
|
|
|
ports:
|
|
|
|
- 5432:5432
|
|
|
|
# Set health checks to wait until postgres has started
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
env:
|
|
|
|
POSTGRES_DB: dh_test
|
|
|
|
POSTGRES_USER: dhub
|
|
|
|
POSTGRES_PASSWORD: ereuse
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
max-parallel: 4
|
|
|
|
matrix:
|
|
|
|
python-version: [3.7]
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
2022-02-07 12:08:21 +00:00
|
|
|
uses: actions/setup-python@v2
|
2020-05-05 22:23:35 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2022-02-07 12:08:21 +00:00
|
|
|
cache: 'pip'
|
2020-05-05 22:23:35 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get update -qy
|
|
|
|
sudo apt-get -y install postgresql-client
|
|
|
|
python -m pip install --upgrade pip
|
2020-07-21 11:02:29 +00:00
|
|
|
pip install virtualenv
|
|
|
|
virtualenv env
|
|
|
|
source env/bin/activate
|
2022-02-09 08:54:57 +00:00
|
|
|
pip install flake8 pytest coverage
|
2020-05-05 22:23:35 +00:00
|
|
|
pip install -r requirements.txt
|
|
|
|
|
|
|
|
- name: Prepare database
|
|
|
|
env:
|
|
|
|
POSTGRES_DB: dh_test
|
|
|
|
POSTGRES_USER: dhub
|
|
|
|
POSTGRES_PASSWORD: ereuse
|
|
|
|
run: |
|
|
|
|
export PGPASSWORD=$POSTGRES_PASSWORD
|
|
|
|
psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pgcrypto SCHEMA public;"
|
|
|
|
psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION ltree SCHEMA public;"
|
|
|
|
psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION citext SCHEMA public;"
|
|
|
|
psql -h "localhost" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_trgm SCHEMA public;"
|
|
|
|
|
|
|
|
- name: Run Tests
|
|
|
|
run: |
|
2020-07-21 11:02:29 +00:00
|
|
|
source env/bin/activate
|
2022-02-09 08:54:57 +00:00
|
|
|
coverage run --source='ereuse_devicehub' env/bin/pytest -m mvp --maxfail=5 tests/
|
|
|
|
coverage report --include='ereuse_devicehub/*'
|
|
|
|
coverage xml
|
|
|
|
|
|
|
|
- name: Upload coverage to Codecov
|
|
|
|
uses: codecov/codecov-action@v1
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|