Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-110109-simplify-test-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale authored Oct 10, 2023
2 parents eb0298c + 732532b commit ab5057a
Show file tree
Hide file tree
Showing 178 changed files with 4,632 additions and 847 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ indent_style = space
[*.{py,c,cpp,h}]
indent_size = 4

[*.rst]
indent_size = 3

[*.yml]
indent_size = 2
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
run_tests: ${{ steps.check.outputs.run_tests }}
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
run_cifuzz: ${{ steps.check.outputs.run_cifuzz }}
config_hash: ${{ steps.config_hash.outputs.hash }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -76,6 +77,21 @@ jobs:
echo "Run hypothesis tests"
echo "run_hypothesis=true" >> $GITHUB_OUTPUT
fi
# oss-fuzz maintains a configuration for fuzzing the main branch of
# CPython, so CIFuzz should be run only for code that is likely to be
# merged into the main branch; compatibility with older branches may
# be broken.
FUZZ_RELEVANT_FILES='(\.c$|\.h$|\.cpp$|^configure$|^\.github/workflows/build\.yml$|^Modules/_xxtestfuzz)'
if [ "$GITHUB_BASE_REF" = "main" ] && [ "$(git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE $FUZZ_RELEVANT_FILES; echo $?)" -eq 0 ]; then
# The tests are pretty slow so they are executed only for PRs
# changing relevant files.
echo "Run CIFuzz tests"
echo "run_cifuzz=true" >> $GITHUB_OUTPUT
else
echo "Branch too old for CIFuzz tests; or no C files were changed"
echo "run_cifuzz=false" >> $GITHUB_OUTPUT
fi
- name: Compute hash for config cache key
id: config_hash
run: |
Expand Down Expand Up @@ -534,6 +550,46 @@ jobs:
- name: Tests
run: xvfb-run make test

# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
cifuzz:
name: CIFuzz
runs-on: ubuntu-latest
timeout-minutes: 60
needs: check_source
if: needs.check_source.outputs.run_cifuzz == 'true'
permissions:
security-events: write
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined, memory]
steps:
- name: Build fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: cpython3
sanitizer: ${{ matrix.sanitizer }}
- name: Run fuzzers (${{ matrix.sanitizer }})
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
fuzz-seconds: 600
oss-fuzz-project-name: cpython3
output-sarif: true
sanitizer: ${{ matrix.sanitizer }}
- name: Upload crash
uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-artifacts
path: ./out/artifacts
- name: Upload SARIF
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif

all-required-green: # This job does nothing and is only used for the branch protection
name: All required checks pass
if: always()
Expand All @@ -550,6 +606,7 @@ jobs:
- build_ubuntu_ssltests
- test_hypothesis
- build_asan
- cifuzz

runs-on: ubuntu-latest

