Skip to content

Merge branch 'refactor/forecasting-parameter-datakeys' into feat/fore… #10840

Merge branch 'refactor/forecasting-parameter-datakeys' into feat/fore…

Merge branch 'refactor/forecasting-parameter-datakeys' into feat/fore… #10840

Workflow file for this run

name: lint-and-test
on:
push:
pull_request:
types:
- opened
jobs:
check:
runs-on: ubuntu-latest
name: Check (on Python 3.11)
steps:
- uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: actions/checkout@v3
- uses: pre-commit/action@v3.0.0
test:
needs: check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py_version: [ "3.10", "3.11", "3.12" ]
include:
- python-version: "3.11"
coverage: yes
name: "Test (on Python ${{ matrix.py_version }})"
steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_version }}
- name: Check out src from Git
uses: actions/checkout@v3
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Upgrade pip
# Pin due to https://github.com/pypa/pip/issues/13636
run: |
pip3 install --upgrade "pip==25.2"
- name: "Caching for dependencies (.txt) - restore existing or ensure new cache will be made"
uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
# manually disable a cache if needed by (re)setting CACHE_DATE
key: ${{ runner.os }}-pip-${{ env.pythonLocation }}-${{ SECRETS.CACHE_DATE }}-${{ hashFiles('**/requirements/**/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- run: |
ci/setup-postgres.sh
sudo apt-get -y install coinor-cbc
- name: Install FlexMeasures & exact dependencies for tests
run: make install-for-test
if: github.event_name == 'push' && steps.cache.outputs.cache-hit != 'true'
- name: Install FlexMeasures & latest dependencies for tests
run: make install-for-test pinned=no
if: github.event_name == 'pull_request'
- name: Run all tests AND record coverage
# NB the --ignore and -k "not ..." statements are not used to ignore test modules,
# but only to ignore some modules with doctests that do not (yet) pass (e.g. requiring app contexts)
run: |
if [[ "${{ matrix.py_version }}" == "3.10" ]]; then
PYTEST_K="not get_object_or_literal and not get_or_create_model and not find_smallest_common_unit"
else
PYTEST_K="not get_object_or_literal and not get_or_create_model"
fi
pytest -v \
--doctest-modules \
--ignore documentation \
--ignore wsgi.py \
--ignore flexmeasures/cli/data_add.py \
--ignore flexmeasures/cli/data_delete.py \
--ignore flexmeasures/cli/data_edit.py \
--ignore flexmeasures/cli/data_show.py \
--ignore flexmeasures/cli/db_ops.py \
--ignore flexmeasures/cli/jobs.py \
--ignore flexmeasures/cli/monitor.py \
--ignore flexmeasures/data/migrations \
--ignore flexmeasures/data/scripts \
-k "$PYTEST_K" \
--cov=flexmeasures \
--cov-branch \
--cov-report=lcov
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
fail-on-error: false
if: ${{ matrix.coverage == 'yes' }}
env:
PGHOST: 127.0.0.1
PGPORT: 5432
PGUSER: flexmeasures_test
PGDB: flexmeasures_test
PGPASSWORD: flexmeasures_test
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:17.4
env:
POSTGRES_USER: flexmeasures_test
POSTGRES_PASSWORD: flexmeasures_test
POSTGRES_DB: flexmeasures_test
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5