|
| 1 | +name: Python application |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, windows-latest] |
| 18 | + python-version: [3.8, 3.9, 3.10, 3.11] |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - name: Set up Python ${{ matrix.python-version }} |
| 22 | + uses: actions/setup-python@v3 |
| 23 | + with: |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + - name: Cache pip on Linux |
| 26 | + if: runner.os == 'Linux' |
| 27 | + uses: actions/cache@v3 |
| 28 | + with: |
| 29 | + path: ~/.cache/pip |
| 30 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-pip- |
| 33 | + - name: Cache pip on Windows |
| 34 | + if: runner.os == 'Windows' |
| 35 | + uses: actions/cache@v3 |
| 36 | + with: |
| 37 | + path: C:\Users\runneradmin\AppData\Local\pip\Cache |
| 38 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-pip- |
| 41 | + - name: Install dependencies |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + python -m pip install --upgrade pip |
| 45 | + pip install flake8 pytest coverage |
| 46 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 47 | + - name: Lint with flake8 |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + # Stop the build if there are Python syntax errors or undefined names |
| 51 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 52 | + # Exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide. |
| 53 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 54 | + - name: Test with coverage |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + coverage run -m pytest |
| 58 | + coverage report |
0 commit comments