Skip to content

Update license year #503

Update license year

Update license year #503

Workflow file for this run

name: Tests
on:
push:
branches:
- develop
pull_request:
branches-ignore:
- master
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
DEFAULT_PYTHON: '3.13'
jobs:
tests:
name: Run tests (Python ${{ matrix.python-version }}, Pydantic v${{ matrix.pydantic-version }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.13']
pydantic-version: [1, 2]
os: [ubuntu-latest]
env:
POETRY_VERSION: ${{ matrix.python-version == '3.7' && '1.5.1' || '1.8.2' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Backend Container
uses: docker/build-push-action@v6
with:
tags: mtsrus/horizon-backend:${{ github.sha }}
context: .
file: docker/Dockerfile.backend
push: false
load: true
cache-from: mtsrus/horizon-backend:develop
- name: Start Backend Container
run: |
docker compose -f docker-compose.test.yml down -v --remove-orphans
docker compose -f docker-compose.test.yml up --wait-timeout 5 -d
env:
TAG: ${{ github.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
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:
version: ${{ env.POETRY_VERSION }}
- name: Cache poetry
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-python-${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}-test-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-python-${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}-test-${{ hashFiles('**/poetry.lock') }}
${{ runner.os }}-python-${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}-test-
${{ runner.os }}-python-${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}-
- name: Install dependencies
run: |
poetry install --no-root --all-extras --with test --without dev,docs
if [ "${{ matrix.pydantic-version }}" == "1" ]; then
poetry run pip install "pydantic<2.0.0"
fi
- name: Run Tests
run: |
source .env.local
mkdir -p reports/
poetry run coverage run -m pytest
- name: Dump backend logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
images: mtsrus/horizon-backend
dest: ./logs
- name: Shutdown Backend Container
if: always()
run: |
docker compose -f docker-compose.test.yml down -v --remove-orphans
- name: Upload server logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: backend-logs-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
path: logs/*
- name: Upload Coverage Results
uses: actions/upload-artifact@v4
with:
name: raw-coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
path: reports/.coverage*
# https://github.com/actions/upload-artifact/issues/602
include-hidden-files: true
all_done:
name: Tests done
runs-on: ubuntu-latest
needs: [tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-coverage
- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: pip install -I coverage pytest
- name: Download all raw coverage data
uses: actions/download-artifact@v4
with:
path: coverage-data/
pattern: raw-coverage-*
- name: Combine Coverage Data
run: |
coverage combine coverage-data/*
coverage xml -o combined_coverage.xml
- name: Check Coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./combined_coverage.xml
fail_ci_if_error: true
plugins: noop
- name: All done
run: echo 1