Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/testing-42.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ jobs:
- name: Local Integration Testing
run: make test-integration

- name: Upload coverage reports to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml

- name: Upload test results to Codecov
uses: codecov/codecov-action@v5
if: ${{ !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: junit.xml
report_type: test_results
11 changes: 10 additions & 1 deletion .github/workflows/testing-52.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ jobs:
- name: Local Integration Testing
run: make test-integration

- name: Upload coverage reports to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml

- name: Upload test results to Codecov
uses: codecov/codecov-action@v5
if: ${{ !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: junit.xml
report_type: test_results
11 changes: 10 additions & 1 deletion .github/workflows/testing-60.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ jobs:
- name: Local Integration Testing
run: make test-integration

- name: Upload coverage reports to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml

- name: Upload test results to Codecov
uses: codecov/codecov-action@v5
if: ${{ !cancelled() }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: junit.xml
report_type: test_results
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ beta_dist/

# Testing
.coverage
coverage.xml
junit.xml
junit-integration.xml

.cache/
.tox/
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ This release aligns with recent Django releases and Python releases.
- Updated `actions/checkout@v2` references to `actions/checkout@v6`.
- Renamed GitHub Actions workflows to match supported Django versions (`testing-42.yaml`, `testing-52.yaml`, `testing-60.yaml`).
- Updated `tox.ini` to test against Django `4.2`, `5.2`, and `6.0`.
- General `Makefile` refactoring.
- Added `scripts/testpypi_integration.sh` for testing deployed Test PyPI packages.
- Added Test PyPI integration test matrix to `tox.ini` with parallel execution support.
- Migrated unit tests to `pytest` with `pytest-django` and `pytest-cov`.
- Added Codecov test results integration via JUnit XML output.
- Fixed Codecov coverage upload by generating `coverage.xml` during test runs.
- General Updates:
- Added `Development` section to `README` with `uv` setup instructions.
- Updated `pyproject.toml` to include missing classifiers.
Expand Down
124 changes: 57 additions & 67 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,32 @@
DIST = ./dist
BETA_DIST = ./beta_dist

#---------------------------------------------------------------------------------------------------
# Composite Variables
#---------------------------------------------------------------------------------------------------

CLEAN_TARGETS = ./.cache ./.tox ./*.egg-info ./.pytest_cache $(BETA_DIST) $(DIST) ./build ./htmlcov .coverage coverage.xml
CLEAN_TARGETS = ./.cache ./.tox ./*.egg-info ./.pytest_cache $(BETA_DIST) $(DIST) ./build ./htmlcov .coverage coverage.xml junit.xml junit-integration.xml

########################################################################################################################
# `make help` Needs to be first so it is ran when just `make` is called
# Utilities
########################################################################################################################


# `help` Needs to be first so it is ran when just `make` is called
.PHONY: help
help: # Show this help screen
@ack '^[a-zA-Z_-]+:.*?# .*$$' $(MAKEFILE_LIST) |\
sort -k1,1 |\
LC_ALL=C sort -t: -k1,1 |\
awk 'BEGIN {FS = ":.*?# "}; {printf "\033[1m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: clean
clean: # Clean up build, test, and other project artifacts
rm -rf $(CLEAN_TARGETS) && \
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf && \
:

########################################################################################################################
# Testing
########################################################################################################################

.PHONY: run-tox
run-tox: # Run tox for the project
@uv run tox

.PHONY: test
test: version-check test-flake test-unit test-coverage-report # Run the full testing suite

#---------------------------------------------------------------------------------------------------
# Versioning
#---------------------------------------------------------------------------------------------------

.PHONY: version-check
version-check: # Verify the project version string is correct across the project
Expand All @@ -41,112 +40,103 @@ version-check: # Verify the project version string is correct across the project
version-check-django: # Verify the project's Django version
@uv run python -c 'import django; print(django.VERSION)'

########################################################################################################################
# Testing
########################################################################################################################

.PHONY: test
test: version-check test-flake test-unit test-coverage-report # Run the full testing suite

.PHONY: test-tox
test-tox: # Run tox for the project
@uv run tox -p auto

#---------------------------------------------------------------------------------------------------
# Test Subcommands
# Internal Test Commands
#---------------------------------------------------------------------------------------------------


# Report test coverage after tests are complete
.PHONY: test-coverage-report
test-coverage-report:
@uv run coverage report


# Run flake8 against project files
.PHONY: test-flake
test-flake:
@uv run flake8 -v


# Tox testing requires coverage to "append" results
.PHONY: test-tox
test-tox: COV-ARGS = --append
test-tox: test-unit

.PHONY: test-tox-entry
test-tox-entry: COV-ARGS = --append
test-tox-entry: test-unit

# Run only unit tests
.PHONY: test-unit
test-unit:
@uv run coverage run \
${COV-ARGS} \
--source="./letsencrypt" \
--omit="\
./letsencrypt/migrations/*,\
./letsencrypt/admin.py,\
./letsencrypt/apps.py,\
./letsencrypt/tests.py,\
./letsencrypt/urls.py,\
" \
example_project/manage.py test \
--settings=example_project.settings_test \

@uv run pytest letsencrypt/tests.py \
--cov=letsencrypt \
--cov-config=pyproject.toml \
--cov-report=term-missing \
--cov-report=xml \
--junitxml=junit.xml \
${PYTEST-ARGS} \

########################################################################################################################
# Integration Testing
########################################################################################################################


.PHONY: test-integration
test-integration: # Run the integration tests for the project
@./scripts/local_integration.sh

.PHONY: test-integration-testpypi
test-integration-testpypi: # Test the deployed Test PyPI package (requires VERSION arg)
@./scripts/testpypi_integration.sh $(VERSION)

########################################################################################################################
# Project Publishing
########################################################################################################################


.PHONY: publish
publish: build # Build and publish the package to PyPi
uv run twine upload --repository pypi $(DIST)/*


.PHONY: test-publish
test-publish: build-beta # Build and publish the package to TestPyPi
uv run twine upload --repository testpypi $(BETA_DIST)/*

.PHONY: test-integration-testpypi-tox
test-integration-testpypi-tox: # Test the deployed Test PyPI package for all versions in parallel with tox (requires VERSION arg)
@TESTPYPI_VERSION=$(VERSION) uv run tox -m testpypi -p all

########################################################################################################################
# Project Building
# Building
########################################################################################################################


.PHONY: build
build: build-pre build-package # Build the release package


.PHONY: build-beta
build-beta: build-pre build-beta-package # Build the beta package


.PHONY: clean
clean: # Clean up build, test, and other project artifacts
rm -rf $(CLEAN_TARGETS) && \
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf && \
:

#---------------------------------------------------------------------------------------------------
# Build Subcommands
# Internal Build Commands
#---------------------------------------------------------------------------------------------------


# Perform required pre-build steps for all build types
.PHONY: build-pre
build-pre: version-check clean test


# Build 'sdist' and 'bdist_wheel' for this package (PyPi)
# Build 'sdist' and 'bdist_wheel' for this package (PyPI)
.PHONY: build-package
build-package:
uv build --out-dir $(DIST)


# Build 'sdist' and 'bdist_wheel' for the beta package (Test PyPi)
# Build 'sdist' and 'bdist_wheel' for the beta package (Test PyPI)
.PHONY: build-beta-package
build-beta-package:
uv run ./scripts/version_manager.py set-beta-build && \
uv run ./scripts/version_manager.py check && \
uv build --out-dir $(BETA_DIST) && \
uv run ./scripts/version_manager.py unset-beta-build && \
:

########################################################################################################################
# Publishing
########################################################################################################################

.PHONY: publish
publish: build # Build and publish the package to PyPI
uv run twine upload --repository pypi $(DIST)/*

.PHONY: publish-test
publish-test: build-beta # Build and publish the package to Test PyPI
uv run twine upload --repository testpypi $(BETA_DIST)/*
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,30 @@ dev = [
'coverage',
'flake8',
'pytest',
'pytest-cov',
'pytest-django',
'setuptools',
'tox',
'tox-uv',
'twine',
]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "example_project.settings_test"
pythonpath = [".", "example_project"]
python_files = ["tests.py", "test_*.py", "*_test.py"]
testpaths = ["letsencrypt", "tests"]
addopts = "-v"

[tool.coverage.run]
source = ["letsencrypt"]
omit = [
"letsencrypt/migrations/*",
"letsencrypt/admin.py",
"letsencrypt/apps.py",
"letsencrypt/tests.py",
"letsencrypt/urls.py",
]

[tool.setuptools.packages.find]
include = ['letsencrypt*']
2 changes: 1 addition & 1 deletion scripts/local_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ popd

echo "${PREFIX} sleeping as server boots..." && sleep 2

uv run pytest -v ./tests/integration/
uv run pytest -v ./tests/integration/ --junitxml=junit-integration.xml

kill ${SERVER_PID}
echo "${PREFIX} killed server via PID ${SERVER_PID}"
Expand Down
Loading