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
|
2022-03-03 08:35:52 +00:00
|
|
|
sudo apt-get -y install postgresql-client --no-install-recommends
|
2020-05-05 22:23:35 +00:00
|
|
|
python -m pip install --upgrade pip
|
2020-09-29 16:15:28 +00:00
|
|
|
pip install flake8 pytest coverage
|
2020-05-05 22:23:35 +00:00
|
|
|
pip install -r requirements.txt
|
2022-05-24 14:57:42 +00:00
|
|
|
pip install -e .
|
2022-05-24 14:41:23 +00:00
|
|
|
mkdir bin
|
|
|
|
wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
|
|
|
|
tar xf geckodriver-v0.30.0-linux64.tar.gz -C bin/
|
2020-05-05 22:23:35 +00:00
|
|
|
|
|
|
|
- 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;"
|
|
|
|
|
2022-05-24 14:52:19 +00:00
|
|
|
- name: Adding minimum datas
|
2022-05-24 15:02:33 +00:00
|
|
|
env:
|
2022-05-24 15:03:41 +00:00
|
|
|
SECRET_KEY: 'f00046306835001b55c230092e3a7990485beda0bc3bf732088d1ba1b5b74110e22e3f9ec3a24890272554b37d4'
|
2022-05-24 14:52:19 +00:00
|
|
|
run: |
|
|
|
|
alembic -x inventory=dbtest upgrade head
|
|
|
|
dh dummy --yes
|
|
|
|
|
2022-02-10 10:16:57 +00:00
|
|
|
- name: Lint with flake8
|
|
|
|
run: |
|
|
|
|
# stop the build if:
|
|
|
|
# - E9,F63,F7,F82: Python syntax errors or undefined names
|
|
|
|
# - E501: line longer than 120 characters
|
|
|
|
# - C901: complexity greater than 10
|
|
|
|
# - F401: modules imported but unused
|
|
|
|
# See: https://flake8.pycqa.org/en/latest/user/error-codes.html
|
|
|
|
flake8 . --select=E9,F63,F7,F82,E501,C901,F401
|
|
|
|
flake8 . --exit-zero
|
|
|
|
|
2020-05-05 22:23:35 +00:00
|
|
|
- name: Run Tests
|
|
|
|
run: |
|
2021-12-28 11:45:33 +00:00
|
|
|
export SECRET_KEY=`python3 -c 'import secrets; print(secrets.token_hex())'`
|
2022-03-03 08:59:47 +00:00
|
|
|
coverage run --source='ereuse_devicehub' -m pytest -m mvp --maxfail=5 tests/
|
2020-09-29 16:15:28 +00:00
|
|
|
coverage report --include='ereuse_devicehub/*'
|
|
|
|
coverage xml
|
2022-05-24 14:41:23 +00:00
|
|
|
flask run & pytest tests/test_selenium.py
|
2020-05-05 22:23:35 +00:00
|
|
|
|
2020-10-02 10:01:10 +00:00
|
|
|
- name: Upload coverage to Codecov
|
|
|
|
uses: codecov/codecov-action@v1
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|