Skip to main content

Test caching plugin for pytest

Project description

DryCI - Test caching system

This pytest plugin speeds up test runs by caching test results. It calculates a hash of the contents of all files that might affect the test results, and looks up the result in a central server.

This repository contains both the pytest plugin and a reference server.

This solution is a lightweight alternative to the test-caching part of heavy hermetic build systems like Bazel or Buck. It is designed to be easy to set up and use, and to work with existing projects without requiring full-time engineers to manage it.

User documentation, a public cache server, a hermeticity verifier, and more language support might come in the future.

How to use

  1. Add the pytest-dryci package to your dev-dependencies.
  2. Configure repo_dagger.yaml, see example_project for inspiration.
  3. Obtain a DryCI token for a DryCI server. The public instance is currently in closed beta, but you may deploy your own.
  4. Run DRYCI_TOKEN=$your_token_here pytest --dryci ./tests.

You may also specify DRYCI_SERVER to use a custom server, DRYCI_SALT to do cache-busting, and DRYCI_TIMEOUT to control http timeouts.

How it works

The plugin runs repo_dagger to analyze the runtime dependencies of all files that might affect the test results. To do this effectively, you will need to configure rules that define dependencies between files in repo_dagger.yaml. See example_config.toml for an example config.

A dependency graph between project files

Then, for each file in the test suite, it traverses the dependency graph and hashes each file. The hash of all these files is known as the "dependency hash" of the test file. The hash also includes some info about the system, such as the operating system, distro, architecture, and the contents of the DRYCI_SALT environment variable.

A hash function hashing the dependencies from the graph above

It then queries the server for the list of passed tests for each dependency hash, and skips any tests it returns. Test identifiers (pytest nodeids) are salted and hashed for privacy.

Note that failed tests are never cached, so flaky tests get a chance to run again. Skipped tests are also not cached, but that might change in the future.

A computer queries the server what tests need to run, and which should be skipped

After running the test suite, we upload the (hashed) identifier of each test that passed, so future runs can skip them.

A computer uploads hashes of passed tests to the server

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytest_dryci-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl (2.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64musllinux: musl 1.1+ x86-64

pytest_dryci-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl (2.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64musllinux: musl 1.1+ ARM64

pytest_dryci-0.1.0-py3-none-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

pytest_dryci-0.1.0-py3-none-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file pytest_dryci-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pytest_dryci-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 229fc077033a74aac14eedeb542e0d22f5fcfe7eeae2c804151cf3cbdb18196c
MD5 fe36d647718bc0941db1103d554d2e98
BLAKE2b-256 ff1105c2b50e6930ea26649ef830d165925336df86098df72dd3c74831b63b38

See more details on using hashes here.

File details

Details for the file pytest_dryci-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for pytest_dryci-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 0969ef1a6c78bd4f3d19187ffde133fa699de45bc2d3d43e6be2bc51173d764a
MD5 78a071bca2788bfc4986fa3b253214ab
BLAKE2b-256 867420dac848fd939964c8999584538d5bac706f6e9181816b8c4769f8ddeb5d

See more details on using hashes here.

File details

Details for the file pytest_dryci-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytest_dryci-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 416d1e13c00e9cba8ab23f5cdd1a4c4dd88e77af47b4540f8104502b06ec655e
MD5 d965f3c66310472b5ecb6bd4cef70817
BLAKE2b-256 96f500559cd41b8d2f743a93132f06f5eeb4a353c0f470ea759a5a13bc595e93

See more details on using hashes here.

File details

Details for the file pytest_dryci-0.1.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pytest_dryci-0.1.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4385426e0211dc9139a8e42db8f92e7ee3aee1008ddd297038ca45897f282446
MD5 b240d67d6255e2187e6622a4575bdca8
BLAKE2b-256 5ea82681f6a48334ba93c7bd1c03676a07dd7abe9ff1f2f3ea814d5904fe401d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page