1
+ name : PR checks
2
+
3
+ on :
4
+ pull_request :
5
+ branches : [ main ]
6
+
7
+ jobs :
8
+
9
+ test :
10
+ runs-on : ubuntu-latest
11
+ strategy :
12
+ matrix :
13
+ python-version : [ '3.x' ]
14
+
15
+ steps :
16
+ - uses : actions/checkout@v2
17
+
18
+ - name : Set up Python
19
+ uses : actions/setup-python@v2
20
+ with :
21
+ python-version : ${{ matrix.python-version }}
22
+ architecture : x64
23
+ cache : ' pip'
24
+
25
+ - name : Install the requirements
26
+ run : pip install -r requirements.txt
27
+
28
+ - name : Execute the unittests
29
+ run : python3 -m unittest discover tests
30
+
31
+ lint :
32
+ runs-on : ubuntu-latest
33
+ strategy :
34
+ matrix :
35
+ python-version : [ '3.x' ]
36
+
37
+ steps :
38
+ - uses : actions/checkout@v2
39
+
40
+ - name : Set up Python
41
+ uses : actions/setup-python@v2
42
+ with :
43
+ python-version : ${{ matrix.python-version }}
44
+ architecture : x64
45
+ cache : ' pip'
46
+
47
+ - name : Install the requirements
48
+ run : pip install -r requirements.txt
49
+
50
+ - name : Execute the linting checks
51
+
52
+ with :
53
+ github_token : ${{ secrets.GITHUB_TOKEN }}
54
+ flake8_args : --config=.flake8
55
+
56
+ coverage :
57
+ runs-on : ubuntu-latest
58
+ strategy :
59
+ matrix :
60
+ python-version : [ '3.x' ]
61
+
62
+ steps :
63
+ - uses : actions/checkout@v2
64
+ with :
65
+ persist-credentials : false
66
+ fetch-depth : 0
67
+
68
+ - name : Set up Python
69
+ uses : actions/setup-python@v2
70
+ with :
71
+ python-version : ${{ matrix.python-version }}
72
+ architecture : x64
73
+ cache : ' pip'
74
+
75
+ - name : Install the requirements
76
+ run : pip install -r requirements.txt && pip install pytest pytest-cov coverage-badge
77
+
78
+ - name : Generate the coverage report
79
+ run : export PYTHONPATH=$PWD && pytest --junitxml=pytest.xml --cov=. tests/ | tee pytest-coverage.txt
80
+
81
+ - name : Execute the coverage checks
82
+
83
+ with :
84
+ github_token : ${{ secrets.GITHUB_TOKEN }}
85
+ pytest-coverage-path : ./pytest-coverage.txt
86
+ junitxml-path : ./pytest.xml
87
+ hide-badge : true
88
+ create-new-commit : true
89
+
90
+ - name : " Check if coverage badge file existence"
91
+ id : check_files
92
+ uses : andstor/file-existence-action@v1
93
+ with :
94
+ files : " docs/coverage.svg"
95
+
96
+ - name : Generate coverage badge
97
+ if : steps.check_files.outputs.files_exists == 'false'
98
+ run : coverage-badge -o docs/coverage.svg -f
99
+
100
+ - name : Commit files
101
+ if : steps.check_files.outputs.files_exists == 'false'
102
+ run : |
103
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
104
+ git config --local user.name "github-actions[bot]"
105
+ git add --force docs/coverage.svg
106
+ git commit -m "Add coverage badge"
107
+
108
+ - name : Push changes
109
+ if : steps.check_files.outputs.files_exists == 'false'
110
+ uses : ad-m/github-push-action@master
111
+ with :
112
+ github_token : ${{ secrets.GITHUB_TOKEN }}
113
+ branch : ${{ github.head_ref }}
114
+ force : true
0 commit comments