-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOP-11675] - add tests to github workflow
- Loading branch information
1 parent
de9bde1
commit 7e00c92
Showing
4 changed files
with
170 additions
and
36 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
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] | ||
mark: [all] | ||
|
||
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: | | ||
source .env.local | ||
mkdir -p reports/ | ||
poetry run coverage run -m pytest | ||
poetry run 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 |
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
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
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