-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (87 loc) · 2.86 KB
/
Copy pathgithub-python-workflow.yml
File metadata and controls
105 lines (87 loc) · 2.86 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
# This workflow handles linting, testing, and SonarQube scanning for the OGC repository.
name: Python Workflow
on:
push:
branches: [ main, develop ]
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install --upgrade pip setuptools && pip install .[dev]
- name: Run flake8 lint checks
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --ignore=E,W,D,I,N806,N815,N818,Q000,Q001,Q002,S001,B008,B028 --show-source --statistics --max-line-length=120 --output-file=flake8-report.txt
- name: Run black format checks
run: black --check --diff -l 120 ogc example > black-report.txt
- name: Artifact flake8 report
uses: actions/upload-artifact@v4
with:
name: flake8-report
path: flake8-report.txt
retention-days: 1
- name: Artifact black report
uses: actions/upload-artifact@v4
with:
name: black-report
path: black-report.txt
retention-days: 1
unit_testing:
name: Unit Testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install dependencies
run: |
pip install --upgrade pip setuptools && pip install .[dev]
- name: Run pytest with coverage
run: |
coverage run --data-file=coverage.bin --branch \
-m pytest --continue-on-collection-errors || \
{ echo "WARNING: Some tests have failed. (Temporarily ignored)"; true; }
coverage xml --data-file=coverage.bin -o coverage.xml
sed -i 's,<source>.*/ogc</source>,<source>ogc</source>,' coverage.xml
- name: Artifact coverage document
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.xml
retention-days: 1
sonarqube_scan:
name: SonarQube Scan
needs: [ unit_testing ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage
path: .
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}