1
+ #
2
+ # Copyright 2022-Present Sonatype Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
# For details of what checks are run for PRs please refer below
2
17
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
3
18
name : Python CI
4
19
5
20
on :
6
21
push :
7
- branches : ["master"]
22
+ branches : ["master", "main" ]
8
23
pull_request :
9
24
workflow_dispatch :
10
25
schedule :
14
29
15
30
env :
16
31
REPORTS_DIR : CI_reports
32
+ PYTHON_VERISON_DEFAULT : " 3.10"
33
+ POETRY_VERSION : " 1.1.11"
17
34
18
35
jobs :
19
36
coding-standards :
20
- name : Linting & Coding Standards
37
+ name : Linting & CodingStandards
21
38
runs-on : ubuntu-latest
22
39
steps :
23
40
- name : Checkout
@@ -27,37 +44,78 @@ jobs:
27
44
# see https://github.com/actions/setup-python
28
45
uses : actions/setup-python@v2
29
46
with :
30
- python-version : 3.9
47
+ python-version : ${{ env.PYTHON_VERISON_DEFAULT }}
31
48
architecture : ' x64'
32
49
- name : Install poetry
33
50
# see https://github.com/marketplace/actions/setup-poetry
34
51
uses : Gr1N/setup-poetry@v7
35
52
with :
36
- poetry-version : 1.1.8
37
- - uses : actions/cache@v2
38
- with :
39
- path : ~/.cache/pypoetry/virtualenvs
40
- key : ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
53
+ poetry-version : ${{ env.POETRY_VERSION }}
41
54
- name : Install dependencies
42
- run : poetry install
55
+ run : poetry install --no-root
43
56
- name : Run tox
44
57
run : poetry run tox -e flake8
45
58
46
- build-and-test :
47
- name : Build & Test (Python ${{ matrix.python-version }}
59
+ static-code-analysis :
60
+ name : StaticCodingAnalysis (py ${{ matrix.python-version}} ${{ matrix.toxenv-factor }})
48
61
runs-on : ubuntu-latest
62
+ strategy :
63
+ fail-fast : false
64
+ matrix :
65
+ include :
66
+ - # test with the locked dependencies
67
+ python-version : ' 3.10'
68
+ toxenv-factor : ' locked'
69
+ - # test with the lowest dependencies
70
+ python-version : ' 3.6'
71
+ toxenv-factor : ' lowest'
72
+ steps :
73
+ - name : Checkout
74
+ # see https://github.com/actions/checkout
75
+ uses : actions/checkout@v2
76
+ - name : Setup Python Environment
77
+ # see https://github.com/actions/setup-python
78
+ uses : actions/setup-python@v2
79
+ with :
80
+ python-version : ${{ matrix.python-version }}
81
+ architecture : ' x64'
82
+ - name : Install poetry
83
+ # see https://github.com/marketplace/actions/setup-poetry
84
+ uses : Gr1N/setup-poetry@v7
85
+ with :
86
+ poetry-version : ${{ env.POETRY_VERSION }}
87
+ - name : Install dependencies
88
+ run : poetry install --no-root
89
+ - name : Run tox
90
+ run : poetry run tox -e mypy-${{ matrix.toxenv-factor }}
91
+
92
+ build-and-test :
93
+ name : Test (${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.toxenv-factor }})
94
+ runs-on : ${{ matrix.os }}
49
95
env :
50
96
REPORTS_ARTIFACT : tests-reports
51
97
strategy :
52
98
fail-fast : false
53
99
matrix :
100
+ os : ['ubuntu-latest', 'windows-latest', 'macos-latest']
54
101
python-version :
55
- - " 3.9" # highest supported
102
+ - " 3.10" # highest supported
103
+ - " 3.9"
56
104
- " 3.8"
57
105
- " 3.7"
58
106
- " 3.6" # lowest supported
107
+ toxenv-factor : ['locked']
108
+ include :
109
+ - # test with the lowest dependencies
110
+ os : ' ubuntu-latest'
111
+ python-version : ' 3.6'
112
+ toxenv : ' lowest'
59
113
timeout-minutes : 30
60
114
steps :
115
+ - name : Disabled Git auto EOL CRLF transforms
116
+ run : |
117
+ git config --global core.autocrlf false
118
+ git config --global core.eol lf
61
119
- name : Checkout
62
120
# see https://github.com/actions/checkout
63
121
uses : actions/checkout@v2
@@ -69,25 +127,23 @@ jobs:
69
127
with :
70
128
python-version : ${{ matrix.python-version }}
71
129
architecture : ' x64'
130
+ - name : Validate Python Environment
131
+ run : echo "import sys; print('Python %s on %s in %s' % (sys.version, sys.platform, sys.getdefaultencoding()))" | python
72
132
- name : Install poetry
73
133
# see https://github.com/marketplace/actions/setup-poetry
74
134
uses : Gr1N/setup-poetry@v7
75
135
with :
76
- poetry-version : 1.1.8
77
- - uses : actions/cache@v2
78
- with :
79
- path : ~/.cache/pypoetry/virtualenvs
80
- key : ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
136
+ poetry-version : ${{ env.POETRY_VERSION }}
81
137
- name : Install dependencies
82
- run : poetry install
138
+ run : poetry install --no-root
83
139
- name : Ensure build successful
84
140
run : poetry build
85
141
- name : Run tox
86
- run : poetry run tox -e py${{ matrix.python-version }}
142
+ run : poetry run tox -e py- ${{ matrix.toxenv-factor }} -s false
87
143
- name : Generate coverage reports
88
144
run : >
89
145
poetry run coverage report &&
90
- poetry run coverage xml -o ${{ env.REPORTS_DIR }}/coverage.xml &&
146
+ poetry run coverage xml -o ${{ env.REPORTS_DIR }}/coverage-${{ matrix.os }}-${{ matrix.python-version }} .xml &&
91
147
poetry run coverage html -d ${{ env.REPORTS_DIR }}
92
148
- name : Artifact reports
93
149
if : ${{ ! cancelled() }}
0 commit comments