[fde104]: / .github / workflows / python-app.yml

Download this file

115 lines (92 with data), 3.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python application
on:
push:
branches: [ dev, main, release ]
tags: v*
pull_request:
branches: [ dev, main, release ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
sudo apt-get install -y libopenslide-dev libopenjp2-7
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Echo OpenSlide Version
run: dpkg -s libopenslide-dev | grep Version
- name: Echo OpenJPEG Version
run: opj_compress -h | head
- name: List PIP Package Versions
run: |
pip list
- 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
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.xml
- name: Report test coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: coverage.xml
fail_ci_if_error: false
verbose: true
- name: Report test coverage to DeepSource
uses: deepsourcelabs/test-coverage-action@master
with:
key: python
coverage-file: coverage.xml
dsn: ${{ secrets.DEEPSOURCE_DSN }}
fail-ci-on-error: false
release:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: build
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
cache: 'pip'
- name: Install dependencies
run: |
sudo apt-get install -y libopenslide-dev libopenjp2-7
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install build
- name: Build package
run: python -m build
- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish package to PyPI
if: startsWith(github.ref, 'refs/tags/v') # Only run on tags starting with v
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}