-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from grip-on-software/module-test-analysis
Modularization, documentation, typing analysis and tests, with GitHub Actions workflow
- Loading branch information
Showing
51 changed files
with
1,943 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[run] | ||
branch = True | ||
[report] | ||
exclude_also = | ||
if TYPE_CHECKING: | ||
except ImportError: | ||
raise NotImplementedError | ||
raise AssertionError | ||
\.\.\. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: grip-on-software/upload | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4.1.4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v5.1.0 | ||
with: | ||
python-version: "${{ matrix.python }}" | ||
- name: Install development packages for some dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install gnupg libgpg-error-dev libgpgme-dev libssl-dev swig | ||
- name: Install dependencies for test | ||
run: make setup_test | ||
- name: Unit test and coverage | ||
run: make coverage | ||
env: | ||
WEBTEST_INTERACTIVE: "False" | ||
- name: Mypy typing coverage | ||
run: | | ||
make setup_analysis | ||
make mypy | ||
- name: Adjust source paths in coverage for Sonar | ||
run: | | ||
sed -i "s/<source>\/home\/runner\/work\/upload\/upload/<source>\/github\/workspace/g" \ | ||
test-reports/cobertura.xml mypy-report/cobertura.xml | ||
- name: SonarCloud Scan | ||
uses: sonarsource/sonarcloud-github-action@v2.1.1 | ||
if: "${{ matrix.python == '3.8.18' }}" | ||
env: | ||
SONAR_TOKEN: "${{ secrets.SONAR_TOKEN }}" | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
- name: Coveralls upload | ||
run: | | ||
pip install coveralls | ||
coveralls | ||
if: "${{ success() }}" | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
strategy: | ||
matrix: | ||
python: | ||
- '3.8.18' | ||
- '3.12.3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
PACKAGE=gros-upload | ||
MODULE=upload | ||
COVERAGE=coverage | ||
MYPY=mypy | ||
PIP=python -m pip | ||
PYLINT=pylint | ||
RM=rm -rf | ||
SOURCES_ANALYSIS=encrypted_upload test | ||
SOURCES_COVERAGE=encrypted_upload,test | ||
TEST=-m pytest -s test | ||
TEST_OUTPUT=--junit-xml=test-reports/TEST-pytest.xml | ||
TWINE=twine | ||
|
||
.PHONY: all | ||
all: coverage mypy pylint | ||
|
||
.PHONY: release | ||
release: test mypy pylint clean build tag push upload | ||
|
||
.PHONY: setup | ||
setup: | ||
$(PIP) install -r requirements.txt | ||
|
||
.PHONY: setup_release | ||
setup_release: | ||
$(PIP) install -r requirements-release.txt | ||
|
||
.PHONY: setup_analysis | ||
setup_analysis: | ||
$(PIP) install -r requirements-analysis.txt | ||
|
||
.PHONY: setup_test | ||
setup_test: | ||
$(PIP) install -r requirements-test.txt | ||
|
||
.PHONY: install | ||
install: | ||
$(PIP) install . | ||
|
||
.PHONY: pylint | ||
pylint: | ||
$(PYLINT) $(SOURCES_ANALYSIS) --exit-zero --reports=n \ | ||
--msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \ | ||
-d duplicate-code | ||
|
||
.PHONY: mypy | ||
mypy: | ||
$(MYPY) $(SOURCES_ANALYSIS) \ | ||
--cobertura-xml-report mypy-report \ | ||
--junit-xml mypy-report/TEST-junit.xml \ | ||
--no-incremental --show-traceback | ||
|
||
.PHONY: mypy_html | ||
mypy_html: | ||
$(MYPY) $(SOURCES_ANALYSIS) \ | ||
--html-report mypy-report \ | ||
--cobertura-xml-report mypy-report \ | ||
--junit-xml mypy-report/TEST-junit.xml \ | ||
--no-incremental --show-traceback | ||
|
||
.PHONY: test | ||
test: | ||
python $(TEST) $(TEST_OUTPUT) | ||
|
||
.PHONY: coverage | ||
coverage: | ||
$(COVERAGE) run --source=$(SOURCES_COVERAGE) $(TEST) $(TEST_OUTPUT) | ||
$(COVERAGE) report -m | ||
$(COVERAGE) xml -i -o test-reports/cobertura.xml | ||
|
||
# Version of the coverage target that does not write JUnit/cobertura XML output | ||
.PHONY: cover | ||
cover: | ||
$(COVERAGE) run --source=$(SOURCES_COVERAGE) $(TEST) | ||
$(COVERAGE) report -m | ||
|
||
.PHONY: get_version | ||
get_version: get_toml_version get_init_version get_sonar_version get_citation_version | ||
if [ "${TOML_VERSION}" != "${INIT_VERSION}" ] || [ "${TOML_VERSION}" != "${SONAR_VERSION}" ] || [ "${TOML_VERSION}" != "${CITATION_VERSION}" ]; then \ | ||
echo "Version mismatch"; \ | ||
exit 1; \ | ||
fi | ||
$(eval VERSION=$(TOML_VERSION)) | ||
|
||
.PHONY: get_init_version | ||
get_init_version: | ||
$(eval INIT_VERSION=v$(shell grep __version__ $(MODULE)/__init__.py | sed -E "s/__version__ = .([0-9.]+)./\\1/")) | ||
$(info Version in __init__.py: $(INIT_VERSION)) | ||
if [ -z "${INIT_VERSION}" ]; then \ | ||
echo "Could not parse version"; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: get_toml_version | ||
get_toml_version: | ||
$(eval TOML_VERSION=v$(shell grep "^version" pyproject.toml | sed -E "s/version = .([0-9.]+)./\\1/")) | ||
$(info Version in pyproject.toml: $(TOML_VERSION)) | ||
|
||
.PHONY: get_sonar_version | ||
get_sonar_version: | ||
$(eval SONAR_VERSION=v$(shell grep projectVersion sonar-project.properties | cut -d= -f2)) | ||
$(info Version in sonar-project.properties: $(SONAR_VERSION)) | ||
|
||
.PHONY: get_citation_version | ||
get_citation_version: | ||
$(eval CITATION_VERSION=v$(shell grep "^version:" CITATION.cff | cut -d' ' -f2)) | ||
$(info Version in CITATION.cff: $(CITATION_VERSION)) | ||
|
||
.PHONY: tag | ||
tag: get_version | ||
git tag $(VERSION) | ||
|
||
.PHONY: build | ||
build: | ||
python -m build | ||
|
||
.PHONY: push | ||
push: get_version | ||
git push origin $(VERSION) | ||
|
||
.PHONY: upload | ||
upload: | ||
$(TWINE) upload dist/* | ||
|
||
.PHONY: clean | ||
clean: | ||
# Typing coverage and Pylint | ||
$(RM) .mypy_cache mypy-report/ pylint-report.txt | ||
# Tests | ||
$(RM) test/sample/upload/ | ||
# Pip and distribution | ||
$(RM) src/ build/ dist/ $(PACKAGE).egg-info/ |
Oops, something went wrong.