-
Notifications
You must be signed in to change notification settings - Fork 29
73 lines (69 loc) · 2.4 KB
/
python-build.yaml
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
# SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project <korte.termijn.prognoses@alliander.com> # noqa E501
#
# SPDX-License-Identifier: MPL-2.0
name: Python Build
on:
- push
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
steps:
# Checkout
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
# Setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# Restore
- name: Restore pip cache
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
# Install
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
# Very limited linting with Flake8 (see setup.cfg for configuration)
- name: Lint
run: |
pip install flake8
# Stop build on a couple more serious violations
# See https://flake8.pycqa.org/en/latest/user/error-codes.html for more details
flake8 . --count --select=E9,F63,F7,F8 --show-source --statistics
# Only print warnings on all other errors
flake8 . --count --exit-zero --show-source --statistics
# Test
- name: Unit test with pytest
run: |
pip install pytest pytest-cov
pytest --cov-report=xml --cov=openstef/ test/ --junitxml=pytest-report.xml
# Fix relative paths in coverage file
# Known bug: https://community.sonarsource.com/t/sonar-on-github-actions-with-python-coverage-source-issue/36057
- name: fix code coverage paths
run: |
sed -i 's/\/home\/runner\/work\/openstef\/openstef\//\/github\/workspace\//g' coverage.xml
# Sonar cloud scan
- name: SonarCloud Scan
if: ${{ github.actor != 'dependabot[bot]' }}
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Build
- name: Build Python package
run: |
python setup.py sdist bdist_wheel