Skip to content

[DOP-11675] - add tests to github workflow #5

[DOP-11675] - add tests to github workflow

[DOP-11675] - add tests to github workflow #5

Workflow file for this run

name: Tests
on:
push:
branches-ignore:
- dependabot/**
- pre-commit-ci-update-config
pull_request:
branches-ignore:
- master
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
tests:
name: Run ${{ matrix.mark}} tests (${{ matrix.python-version }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.12', pypy-3.7, pypy-3.10]
os: [ubuntu-latest]
# run only limited set of tests because it takes too long
mark: [important]
include:
- os: macos-latest
mark: important
python-version: '3.12'
- os: windows-latest
mark: important
python-version: '3.12'
# run all the tests only on latest python version
- os: ubuntu-latest
mark: all
python-version: '3.12'
services:
db:
image: postgres:15-alpine
env:
# Init Postgres database
POSTGRES_DB: horizon
POSTGRES_USER: horizon
POSTGRES_PASSWORD: Aeviphai6juo3ooY7iecaivieX5OoMai
# See Backend -> Configuration documentation
HORIZON__DATABASE__URL: postgresql+asyncpg://horizon:Aeviphai6juo3ooY7iecaivieX5OoMai@db:5432/horizon
HORIZON__AUTH__ACCESS_TOKEN__SECRET_KEY: bae1thahr8Iyaisai0kohvoh1aeg5quu
HORIZON__AUTH__PROVIDER: horizon.backend.providers.auth.dummy.DummyAuthProvider
HORIZON__SERVER__LOGGING__PRESET: colored
HORIZON__SERVER__DEBUG: false
ports:
- 5432:5432
ldap:
image: thoteam/slapd-server-mock
ports:
- 389:389
- 636:636
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build Backend Container
run: docker build -t backend:${{ github.sha }} -f docker/Dockerfile.backend .
- name: Start Backend Container
run: |
docker run -d --name backend --restart unless-stopped --network host --env-file .env.docker -p 8000:8000 -v $(pwd):/app backend:${{ github.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
# this step is needed for successful installation of "bonsai" library in python dependencies
run: sudo apt-get update && sudo apt-get install -y libldap2-dev libsasl2-dev
- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Cache poetry
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-codeql-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-codeql-${{ hashFiles('**/poetry.lock') }}
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-codeql-
${{ runner.os }}-python
${{ runner.os }}-
- name: Install dependencies
run: |
poetry install --no-root --all-extras --with dev,test,docs
- name: Run Tests
run: |
mkdir reports/
coverage run -m pytest
coverage xml -o reports/coverage-${{ matrix.python-version }}.xml -i
- name: Upload Coverage Results
uses: actions/upload-artifact@v3
with:
name: code-coverage-${{ matrix.python-version }}
path: reports/coverage-${{ matrix.python-version }}.xml
all_done:
name: Tests done
runs-on: ubuntu-latest
needs: [tests]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download all coverage reports
uses: actions/download-artifact@v3
with:
path: reports
- name: Move coverage reports to the root folder
run: find reports -type f -exec mv '{}' reports \;
- name: Check coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./reports
fail_ci_if_error: true
- name: All done
run: echo 1