|
36 | 36 | timeout-minutes:10 |
37 | 37 | outputs: |
38 | 38 | run_tests:${{ steps.check.outputs.run_tests }} |
| 39 | +run_hypothesis:${{ steps.check.outputs.run_hypothesis }} |
39 | 40 | steps: |
40 | 41 | -uses:actions/checkout@v3 |
41 | 42 | -name:Check for source changes |
|
61 | 62 | git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo "run_tests=true" >> $GITHUB_OUTPUT ||true |
62 | 63 | fi |
63 | 64 |
|
| 65 | + # Check if we should run hypothesis tests |
| 66 | + GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}} |
| 67 | + echo $GIT_BRANCH |
| 68 | + if $(echo "$GIT_BRANCH" | grep -q -w '3\.\(8\|9\|10\|11\)'); then |
| 69 | + echo "Branch too old for hypothesis tests" |
| 70 | + echo "run_hypothesis=false" >> $GITHUB_OUTPUT |
| 71 | + else |
| 72 | + echo "Run hypothesis tests" |
| 73 | + echo "run_hypothesis=true" >> $GITHUB_OUTPUT |
| 74 | + fi |
| 75 | +
|
64 | 76 | check_generated_files: |
65 | 77 | name:'Check if generated files are up to date' |
66 | 78 | runs-on:ubuntu-latest |
@@ -291,6 +303,92 @@ jobs: |
291 | 303 | -name:SSL tests |
292 | 304 | run:./python Lib/test/ssltests.py |
293 | 305 |
|
| 306 | +test_hypothesis: |
| 307 | +name:"Hypothesis Tests on Ubuntu" |
| 308 | +runs-on:ubuntu-20.04 |
| 309 | +timeout-minutes:60 |
| 310 | +needs:check_source |
| 311 | +if:needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true' |
| 312 | +env: |
| 313 | +OPENSSL_VER:1.1.1t |
| 314 | +PYTHONSTRICTEXTENSIONBUILD:1 |
| 315 | +steps: |
| 316 | + -uses:actions/checkout@v3 |
| 317 | + -name:Register gcc problem matcher |
| 318 | +run:echo "::add-matcher::.github/problem-matchers/gcc.json" |
| 319 | + -name:Install Dependencies |
| 320 | +run:sudo ./.github/workflows/posix-deps-apt.sh |
| 321 | + -name:Configure OpenSSL env vars |
| 322 | +run:| |
| 323 | + echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV |
| 324 | + echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> $GITHUB_ENV |
| 325 | + echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV |
| 326 | + -name:'Restore OpenSSL build' |
| 327 | +id:cache-openssl |
| 328 | +uses:actions/cache@v3 |
| 329 | +with: |
| 330 | +path:./multissl/openssl/${{ env.OPENSSL_VER }} |
| 331 | +key:${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} |
| 332 | + -name:Install OpenSSL |
| 333 | +if:steps.cache-openssl.outputs.cache-hit != 'true' |
| 334 | +run:python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux |
| 335 | + -name:Add ccache to PATH |
| 336 | +run:| |
| 337 | + echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV |
| 338 | + -name:Configure ccache action |
| 339 | +uses:hendrikmuhs/ccache-action@v1.2 |
| 340 | + -name:Setup directory envs for out-of-tree builds |
| 341 | +run:| |
| 342 | + echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV |
| 343 | + echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV |
| 344 | + -name:Create directories for read-only out-of-tree builds |
| 345 | +run:mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR |
| 346 | + -name:Bind mount sources read-only |
| 347 | +run:sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR |
| 348 | + -name:Configure CPython out-of-tree |
| 349 | +working-directory:${{ env.CPYTHON_BUILDDIR }} |
| 350 | +run:../cpython-ro-srcdir/configure --with-pydebug --with-openssl=$OPENSSL_DIR |
| 351 | + -name:Build CPython out-of-tree |
| 352 | +working-directory:${{ env.CPYTHON_BUILDDIR }} |
| 353 | +run:make -j4 |
| 354 | + -name:Display build info |
| 355 | +working-directory:${{ env.CPYTHON_BUILDDIR }} |
| 356 | +run:make pythoninfo |
| 357 | + -name:Remount sources writable for tests |
| 358 | +# some tests write to srcdir, lack of pyc files slows down testing |
| 359 | +run:sudo mount $CPYTHON_RO_SRCDIR -oremount,rw |
| 360 | + -name:Setup directory envs for out-of-tree builds |
| 361 | +run:| |
| 362 | + echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV |
| 363 | + -name:"Create hypothesis venv" |
| 364 | +working-directory:${{ env.CPYTHON_BUILDDIR }} |
| 365 | +run:| |
| 366 | + VENV_LOC=$(realpath -m .)/hypovenv |
| 367 | + VENV_PYTHON=$VENV_LOC/bin/python |
| 368 | + echo "HYPOVENV=${VENV_LOC}" >> $GITHUB_ENV |
| 369 | + echo "VENV_PYTHON=${VENV_PYTHON}" >> $GITHUB_ENV |
| 370 | + ./python -m venv $VENV_LOC && $VENV_PYTHON -m pip install -U hypothesis |
| 371 | + -name:"Run tests" |
| 372 | +working-directory:${{ env.CPYTHON_BUILDDIR }} |
| 373 | +run:| |
| 374 | + # Most of the excluded tests are slow test suites with no property tests |
| 375 | + # |
| 376 | + # (GH-104097) test_sysconfig is skipped because it has tests that are |
| 377 | + # failing when executed from inside a virtual environment. |
| 378 | + ${{ env.VENV_PYTHON }} -m test \ |
| 379 | + -W \ |
| 380 | + -o \ |
| 381 | + -j4 \ |
| 382 | + -x test_asyncio \ |
| 383 | + -x test_multiprocessing_fork \ |
| 384 | + -x test_multiprocessing_forkserver \ |
| 385 | + -x test_multiprocessing_spawn \ |
| 386 | + -x test_concurrent_futures \ |
| 387 | + -x test_socket \ |
| 388 | + -x test_subprocess \ |
| 389 | + -x test_signal \ |
| 390 | + -x test_sysconfig |
| 391 | +
|
294 | 392 |
|
295 | 393 | build_asan: |
296 | 394 | name:'Address sanitizer' |
|