12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- name: lint-and-test
- on:
- push:
- pull_request:
- types:
- - opened
- jobs:
- check:
- runs-on: ubuntu-latest
- name: Check (on Python 3.9)
- steps:
- - uses: actions/setup-python@v4
- with:
- python-version: 3.9
- - 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.8", "3.9", "3.10", "3.11", "3.12" ]
- include:
- - python-version: "3.9"
- 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
- run: |
- pip3 install --upgrade pip
- - 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 doctests in the data/schemas subpackage
- run: pytest flexmeasures/data/schemas --doctest-modules --ignore flexmeasures/data/schemas/tests
- - name: Run all doctests in the utils subpackage
- run: pytest flexmeasures/utils --doctest-modules --ignore flexmeasures/utils/tests
- - name: Run all tests except those marked to be skipped by GitHub AND record coverage
- run: pytest -v -m "not skip_github" --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:12.5
- 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
|