Pep8 action #171
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: snowexsql testing | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
flake8: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install flake8 | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# use flake8 to check formatting, based on example here https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html | |
flake8 . --count --select=C,E,F,W,B,B950 --max-complexity=10 --max-line-length=88 --statistics --extend-ignore=E203 | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.8, 3.9, '3.10'] | |
services: | |
postgis: | |
image: kartoza/postgis:14-3.2 | |
env: | |
POSTGRES_PASSWORD: db_builder | |
POSTGRES_USER: builder | |
POSTGRES_DB: test | |
TZ: 'UTC' | |
PGTZ: 'UTC' | |
POSTGIS_GDAL_ENABLED_DRIVERS: 'ENABLE_ALL' | |
POSTGIS_ENABLE_OUTDB_RASTERS: 'True' | |
ports: | |
- 5432:5432 | |
volumes: | |
- /home/runner/work/:/home/runner/work/ | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y postgis gdal-bin | |
python3 -m pip install --upgrade pip | |
python3 -m pip install pytest coverage | |
if [ -f requirements_dev.txt ]; then python3 -m pip install -r requirements_dev.txt; fi | |
- name: Test with pytest | |
run: | | |
pytest -s | |
# Run coverage only once | |
- if: ${{ matrix.python-version == '3.9'}} | |
name: Get Coverage for badge | |
run: | | |
# Run coverage save the results | |
coverage run --source snowexsql -m pytest | |
SUMMARY=`coverage report -m | grep TOTAL` | |
# Save results as ENV var | |
COVERAGE=$(python -c "print('$SUMMARY'.split(' ')[-1])") | |
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV | |
# var REF = 'refs/pull/27/merge.json'; | |
REF=${{ github.ref }} | |
# console.log('github.ref: ' + REF); | |
echo "github.ref: $REF" | |
# var PATHS = REF.split('/'); | |
IFS='/' read -ra PATHS <<< "$REF" | |
# var BRANCH_NAME = PATHS[1] + PATHS[2]; | |
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}" | |
# console.log(BRANCH_NAME); // 'pull_27' | |
echo $BRANCH_NAME | |
# process.env.BRANCH = 'pull_27'; | |
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV | |
- if: ${{ matrix.python-version == '3.9'}} | |
name: Create the Badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 2034019acc40a963bd02d2fcbb31c5a9 | |
filename: snowexsql__${{ env.BRANCH }}.json | |
label: Coverage | |
message: ${{ env.COVERAGE }} | |
color: green |