Skip to content

Commit 0e3cd01

Browse files
authored
test: fix slow tests and add timing reports (#962)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent e395d0f commit 0e3cd01

File tree

5 files changed

+57
-17
lines changed

5 files changed

+57
-17
lines changed

.github/workflows/docker.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# This file is part of CycloneDX Python
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
118
# For details of what checks are run for PRs please refer below
219
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
320

@@ -41,7 +58,6 @@ jobs:
4158
uses: actions/setup-python@v5
4259
with:
4360
python-version: ${{ env.PYTHON_VERSION }}
44-
architecture: 'x64'
4561
- name: Setup poetry ${{ env.POETRY_VERSION }}
4662
# see https://github.com/marketplace/actions/setup-poetry
4763
uses: Gr1N/setup-poetry@v9

.github/workflows/python.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
# This file is part of CycloneDX Python
42
#
53
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +15,9 @@
1715
# SPDX-License-Identifier: Apache-2.0
1816
# Copyright (c) OWASP Foundation. All Rights Reserved.
1917

18+
# For details of what checks are run for PRs please refer below
19+
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
20+
2021
name: Python CI
2122

2223
on:
@@ -57,7 +58,6 @@ jobs:
5758
uses: actions/setup-python@v5
5859
with:
5960
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
60-
architecture: 'x64'
6161
- name: Install poetry
6262
# see https://github.com/marketplace/actions/setup-poetry
6363
uses: Gr1N/setup-poetry@v9
@@ -81,7 +81,6 @@ jobs:
8181
uses: actions/setup-python@v5
8282
with:
8383
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
84-
architecture: 'x64'
8584
- name: Install poetry
8685
# see https://github.com/marketplace/actions/setup-poetry
8786
uses: Gr1N/setup-poetry@v9
@@ -105,7 +104,6 @@ jobs:
105104
uses: actions/setup-python@v5
106105
with:
107106
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
108-
architecture: 'x64'
109107
- name: Install poetry
110108
# see https://github.com/marketplace/actions/setup-poetry
111109
uses: Gr1N/setup-poetry@v9
@@ -139,7 +137,6 @@ jobs:
139137
uses: actions/setup-python@v5
140138
with:
141139
python-version: ${{ matrix.python-version }}
142-
architecture: 'x64'
143140
- name: Install poetry
144141
# see https://github.com/marketplace/actions/setup-poetry
145142
uses: Gr1N/setup-poetry@v9
@@ -163,7 +160,6 @@ jobs:
163160
uses: actions/setup-python@v5
164161
with:
165162
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
166-
architecture: 'x64'
167163
- name: Install poetry
168164
# see https://github.com/marketplace/actions/setup-poetry
169165
uses: Gr1N/setup-poetry@v9
@@ -197,7 +193,6 @@ jobs:
197193
uses: actions/setup-python@v5
198194
with:
199195
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
200-
architecture: 'x64'
201196
- name: Install self
202197
run: pip install .
203198
- name: run command
@@ -206,7 +201,7 @@ jobs:
206201
build-and-test:
207202
name: Test (${{ matrix.os }} py${{ matrix.python-version }})
208203
runs-on: ${{ matrix.os }}
209-
timeout-minutes: 10
204+
timeout-minutes: 180
210205
strategy:
211206
fail-fast: false
212207
matrix:
@@ -228,8 +223,10 @@ jobs:
228223
include:
229224
- os: macos-13
230225
python-version: "3.10"
226+
unittest-args: []
231227
- os: macos-13
232228
python-version: "3.9"
229+
unittest-args: []
233230
steps:
234231
- name: Checkout
235232
# see https://github.com/actions/checkout
@@ -241,7 +238,15 @@ jobs:
241238
uses: actions/setup-python@v5
242239
with:
243240
python-version: ${{ matrix.python-version }}
244-
architecture: 'x64'
241+
- name: craft PY_UT_ARGS
242+
shell: python
243+
run: |-
244+
import sys, os
245+
PY_UT_ARGS=[]
246+
if sys.version_info >= (3, 12):
247+
PY_UT_ARGS.append('--durations=0')
248+
with open(os.environ['GITHUB_ENV'], 'a') as env_file:
249+
env_file.write(f'PY_UT_ARGS={" ".join(PY_UT_ARGS)}\n')
245250
- name: Install poetry
246251
# see https://github.com/marketplace/actions/setup-poetry
247252
uses: Gr1N/setup-poetry@v9
@@ -252,7 +257,7 @@ jobs:
252257
- name: Ensure build successful
253258
run: poetry build
254259
- name: Run tox
255-
run: poetry run tox r -e py -s false
260+
run: poetry run -- tox r -e py -s false -- $PY_UT_ARGS
256261
- name: Generate coverage reports
257262
if: ${{ failure() || success() }}
258263
shell: bash

.github/workflows/release.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# This file is part of CycloneDX Python
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
18+
# For details of what checks are run for PRs please refer below
19+
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
20+
121
name: Release
222

323
on:
@@ -57,7 +77,6 @@ jobs:
5777
uses: actions/setup-python@v5
5878
with:
5979
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
60-
architecture: 'x64'
6180
- name: Install poetry
6281
# see https://github.com/marketplace/actions/setup-poetry
6382
uses: Gr1N/setup-poetry@v9
@@ -81,7 +100,6 @@ jobs:
81100
uses: actions/setup-python@v5
82101
with:
83102
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
84-
architecture: 'x64'
85103
- name: Install poetry
86104
# see https://github.com/marketplace/actions/setup-poetry
87105
uses: Gr1N/setup-poetry@v9
@@ -122,7 +140,6 @@ jobs:
122140
uses: actions/setup-python@v5
123141
with:
124142
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
125-
architecture: 'x64'
126143
- name: Install and configure Poetry
127144
# See https://github.com/marketplace/actions/install-poetry-action
128145
uses: snok/install-poetry@v1

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ tomli = { version = "^2.0.1", python = "<3.11" }
9696
tox = "4.27.0"
9797
pyupgrade = "3.20.0"
9898
deptry = "0.23.0"
99+
# for tests, use the GPL-version of jsonschema format validators - they are faster
100+
jsonschema = { version = "*", extras = ["format"] }
99101

100102
# min version required to be able to install some dependencies
101103
# see https://github.com/MichaelKim0407/flake8-use-fstring/issues/33

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ allowlist_externals = poetry
2323
## deps = poetry ## << this one caused https://github.com/python-poetry/poetry/issues/6288
2424
commands_pre =
2525
{envpython} --version
26-
poetry install --no-root -v
26+
# poetry install --no-root -v
2727
poetry run pip freeze
2828
commands =
29-
poetry run coverage run --source=cyclonedx_py -m unittest discover -t . -s tests -v
29+
poetry run coverage run --source=cyclonedx_py -m unittest discover -t . -s tests -v {posargs}
3030
setenv =
3131
PYTHONHASHSEED=0
3232
CDX_TEST_RECREATE_SNAPSHOTS={env:CDX_TEST_RECREATE_SNAPSHOTS:}

0 commit comments

Comments
 (0)