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.1-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.1-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.1-py3-none-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

pytest_dryci-0.1.1-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.1-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.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ac7882944922ae336c9051d4dab4ec4ee1bfc4a86267ec70dd751f8871e12038
MD5 b0fcb7e25267a35a3c41da9d1078eb5d
BLAKE2b-256 3f2dac325f93a5ac46d912d23bad80f85c16aeec0b938fc0fd61e0f187b7e054

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_dryci-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 08760412ead53d884560d674f7988b63230fd24570ec41bf8d8ca2a9cfe50545
MD5 9f559162de7e21d4332a2cfb078c7909
BLAKE2b-256 11f2cca7589dbc97e176083726c3c057a61db6d8a7b57ffd4b121662196ab489

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_dryci-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d26177aaba653b8ef0a54b89b04d6ba88166bae28d68788d8ccd8a146424e709
MD5 27015917c3801bc7305523572484a033
BLAKE2b-256 d51053a7312e4c13deccf6020d95614d0e9d973330110ba5809eee545d505b63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_dryci-0.1.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7580d4ea3194904f2a610673809939e83a90467a7283bbe4ddbc3f08c0e53f6e
MD5 3b5bd4c13b2e2229cbb73c1ae5957f07
BLAKE2b-256 11a3245ee1d22570e7b0bb3542cd3162391cf1b1a5419ae6b91aceea7241208a

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