Add more tests #990
Workflow file for this run
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: tests | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
lint: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python-version: [ 3.9 ] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install poetry | |
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2 | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cache/pypoetry/virtualenvs | |
key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} | |
restore-keys: | | |
myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}- | |
- name: Install dependencies | |
run: | | |
poetry install | |
- name: check format with black | |
run: | | |
poetry run black --version | |
poetry run black --check . | |
- name: check import order with isort | |
run: | | |
poetry run isort --version | |
poetry run isort -c . | |
- name: Lint with pylint | |
run: | | |
poetry run pylint --version | |
poetry run pylint --fail-under=9 myhpi | |
test: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python-version: [ 3.8, 3.9 ] | |
database: [ sqlite, postgres ] | |
include: | |
- database: sqlite | |
database_url: "sqlite:///data/db.sqlite3" | |
- database: postgres | |
database_url: "psql://user:pass@127.0.0.1:5432/myHPI" | |
env: | |
DJANGO_SETTINGS_MODULE: myhpi.settings | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
#- uses: Gr1N/setup-poetry@v4 | |
#- uses: actions/cache@v1 | |
# with: | |
# path: ~/.cache/pypoetry/virtualenvs | |
# key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} | |
# restore-keys: | | |
# myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}- | |
- name: Setup python venv and poetry | |
run: | | |
#sudo apt-get install python-venv | |
python -m venv env | |
source env/bin/activate | |
curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2 | |
- name: Install dependencies | |
# always install all -E extras to use a single cache | |
run: | | |
sudo apt-get install gettext | |
source env/bin/activate | |
poetry run python -m pip install setuptools -U | |
poetry install -E mysql -E pgsql | |
python install-bootstrap.py | |
- name: Prepare files for test run | |
continue-on-error: true | |
run: | | |
cp .env.example .env | |
source env/bin/activate | |
poetry run python manage.py compilemessages --settings myhpi.settings | |
poetry run python manage.py collectstatic --settings myhpi.settings | |
- name: Setup postgres | |
uses: harmon758/postgresql-action@v1 | |
with: | |
postgresql version: '11' # See https://hub.docker.com/_/postgres for available versions | |
postgresql db: myHPI | |
postgresql user: user | |
postgresql password: pass | |
if: matrix.database == 'postgres' | |
- name: Setup postgres dependency | |
run: | | |
source env/bin/activate | |
poetry run python -m pip install psycopg2 | |
if: matrix.database == 'postgres' | |
#- name: Migrate db | |
# run: | | |
# source env/bin/activate | |
# # python manage.py migrate --run-syncdb | |
- name: Test apps | |
env: | |
DATABASE_URL: ${{ matrix.database_url }} | |
run: | | |
source env/bin/activate | |
poetry run coverage run --source=myhpi manage.py test myhpi.tests | |
- name: Coveralls | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
source env/bin/activate | |
pip install coveralls | |
coveralls --service=github | |
if: matrix.python-version == '3.9' && matrix.database == 'sqlite' |