diff --git a/.circleci/config.templ.yml b/.circleci/config.templ.yml index ac9596d43c8..e30100afe51 100644 --- a/.circleci/config.templ.yml +++ b/.circleci/config.templ.yml @@ -83,7 +83,7 @@ commands: setup_hatch: description: "Install hatch" steps: - - run: pip3 install hatch==1.7.0 hatch-containers==0.7.0 + - run: pip3 install hatch~=1.8.0 hatch-containers==0.7.0 start_docker_services: description: "Start Docker services" diff --git a/.readthedocs.yml b/.readthedocs.yml index 07428a64eba..caaa8a600eb 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -5,6 +5,6 @@ build: python: "3.10" commands: - git fetch --unshallow || true - - pip install hatch==1.7.0 hatch-containers==0.7.0 + - pip install hatch~=1.8.0 hatch-containers==0.7.0 - hatch -v run docs:sphinx-build -W -b html docs docs/_build/html - mv docs/_build $READTHEDOCS_OUTPUT diff --git a/docker/Dockerfile b/docker/Dockerfile index 3ac3f94c81e..a278ae8b884 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,6 +3,9 @@ # have to be built from source all the time (grpcio takes forever to install) FROM debian:buster-20221219-slim +ARG TARGETARCH +ARG HATCH_VERSION=1.8.1 + # http://bugs.python.org/issue19846 # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. ENV LANG C.UTF-8 @@ -71,4 +74,12 @@ RUN git clone --depth 1 --branch v2.3.33 https://github.com/pyenv/pyenv "${PYENV && pyenv local | xargs -L 1 pyenv install \ && cd - +RUN if [ "$TARGETARCH" = "amd64" ]; \ + then curl -L https://github.com/pypa/hatch/releases/download/hatch-v${HATCH_VERSION} hatch-${HATCH_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar zx; \ + else curl -L https://github.com/pypa/hatch/releases/download/hatch-v${HATCH_VERSION}/hatch-${HATCH_VERSION}-aarch64-unknown-linux-gnu.tar.gz | tar zx; \ + fi \ + && mv hatch-${HATCH_VERSION}-* hatch \ + && install -t /usr/local/bin hatch \ + && hatch -q + CMD ["/bin/bash"] diff --git a/docs/contributing-testing.rst b/docs/contributing-testing.rst index 0b96b651e15..d6bf0c72abe 100644 --- a/docs/contributing-testing.rst +++ b/docs/contributing-testing.rst @@ -36,7 +36,7 @@ In addition, you will need `riot `_ an .. code-block:: bash $ pip install riot==0.19.0 - $ pip install hatch==1.7.0 + $ pip install hatch~=1.8.0 hatch-containers==0.7.0 Some of our test environments are managed with Riot, others with Hatch. diff --git a/hatch.toml b/hatch.toml index 3e071a8d296..bc9841af448 100644 --- a/hatch.toml +++ b/hatch.toml @@ -1,3 +1,8 @@ +[env] +requires = [ + "hatch-containers==0.7.0", +] + [envs.lint] detached = true python = "3.10" diff --git a/scripts/ddtest b/scripts/ddtest index 7b44295f949..8759e2af054 100755 --- a/scripts/ddtest +++ b/scripts/ddtest @@ -12,7 +12,7 @@ fi # retry docker pull if fails for i in {1..3}; do docker-compose pull -q testrunner && break || sleep 3; done -FULL_CMD="pip install -q --disable-pip-version-check riot==0.19.0 hatch==1.7.0 && $CMD" +FULL_CMD="pip install -q --disable-pip-version-check riot==0.19.0 && $CMD" # install and upgrade riot in case testrunner image has not been updated diff --git a/scripts/gen_circleci_config.py b/scripts/gen_circleci_config.py index f8d46844d35..071e4633589 100644 --- a/scripts/gen_circleci_config.py +++ b/scripts/gen_circleci_config.py @@ -49,37 +49,37 @@ def check(name: str, command: str, paths: t.Set[str]) -> None: check( name="Style", command="hatch run lint:style", - paths={"*.py", "*.pyi", "hatch.toml", "pyproject.toml"}, + paths={"docker", "*.py", "*.pyi", "hatch.toml", "pyproject.toml"}, ) check( name="Typing", command="hatch run lint:typing", - paths={"*.py", "*.pyi", "hatch.toml"}, + paths={"docker", "*.py", "*.pyi", "hatch.toml"}, ) check( name="Security", command="hatch run lint:security", - paths={"ddtrace/*", "hatch.toml"}, + paths={"docker", "ddtrace/*", "hatch.toml"}, ) check( name="Run riotfile.py tests", command="hatch run lint:riot", - paths={"riotfile.py", "hatch.toml"}, + paths={"docker", "riotfile.py", "hatch.toml"}, ) check( name="Style: Test snapshots", command="hatch run lint:fmt-snapshots && git diff --exit-code tests/snapshots hatch.toml", - paths={"tests/snapshots/*", "hatch.toml"}, + paths={"docker", "tests/snapshots/*", "hatch.toml"}, ) check( name="Run scripts/*.py tests", command="hatch run scripts:test", - paths={"scripts/*.py", "scripts/mkwheelhouse", "scripts/run-test-suite", "tests/.suitespec.json"}, + paths={"docker", "scripts/*.py", "scripts/mkwheelhouse", "scripts/run-test-suite", "tests/.suitespec.json"}, ) check( name="Validate suitespec JSON file", command="python -m tests.suitespec", - paths={"tests/.suitespec.json", "tests/suitespec.py"}, + paths={"docker", "tests/.suitespec.json", "tests/suitespec.py"}, ) @@ -87,7 +87,7 @@ def gen_build_docs(template: dict) -> None: """Include the docs build step if the docs have changed.""" from needs_testrun import pr_matches_patterns - if pr_matches_patterns({"docs/*", "ddtrace/*", "scripts/docs", "releasenotes/*"}): + if pr_matches_patterns({"docker", "docs/*", "ddtrace/*", "scripts/docs", "releasenotes/*"}): template["workflows"]["test"]["jobs"].append({"build_docs": template["requires_pre_check"]}) @@ -95,7 +95,7 @@ def gen_slotscheck(template: dict) -> None: """Include the slotscheck if the Python source has changed.""" from needs_testrun import pr_matches_patterns - if pr_matches_patterns({"ddtrace/*.py", "hatch.toml"}): + if pr_matches_patterns({"docker", "ddtrace/*.py", "hatch.toml"}): template["workflows"]["test"]["jobs"].append({"slotscheck": template["requires_pre_check"]}) @@ -103,7 +103,7 @@ def gen_conftests(template: dict) -> None: """Include the conftests if the Python conftest or tests/meta has changed.""" from needs_testrun import pr_matches_patterns - if pr_matches_patterns({"tests/*conftest.py", "tests/meta/*"}): + if pr_matches_patterns({"docker", "tests/*conftest.py", "tests/meta/*"}): template["workflows"]["test"]["jobs"].append({"conftests": template["requires_pre_check"]}) @@ -111,7 +111,7 @@ def gen_c_check(template: dict) -> None: """Include C code checks if C code has changed.""" from needs_testrun import pr_matches_patterns - if pr_matches_patterns({"*.c", "*.h", "*.cpp", "*.hpp", "*.cc", "*.hh"}): + if pr_matches_patterns({"docker", "*.c", "*.h", "*.cpp", "*.hpp", "*.cc", "*.hh"}): template["requires_pre_check"]["requires"].append("ccheck") template["requires_base_venvs"]["requires"].append("ccheck") template["workflows"]["test"]["jobs"].append("ccheck") diff --git a/tests/.suitespec.json b/tests/.suitespec.json index 287c4569d71..6ac5bb9f991 100644 --- a/tests/.suitespec.json +++ b/tests/.suitespec.json @@ -6,6 +6,7 @@ "pyproject.toml" ], "$harness": [ + "docker/*", "riotfile.py", "scripts/ddtest", "scripts/run-test-suite", diff --git a/tests/suitespec.py b/tests/suitespec.py index b0f6e531a43..b9add305c12 100644 --- a/tests/suitespec.py +++ b/tests/suitespec.py @@ -19,9 +19,9 @@ def get_patterns(suite: str) -> t.Set[str]: 'ddtrace/provider.py', 'ddtrace/py.typed', 'ddtrace/sampler.py', 'ddtrace/settings/__init__.py', 'ddtrace/settings/config.py', 'ddtrace/settings/dynamic_instrumentation.py', 'ddtrace/settings/exception_debugging.py', 'ddtrace/settings/http.py', 'ddtrace/settings/integration.py', - 'ddtrace/span.py', 'ddtrace/tracer.py', 'ddtrace/tracing/*', 'ddtrace/version.py', 'hatch.toml', 'pyproject.toml', - 'riotfile.py', 'scripts/ddtest', 'scripts/run-test-suite', 'setup.cfg', 'setup.py', 'tests/.suitespec.json', - 'tests/__init__.py', 'tests/conftest.py', 'tests/debugging/*'] + 'ddtrace/span.py', 'ddtrace/tracer.py', 'ddtrace/tracing/*', 'ddtrace/version.py', 'docker/*', 'hatch.toml', + 'pyproject.toml', 'riotfile.py', 'scripts/ddtest', 'scripts/run-test-suite', 'setup.cfg', 'setup.py', + 'tests/.suitespec.json', 'tests/__init__.py', 'tests/conftest.py', 'tests/debugging/*'] >>> get_patterns("foobar") set() >>> sorted(get_patterns("urllib3")) # doctest: +NORMALIZE_WHITESPACE @@ -34,10 +34,10 @@ def get_patterns(suite: str) -> t.Set[str]: 'ddtrace/propagation/*', 'ddtrace/provider.py', 'ddtrace/py.typed', 'ddtrace/sampler.py', 'ddtrace/settings/__init__.py', 'ddtrace/settings/_database_monitoring.py', 'ddtrace/settings/config.py', 'ddtrace/settings/http.py', 'ddtrace/settings/integration.py', 'ddtrace/span.py', 'ddtrace/tracer.py', - 'ddtrace/tracing/*', 'ddtrace/version.py', 'hatch.toml', 'pyproject.toml', 'riotfile.py', 'scripts/ddtest', - 'scripts/run-test-suite', 'setup.cfg', 'setup.py', 'tests/.suitespec.json', 'tests/__init__.py', - 'tests/conftest.py', 'tests/contrib/__init__.py', 'tests/contrib/patch.py', 'tests/contrib/urllib3/*', - 'tests/snapshots/tests.contrib.urllib3.*'] + 'ddtrace/tracing/*', 'ddtrace/version.py', 'docker/*', 'hatch.toml', 'pyproject.toml', 'riotfile.py', + 'scripts/ddtest', 'scripts/run-test-suite', 'setup.cfg', 'setup.py', 'tests/.suitespec.json', + 'tests/__init__.py', 'tests/conftest.py', 'tests/contrib/__init__.py', 'tests/contrib/patch.py', + 'tests/contrib/urllib3/*', 'tests/snapshots/tests.contrib.urllib3.*'] """ compos = SUITESPEC["components"] if suite not in SUITESPEC["suites"]: