Skip to content

Commit

Permalink
ci: update hatch to v1.8.0 (#7888)
Browse files Browse the repository at this point in the history
This updates hatch to the latest version and installs it using the
standalone binary installation method as part of the `testrunner` Docker
image.

The changes to the `testrunner` image are verified with
e256f3a
in
https://github.com/DataDog/dd-trace-py/actions/runs/7176116304/job/19540500500.
 
## Checklist

- [x] Change(s) are motivated and described in the PR description.
- [x] Testing strategy is described if automated tests are not included
in the PR.
- [x] Risk is outlined (performance impact, potential for breakage,
maintainability, etc).
- [x] Change is maintainable (easy to change, telemetry, documentation).
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed. If no release note is required, add label
`changelog/no-changelog`.
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/)).
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist

- [ ] Title is accurate.
- [ ] No unnecessary changes are introduced.
- [ ] Description motivates each change.
- [ ] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes unless absolutely necessary.
- [ ] Testing strategy adequately addresses listed risk(s).
- [ ] Change is maintainable (easy to change, telemetry, documentation).
- [ ] Release note makes sense to a user of the library.
- [ ] Reviewer has explicitly acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment.
- [ ] Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
- [ ] If this PR touches code that signs or publishes builds or
packages, or handles credentials of any kind, I've requested a review
from `@DataDog/security-design-and-guidance`.
- [ ] This PR doesn't touch any of that.
  • Loading branch information
majorgreys authored Dec 19, 2023
1 parent 5c34942 commit 0e9ae0d
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.templ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion docs/contributing-testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In addition, you will need `riot <https://ddriot.readthedocs.io/en/latest/>`_ 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.

Expand Down
5 changes: 5 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[env]
requires = [
"hatch-containers==0.7.0",
]

[envs.lint]
detached = true
python = "3.10"
Expand Down
2 changes: 1 addition & 1 deletion scripts/ddtest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions scripts/gen_circleci_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,69 +49,69 @@ 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"},
)


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"]})


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"]})


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"]})


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")
Expand Down
1 change: 1 addition & 0 deletions tests/.suitespec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"pyproject.toml"
],
"$harness": [
"docker/*",
"riotfile.py",
"scripts/ddtest",
"scripts/run-test-suite",
Expand Down
14 changes: 7 additions & 7 deletions tests/suitespec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]:
Expand Down

0 comments on commit 0e9ae0d

Please sign in to comment.