Expand All @@ -562,6 +619,7 @@ jobs:
build_ubuntu_ssltests,
build_win32,
build_win_arm64,
cifuzz,
test_hypothesis,
allowed-skips: >-
${{
Expand All @@ -585,6 +643,13 @@ jobs:
'
|| ''
}}
${{
!fromJSON(needs.check_source.outputs.run_cifuzz)
&& '
cifuzz,
'
|| ''
}}
${{
!fromJSON(needs.check_source.outputs.run_hypothesis)
&& '
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:

env:
FORCE_COLOR: 1
RUFF_FORMAT: github
RUFF_OUTPUT_FORMAT: github

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
36 changes: 35 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ repos:
name: Run Ruff on Lib/test/
args: [--exit-non-zero-on-fix]
files: ^Lib/test/
- id: ruff
name: Run Ruff on Argument Clinic
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
files: ^Tools/clinic/|Lib/test/test_clinic.py

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -17,7 +21,31 @@ repos:
types: [python]
exclude: Lib/test/tokenizedata/coding20731.py
- id: trailing-whitespace
types_or: [c, python, rst]
types_or: [c, inc, python, rst]

- repo: local
hooks:
- id: python-file-whitespace
name: "Check Python file whitespace"
entry: 'python Tools/patchcheck/reindent.py --nobackup --newline LF'
language: 'system'
types: [python]
exclude: '^(Lib/test/tokenizedata/|Tools/c-analyzer/cpython/_parser).*$'

- repo: local
hooks:
- id: c-file-whitespace
name: "Check C file whitespace"
entry: "python Tools/patchcheck/untabify.py"
language: "system"
types_or: ['c', 'c++']
# Don't check the style of vendored libraries
exclude: |
(?x)^(
Modules/_decimal/.*
| Modules/libmpdec/.*
| Modules/expat/.*
)$
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v0.6.8
Expand All @@ -26,3 +54,9 @@ repos:
args: [--enable=default-role]
files: ^Doc/|^Misc/NEWS.d/next/
types: [rst]
require_serial: true

- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
1 change: 0 additions & 1 deletion Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
PYTHON = python3
VENVDIR = ./venv
SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
SPHINXLINT = PATH=$(VENVDIR)/bin:$$PATH sphinx-lint
BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
JOBS = auto
PAPER =
Expand Down
13 changes: 13 additions & 0 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,19 @@ PyConfig
.. versionadded:: 3.12
.. c:member:: int cpu_count
If the value of :c:member:`~PyConfig.cpu_count` is not ``-1`` then it will
override the return values of :func:`os.cpu_count`,
:func:`os.process_cpu_count`, and :func:`multiprocessing.cpu_count`.
Configured by the :samp:`-X cpu_count={n|default}` command line
flag or the :envvar:`PYTHON_CPU_COUNT` environment variable.
Default: ``-1``.
.. versionadded:: 3.13
.. c:member:: int isolated
If greater than ``0``, enable isolated mode:
Expand Down
21 changes: 17 additions & 4 deletions Doc/c-api/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,24 @@ accessible to C code. They all work with the current interpreter thread's
Raise an auditing event with any active hooks. Return zero for success
and non-zero with an exception set on failure.
The *event* string argument must not be *NULL*.
If any hooks have been added, *format* and other arguments will be used
to construct a tuple to pass. Apart from ``N``, the same format characters
as used in :c:func:`Py_BuildValue` are available. If the built value is not
a tuple, it will be added into a single-element tuple. (The ``N`` format
option consumes a reference, but since there is no way to know whether
arguments to this function will be consumed, using it may cause reference
leaks.)
a tuple, it will be added into a single-element tuple.
The ``N`` format option must not be used. It consumes a reference, but since
there is no way to know whether arguments to this function will be consumed,
using it may cause reference leaks.
Note that ``#`` format characters should always be treated as
:c:type:`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined.
:func:`sys.audit` performs the same function from Python code.
See also :c:func:`PySys_AuditTuple`.
.. versionadded:: 3.8
.. versionchanged:: 3.8.2
Expand All @@ -312,6 +317,14 @@ accessible to C code. They all work with the current interpreter thread's
unavoidable deprecation warning was raised.
.. c:function:: int PySys_AuditTuple(const char *event, PyObject *args)
Similar to :c:func:`PySys_Audit`, but pass arguments as a Python object.
*args* must be a :class:`tuple`. To pass no arguments, *args* can be *NULL*.
.. versionadded:: 3.13
.. c:function:: int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
Append the callable *hook* to the list of active auditing hooks.
Expand Down
1 change: 1 addition & 0 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Doc/howto/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Currently, the HOWTOs are:
perf_profiling.rst
annotations.rst
isolating-extensions.rst
timerfd.rst

3 changes: 1 addition & 2 deletions Doc/howto/perf_profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ the :option:`!-X` option takes precedence over the environment variable.

Example, using the environment variable::

$ PYTHONPERFSUPPORT=1
$ python script.py
$ PYTHONPERFSUPPORT=1 python script.py
$ perf report -g -i perf.data

Example, using the :option:`!-X` option::
Expand Down
Loading

0 comments on commit ab5057a

Please sign in to comment.