refactor: access check logic tweak #6571
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
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 | |
# fixed for now due to problems with 22.04 (see #551), try -latest sometime | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
py_version: [ "3.8", "3.9", "3.10", "3.11" ] | |
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: "Caching for dependencies (.txt) - restore existing or ensure new cache will be made" | |
uses: actions/cache@v2 | |
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 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 | |
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 |