Skip to content
Commits on Source (2)
......@@ -12,7 +12,5 @@ build/
dist/
# unit-testing, coverage, etc.
/*.xml
/*.json
.coverage*
.noseids
/*_cache/
/results/
stages:
- test
- acceptance
- build
- publish
include:
- project: dom/project-templates
file: /pipeline-templates/pre-commit.yml
- project: dom/project-templates
ref: tmp
file: /pipeline-templates/python-package.yml
image: python:3.8
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
cache:
key: all
paths:
- .cache/
- .eggs/
.python:
image: python:3.12
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/cache/pkg
PIP_NO_COMPILE: "true"
PIP_NO_CLEAN: "true"
cache:
key: $CI_JOB_IMAGE
paths: [cache]
# Unit Tests
.unittest:
stage: test
image: python:$PY_VERSION
before_script:
- pip install -e .[test] nose2
- pip install -e .[test] coverage pytest
- mkdir results
script:
- nose2 -v -c setup.cfg
- coverage run -m pytest -v --junit-xml=results/junit.xml
after_script:
- mv .coverage .coverage.$PY_VERSION
- mv .unittest.xml .unittest.$PY_VERSION.xml
coverage: '/^TOTAL.* ([0-9.]+\%)$/'
- mv results results.$PY_VERSION
artifacts:
when: always
paths:
- .noseids
- .coverage.*
- .unittest.$PY_VERSION.xml
- results.$PY_VERSION
reports:
junit: .unittest.$PY_VERSION.xml
junit: results.$PY_VERSION/junit.xml
unittest:3.8:
extends: .unittest
Unit Tests (Py 3.10):
extends: [.python, .unittest]
variables:
PY_VERSION: '3.8'
PY_VERSION: '3.10'
unittest:3.9:
extends: .unittest
Unit Tests (Py 3.11):
extends: [.python, .unittest]
variables:
PY_VERSION: '3.9'
PY_VERSION: '3.11'
unittest:3.10:
extends: .unittest
Unit Tests (Py 3.12):
extends: [.python, .unittest]
variables:
PY_VERSION: '3.10-rc'
PY_VERSION: '3.12'
publish:unittests:
stage: publish
Publish Unit Tests:
stage: deploy
extends: [.python]
when: always
dependencies: &unittests
- unittest:3.8
- unittest:3.9
- unittest:3.10
- Unit Tests (Py 3.10)
- Unit Tests (Py 3.11)
- Unit Tests (Py 3.12)
needs: *unittests
script:
- pip install --upgrade junit2html
- mkdir -p unittest
- python util/junit_merge.py .unittest.*.xml > .unittest.xml
- junit2html .unittest.xml unittest/index.html
- pip install --upgrade junit2html
- mkdir -p unittest
- python util/junit_merge.py results.*/junit.xml > junit.xml
- junit2html junit.xml unittest/index.html
artifacts:
when: always
paths:
- .unittest.xml
- unittest
- junit.xml
- unittest
reports:
junit: junit.xml
# Aggregate Coverage
coverage:
stage: acceptance
Aggregate Coverage:
stage: test
extends: [.python]
when: always
dependencies: *unittests
needs: *unittests
script:
- pip install --upgrade coverage
- coverage combine
- coverage report
- pip install --upgrade coverage
- coverage combine results.*
- coverage report
coverage: '/^TOTAL.* ([0-9.]+\%)$/'
artifacts:
when: always
paths:
- .coverage
- results
publish:coverage:
stage: publish
Publish Coverage:
stage: deploy
extends: [.python]
when: always
dependencies: [coverage]
needs: [coverage]
dependencies: [Aggregate Coverage]
needs: [Aggregate Coverage]
script:
- pip install --upgrade coverage
- coverage html --fail-under=0 -d coverage
- coverage xml --fail-under=0 -o coverage/coverage.xml
- coverage html --fail-under=0 -d results/coverage.html
- coverage xml --fail-under=0 -o results/coverage.xml
artifacts:
when: always
paths:
- coverage
# Quality Assurance
Code Analysis:
stage: test
variables:
FROM_REF: $CI_DEFAULT_BRANCH
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
FROM_REF: $CI_COMMIT_BEFORE_SHA
- when: always
before_script:
- pip install pre-commit
script:
- git fetch $CI_REPOSITORY_URL $FROM_REF:FROM_REF -f
- pre-commit run
--hook-stage=commit
--from-ref=FROM_REF
--to-ref=${CI_COMMIT_SHA}
Commit Graph Analysis:
stage: test
variables:
FROM_REF: $CI_DEFAULT_BRANCH
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
FROM_REF: $CI_COMMIT_BEFORE_SHA
- if: $CI_PIPELINE_TRIGGERED == "merge_request_event"
before_script:
- pip install pre-commit
script:
- pre-commit run
--hook-stage=push
--from-ref=FROM_REF
--to-ref=${CI_COMMIT_SHA}
# Package publishing
Check Tag:
stage: test
rules:
- if: $CI_COMMIT_TAG =~ /^v[0-9]/
script:
- test `./setup.py --version` == ${CI_COMMIT_TAG#v}
Build Packages:
stage: build
script:
- ./setup.py bdist_wheel sdist
artifacts:
paths:
- dist
Upload Packages:
stage: publish
rules:
- if: $CI_COMMIT_TAG =~ /^v[0-9]/
dependencies:
- Build Packages
script:
- pip install twine
- TWINE_PASSWORD=$CI_JOB_TOKEN
TWINE_USERNAME=gitlab-ci-token
twine upload
--verbose
--non-interactive
--repository-url $CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/pypi
dist/*
- results
......@@ -16,3 +16,37 @@ implicit_reexport = true
strict = true
warn_unreachable = true
warn_unused_configs = true
[tool.coverage.run]
data_file = "results/coverage.db"
branch = true
source = ["wpa_supplicant"]
[tool.coverage.report]
precision = 2
skip_empty = true
exclude_lines = [
"pragma: no-cover",
"if .*\\b__name__\\b",
"if .*\\bTYPE_CHECKING\\b",
"class .*(.*\\bProtocol\\b.*):",
"def __repr__",
"@overload",
"@(abc\\.)abstractmethod",
]
partial_branches = [
"pragma: no-branch",
"if .*\\b__debug__\\b",
]
[tool.coverage.json]
output = "results/coverage.json"
show_contexts = true
[tool.coverage.xml]
output = "results/coverage.xml"
[tool.coverage.html]
directory = "results/coverage"
show_contexts = true
......@@ -45,50 +45,6 @@ test =
nose2[coverage_plugin]
trio
[unittest]
start-dir = tests/unit
verbose = True
plugins =
nose2.plugins.junitxml
nose2.plugins.testid
[coverage]
always-on = True
coverage = wpa_supplicant
coverage-report = term
[coverage:run]
branch = True
[coverage:report]
fail_under = 80
precision = 2
show_missing = True
omit = **/__main__.py
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
def __repr__
__version__ =
@(.*\.)?abstract((static|class)?method|property)
except ImportError:\s*(...|pass)
[coverage:xml]
output = .coverage.xml
[coverage:html]
directory = .coverage.html.d
[junit-xml]
always-on = True
path = .unittest.xml
[testid]
always-on = True
[log-capture]
always-on = True
[isort]
force_single_line = true
......