From 4d28d203ff03dc4a4994ad223e769d2460f83a57 Mon Sep 17 00:00:00 2001 From: Alberto Contreras Date: Mon, 8 May 2023 23:17:17 +0200 Subject: ci: add hypothesis scheduled GH check (#2149) --- .github/workflows/scheduled.yml | 32 ++++++++++++++++++++++++++++++++ tests/unittests/conftest.py | 8 ++++++++ tox.ini | 1 + 3 files changed, 41 insertions(+) create mode 100644 .github/workflows/scheduled.yml diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml new file mode 100644 index 00000000..ac4af1e7 --- /dev/null +++ b/.github/workflows/scheduled.yml @@ -0,0 +1,32 @@ +name: scheduled +on: + schedule: + - cron: '3 14 * * *' +concurrency: + group: 'ci-${{ github.workflow }}-${{ github.ref }}' + cancel-in-progress: true + +jobs: + unittests: + strategy: + matrix: + toxenv: [ hypothesis-slow ] + name: unittest / ${{ matrix.toxenv }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # Fetch all tags for tools/read-version + fetch-depth: 0 + - name: Install dependencies + env: + DEBIAN_FRONTEND: noninteractive + run: | + sudo apt-get -qy update + sudo apt-get -qy install tox + - name: Run fuzztest + env: + PYTEST_ADDOPTS: -v + HYPOTHESIS_PROFILE: ci + run: tox -e ${{ matrix.toxenv }} diff --git a/tests/unittests/conftest.py b/tests/unittests/conftest.py index a3daaf22..0cfa810e 100644 --- a/tests/unittests/conftest.py +++ b/tests/unittests/conftest.py @@ -7,6 +7,7 @@ from unittest import mock import pytest from cloudinit import atomic_helper, util +from tests.hypothesis import HAS_HYPOTHESIS from tests.unittests.helpers import retarget_many_wrapper FS_FUNCS = { @@ -81,3 +82,10 @@ if PYTEST_VERSION_TUPLE < (3, 9, 0): @pytest.fixture def tmp_path(tmpdir): return Path(tmpdir) + + +if HAS_HYPOTHESIS: + from hypothesis import settings # pylint: disable=import-error + + settings.register_profile("ci", max_examples=1000) + settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default")) diff --git a/tox.ini b/tox.ini index d6c44b84..626543a5 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ setenv = LC_ALL = en_US.utf-8 passenv= PYTEST_ADDOPTS + HYPOTHESIS_PROFILE [format_deps] black==22.3.0 -- cgit v1.2.1