# How public dbt projects test their models

How many models in real public data transformation projects have any test, how many check their keys, how many
projects declare source freshness, and how many run tests before a change merges? This study lists every public GitHub
repository holding a dbt project file, keeps the ones that pass a qualifying rule written before any was measured (no
forks, tutorials, courses or packages; at least 20 models and 2 contributors), measures a random sample of them from
their code, and publishes the distributions with a lookup for a reader's own project. The page is `index.html`.

## Data

Public GitHub repositories, read through the official APIs (code search, GraphQL, contributors) and through shallow,
sparse clones that were deleted after measurement. Only counts were kept, privately; the files here hold aggregates
only and name no repository, owner or project. GitHub's Acceptable Use Policies allow researchers to use public,
non-personal information for research when the publication is open access.

## Reproduce

Python 3.12 with PyYAML (`pip install pyyaml`), the `gh` command line tool logged in (the scripts read its token), and
`git`. The tests need only PyYAML.

```
python3 -B tests/test_measure.py
python3 -B tests/test_measure_v2.py
python3 -B tools/enumerate.py /path/to/new/enum --budget 540        # repeat until ENUMERATION_COMPLETE
python3 -B tools/screen.py /path/to/new/enum /path/to/new/screen meta --companies <a CSV with a company column>
python3 -B tools/screen.py /path/to/new/enum /path/to/new/screen rtree --companies <same CSV>
python3 -B tools/screen.py /path/to/new/enum /path/to/new/screen tree --companies <same CSV>   # truncated listings only
python3 -B tools/screen.py /path/to/new/enum /path/to/new/screen contrib --companies <same CSV>
python3 -B tools/screen.py /path/to/new/enum /path/to/new/screen decide --companies <same CSV>
python3 -B tools/run_sample.py /path/to/new/screen /path/to/new/sample /path/to/new/work
python3 -B tools/summarize.py /path/to/new/screen /path/to/new/sample .
python3 -I -B site/render.py
```

Run each stage again to continue it, until it prints its COMPLETE line. The company list
and the tool maker's logins used for the owner rule are private and not included (pass them with `--companies` and
`--maker-orgs`). The per-repository counts are not included either, because they
would name projects, so `results/summary.json` cannot be recomputed from this download alone, and a new run reads the
repositories as they stand then.

## Files

- `public-rule/`: the qualifying rule, committed before any repository was listed, and four changes to it, all
  committed before the qualifying count: the order the rules are applied and batched reads (before any repository was
  screened), the package rule (after partial screening counts were seen), the slower rules applied to a random
  screening sample of 10,000 (once the frame was listed), and folder listings read through the REST git tree. These are public copies: clause ids are written
  in lower case and two reading-rate figures are left out; the committed originals are unchanged in the study's
  repository but not in this download.
- `DESIGN-r1.md`, `protocol-r1.json`, `predictions-r1.json`: the design, the definitions of every measure with
  examples, and the expected finding, its opposite and six predictions, all committed before any sampled repository
  was measured.
- `tools/enumerate.py`: lists every file named dbt_project.yml through code search, split by file size.
- `tools/screen.py`: applies the qualifying rule and writes the count excluded by each clause.
- `tools/run_sample.py`, `tools/measure.py`: draw the sample, clone, measure and delete each repository.
- `tools/summarize.py`: aggregates, bootstrap intervals and the predictions scored as declared.
- Added after the results, each declared before it ran: `DESIGN-r1-v2.md` (a revised file reader and two
  checks) and `DESIGN-r1-v2-check1b.md` (the check by an independent reader; running dbt on the
  repositories was not allowed). `tools/measure_v2.py`, `tools/run_v2.py`, `tools/runs_check.py` and
  `tools/summarize_v2.py` run them; `checks/independent_count.py` is the reader an independent author wrote from the
  protocol's definitions without seeing the measurement code, with its notes; `results/v2-summary.json` holds the
  results. The original reader's `results/summary.json` is unchanged.
- `DESIGN-r1-change5.md`: the headline figures the checks support, with the
  pull-request figure from the revised reader leading wherever it appears. `tools/summarize_review2.py` writes its descriptives
  (agreement on positives, Cohen's kappa, the cost of the test words in the tutorial filter) to
  `results/review2-summary.json`.
- `results/summary.json`: every published number. `results/distribution.json`: the rounded per-project shares behind
  the lookup, each measure shuffled on its own so no row links two measures or identifies a project.
- `assumptions.json`: the money assumptions behind the page's "What it is worth" section.
- `site/render.py`, `site/page.css`: the page. Every number on it comes from `results/` or `assumptions.json`.
- `vendor/viz-design-system/`: the chart kit (version 2.3.0) with its licences.

Some files are packed in data-project-test-audit-data-1.zip; unzip it here to restore the full export, which the manifest lists file by file.
