Skip to content

Tests and CI

Tests and CI #2

Workflow file for this run

name: AI CI
on:
push:
branches: [development]
pull_request:
branches: [development]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Cache Poetry and dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry
.venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
run: |
poetry install --no-interaction --with dev
- name: Run unit tests with coverage report
run: |
poetry run python -m pytest -v --cov=./src --cov-report term-missing:skip-covered tests
- name: Check coverage is at least 70%
run: |
poetry run coverage report -m
COVERAGE=$(poetry run coverage report -m | grep -Po '^TOTAL.*\s(\d+%)$' | awk '{sub("%", "", $NF); print $NF}')
echo "Coverage is $COVERAGE%"
if [ "$COVERAGE" -lt "70" ]; then
exit 1
fi
- name: Python Semantic Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install python-semantic-release
git config user.name github-actions
git config user.email [email protected]
semantic-release version
semantic-release publish
- name: Check if release was created
id: check-release
run: |
if [ -n "$(git tag --points-at HEAD)" ]; then
echo "RELEASE_CREATED=true" >> $GITHUB_ENV
else
echo "RELEASE_CREATED=false" >> $GITHUB_ENV
fi
- name: Merge development into main if release created
if: ${{ env.RELEASE_CREATED == 'true' }}
run: |
git checkout main
git merge --ff-only development
git push origin main