Skip to content

feature: Allows fallback to Basic Auth in PKCE mode #8055

feature: Allows fallback to Basic Auth in PKCE mode

feature: Allows fallback to Basic Auth in PKCE mode #8055

Workflow file for this run

name: Python Lint and Test
on: pull_request
jobs:
test:
env:
# Minimum code coverage per file
COVERAGE_SINGLE: 50
# Minimum total code coverage
COVERAGE_TOTAL: 54
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: dispatch
POSTGRES_DB: dispatch
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
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11.2
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
export DISPATCH_LIGHT_BUILD=1
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: "Lint with ruff"
run: |
ruff check src tests
ruff format src tests
- name: Test with pytest
run: |
pip install pytest-cov
pytest --junitxml=junit/test-results.xml --cov=dispatch --cov-report=json:coverage.json --cov-report=xml --cov-report=html
- name: Coverage per file
# TODO: Change this recommendation into a requirement.
run: |
export FAILED_COVERAGE_PER_FILE=$(python -c "import json;files=json.load(open('coverage.json'))['files'];covs=map(lambda k, v: (k, v['summary']['percent_covered_display']),files.keys(),files.values()); f=filter(lambda cov:int(cov[1])<${{ env.COVERAGE_SINGLE }},covs); print('\n'.join('{:<68}{:>3}%'.format(k,v) for k,v in f))")
if [[ $FAILED_COVERAGE_PER_FILE != "" ]]; then
echo "FAIL Recommended file(s) test coverage of ${{ env.COVERAGE_SINGLE }}% not reached."
echo -e "Failed file coverage(s):\n$FAILED_COVERAGE_PER_FILE"
# exit 1
fi
- name: Coverage total
run: |
export COVERAGE_TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
if [[ $COVERAGE_TOTAL < ${{ env.COVERAGE_TOTAL }} ]]; then
echo "FAIL Recommended total test coverage of ${{ env.COVERAGE_TOTAL }}% not reached. Total coverage: $COVERAGE_TOTAL%"
exit 1
fi