diff --git a/.azure-pipelines/main.yml b/.azure-pipelines/main.yml index cae4f799c..d3c3a152e 100644 --- a/.azure-pipelines/main.yml +++ b/.azure-pipelines/main.yml @@ -1,8 +1,10 @@ -trigger: none +# We run the test suite on commits to master so codecov gets coverage data +# about the master branch and can use it to track coverage changes. +trigger: + - master pr: - master - '*.x' jobs: - template: templates/jobs/standard-tests-jobs.yml - diff --git a/.azure-pipelines/templates/jobs/standard-tests-jobs.yml b/.azure-pipelines/templates/jobs/standard-tests-jobs.yml index c49e22bc1..5d0044d19 100644 --- a/.azure-pipelines/templates/jobs/standard-tests-jobs.yml +++ b/.azure-pipelines/templates/jobs/standard-tests-jobs.yml @@ -7,10 +7,11 @@ jobs: macos-py37-cover: IMAGE_NAME: macOS-12 PYTHON_VERSION: 3.7 - TOXENV: py37-cover + TOXENV: cover macos-cover: IMAGE_NAME: macOS-12 - TOXENV: py3-cover + TOXENV: cover + UPLOAD_COVERAGE: 1 windows-py37: IMAGE_NAME: windows-2019 PYTHON_VERSION: 3.7 @@ -18,11 +19,13 @@ jobs: windows-py39-cover: IMAGE_NAME: windows-2019 PYTHON_VERSION: 3.9 - TOXENV: py39-cover-win + TOXENV: cover-win + UPLOAD_COVERAGE: 1 windows-integration-certbot: IMAGE_NAME: windows-2019 PYTHON_VERSION: 3.9 TOXENV: integration-certbot + UPLOAD_COVERAGE: 1 linux-oldest-tests-1: IMAGE_NAME: ubuntu-22.04 PYTHON_VERSION: 3.7 @@ -37,7 +40,8 @@ jobs: TOXENV: py37 linux-cover: IMAGE_NAME: ubuntu-22.04 - TOXENV: py3-cover + TOXENV: cover + UPLOAD_COVERAGE: 1 linux-lint: IMAGE_NAME: ubuntu-22.04 TOXENV: lint-posix @@ -49,6 +53,7 @@ jobs: PYTHON_VERSION: 3.8 TOXENV: integration ACME_SERVER: pebble + UPLOAD_COVERAGE: 1 apache-compat: IMAGE_NAME: ubuntu-22.04 TOXENV: apache_compat diff --git a/.azure-pipelines/templates/steps/tox-steps.yml b/.azure-pipelines/templates/steps/tox-steps.yml index fbda960a5..a85e1519a 100644 --- a/.azure-pipelines/templates/steps/tox-steps.yml +++ b/.azure-pipelines/templates/steps/tox-steps.yml @@ -55,3 +55,28 @@ steps: AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) AWS_EC2_PEM_FILE: $(testFarmPem.secureFilePath) displayName: Run tox + # For now, let's omit `set -e` and avoid the script exiting with a nonzero + # status code to prevent problems here from causing build failures. If + # this turns out to work well, we can change this. + - bash: | + python3 tools/pip_install.py -I coverage + case "$AGENT_OS" in + Darwin) + CODECOV_URL="https://uploader.codecov.io/latest/macos/codecov" + ;; + Linux) + CODECOV_URL="https://uploader.codecov.io/latest/linux/codecov" + ;; + Windows_NT) + CODECOV_URL="https://uploader.codecov.io/latest/windows/codecov.exe" + ;; + *) + echo "Unexpected OS" + exit 0 + esac + curl --retry 3 -o codecov "$CODECOV_URL" + chmod +x codecov + coverage xml + ./codecov || echo "Uploading coverage data failed" + condition: ne(variables['UPLOAD_COVERAGE'], '') + displayName: Upload coverage data diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 000000000..23d2fbbe9 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,7 @@ +# This disables all reporting from codecov. Let's just set it up to collect +# data for now and then we can play with the settings here. +comment: false +coverage: + status: + project: off + patch: off diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 2e4106314..000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Configuration for https://github.com/marketplace/stale - -# Number of days of inactivity before an Issue or Pull Request becomes stale -daysUntilStale: 365 - -# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. -# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. -# When changing this value, be sure to also update markComment below. -daysUntilClose: 30 - -# Ignore issues with an assignee (defaults to false) -exemptAssignees: true - -# Label to use when marking as stale -staleLabel: needs-update - -# Comment to post when marking as stale. Set to `false` to disable -markComment: > - We've made a lot of changes to Certbot since this issue was opened. If you - still have this issue with an up-to-date version of Certbot, can you please - add a comment letting us know? This helps us to better see what issues are - still affecting our users. If there is no activity in the next 30 days, this - issue will be automatically closed. - -# Comment to post when closing a stale Issue or Pull Request. -closeComment: > - This issue has been closed due to lack of activity, but if you think it - should be reopened, please open a new issue with a link to this one and we'll - take a look. - -# Limit the number of actions per hour, from 1-30. Default is 30 -limitPerRun: 1 - -# Don't mark pull requests as stale. -only: issues diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..010259922 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,42 @@ +name: Update Stale Issues +on: + schedule: + # Run at midnight every night + - cron: '24 1 * * *' +permissions: + issues: write +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v6 + with: + # REMOVEME: dry run to see if this works + debug-only: true + + # Idle number of days before marking issues stale + days-before-issue-stale: 365 + + # Idle number of days before closing stale issues + days-before-issue-close: 30 + + # Ignore issues with an assignee + exempt-all-issue-assignees: true + + # Label to use when marking as stale + stale-issue-label: needs-update + + stale-issue-message: > + We've made a lot of changes to Certbot since this issue was opened. If you + still have this issue with an up-to-date version of Certbot, can you please + add a comment letting us know? This helps us to better see what issues are + still affecting our users. If there is no activity in the next 30 days, this + issue will be automatically closed. + + close-issue-message: > + This issue has been closed due to lack of activity, but if you think it + should be reopened, please open a new issue with a link to this one and we'll + take a look. + + # Limit the number of actions per hour, from 1-30. Default is 30 + operations-per-run: 1 diff --git a/acme/acme/messages.py b/acme/acme/messages.py index 0e02a054e..c1af1991a 100644 --- a/acme/acme/messages.py +++ b/acme/acme/messages.py @@ -123,6 +123,9 @@ class Error(jose.JSONObjectWithFields, errors.Error): https://datatracker.ietf.org/doc/html/rfc7807 + Note: Although Error inherits from JSONObjectWithFields, which is immutable, + we add mutability for Error to comply with the Python exception API. + :ivar str typ: :ivar str title: :ivar str detail: @@ -185,6 +188,10 @@ class Error(jose.JSONObjectWithFields, errors.Error): return code return None + # Hack to allow mutability on Errors (see GH #9539) + def __setattr__(self, name: str, value: Any) -> None: + return object.__setattr__(self, name, value) + def __str__(self) -> str: result = b' :: '.join( part.encode('ascii', 'backslashreplace') for part in diff --git a/acme/tests/messages_test.py b/acme/tests/messages_test.py index cbff65771..405e801a2 100644 --- a/acme/tests/messages_test.py +++ b/acme/tests/messages_test.py @@ -1,6 +1,7 @@ """Tests for acme.messages.""" from typing import Dict import unittest +import contextlib from unittest import mock import warnings @@ -91,6 +92,19 @@ class ErrorTest(unittest.TestCase): u"Problem for {1.identifier.value}: {1.typ} :: {1.description} :: {1.detail} :: {1.title}").format( self.error_with_subproblems, self.subproblem)) + # this test is based on a minimal reproduction of a contextmanager/immutable + # exception related error: https://github.com/python/cpython/issues/99856 + def test_setting_traceback(self): + self.assertIsNone(self.error_custom.__traceback__) + + try: + 1/0 + except ZeroDivisionError as e: + self.error_custom.__traceback__ = e.__traceback__ + + self.assertIsNotNone(self.error_custom.__traceback__) + + class ConstantTest(unittest.TestCase): """Tests for acme.messages._Constant.""" diff --git a/certbot/CHANGELOG.md b/certbot/CHANGELOG.md index cc7e5e78f..b2762eb11 100644 --- a/certbot/CHANGELOG.md +++ b/certbot/CHANGELOG.md @@ -18,6 +18,7 @@ Certbot adheres to [Semantic Versioning](https://semver.org/). ### Fixed * Fixed a crash when registering an account with BuyPass' ACME server. +* Fixed a bug where Certbot would crash with `AttributeError: can't set attribute` on ACME server errors in Python 3.11. See [GH #9539](https://github.com/certbot/certbot/issues/9539). More details about these changes can be found on our GitHub repo. diff --git a/certbot/docs/contributing.rst b/certbot/docs/contributing.rst index 6d1faf061..49cc1fc81 100644 --- a/certbot/docs/contributing.rst +++ b/certbot/docs/contributing.rst @@ -130,7 +130,7 @@ For debugging, we recommend putting Once you are done with your code changes, and the tests in ``foo_test.py`` pass, run all of the unit tests for Certbot and check for coverage with ``tox --e py3-cover``. You should then check for code style with ``tox -e lint`` (all +-e cover``. You should then check for code style with ``tox -e lint`` (all files) or ``pylint --rcfile=.pylintrc path/to/file.py`` (single file at a time). diff --git a/tests/lock_test.py b/tests/lock_test.py index a1e706c2f..09e11b25f 100644 --- a/tests/lock_test.py +++ b/tests/lock_test.py @@ -134,7 +134,7 @@ def set_up_command(config_dir: str, logs_dir: str, work_dir: str, nginx_dir: str return ( 'certbot --cert-path {0} --key-path {1} --config-dir {2} ' '--logs-dir {3} --work-dir {4} --nginx-server-root {5} --debug ' - '--force-renewal --nginx -vv '.format( + '--force-renewal --nginx -vv --no-random-sleep-on-renew '.format( test_util.vector_path('cert.pem'), test_util.vector_path('rsa512_key.pem'), config_dir, logs_dir, work_dir, nginx_dir).split()) diff --git a/tox.ini b/tox.ini index a3436e95a..2bdd5e25c 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ [tox] skipsdist = true -envlist = {py3-cover,lint,mypy}-{win,posix} +envlist = {cover,lint,mypy}-{win,posix} [base] # pip installs the requested packages in editable mode