Skip to content

Add full test/coverage enforcement, Python linting, and incremental web events staging - #9

Merged
seanlip merged 1 commit into
developfrom
add-tests
Nov 25, 2026
Merged

seanlip merged 1 commit into
developfrom
add-tests

Conversation

@seanlip

@seanlip seanlip commented Nov 25, 2026

Copy link
Copy Markdown
Member

Adds end-to-end test, documentation, lint, and coverage enforcement across SQL, YAML, and Python, and fixes the stg_web_analytics__events staging model so weekly production runs preserve history.

  1. dbt Data Tests, Source Freshness & Macro Test:
  • Added not_null data_tests and column descriptions for core GA4 fields (user_pseudo_id, event_name, event_date, event_timestamp) in models/staging/web/schema.yml.
  • Added query-based source freshness (TIMESTAMP_MICROS(event_timestamp), 36h warn / 48h error, filtered to the last 3 _TABLE_SUFFIX shards) in models/staging/web/src_web.yml and wired dbt source freshness into weekly_run.yml before dbt build.
  • Added tests/test_generate_surrogate_key.sql (zero BigQuery table scans) to test macros/generate_surrogate_key.sql.
  1. Automated 100% Coverage & Python Linting in CI (pr_validation.yml):
  • Added scripts/check_dbt_coverage.py enforcing 100% model documentation, data_tests, intermediate//marts/ unit_tests, column descriptions, custom macro coverage, source freshness compliance, and DAG layering rules offline.
  • Added 21 DAMP unit tests in scripts/test_check_dbt_coverage.py with 100% statement and branch coverage enforced via coverage (.coveragerc).
  • Added Ruff (ruff.toml, 88-char line length) for Python linting and formatting.
  1. Incremental Partitioned Staging Model (stg_web_analytics__events):
  • Converted stg_web_analytics__events to materialized='incremental' (insert_overwrite), partitioned daily by DATE event_date (PARSE_DATE('%Y%m%d', event_date)) and clustered by ["event_name", "user_pseudo_id"].
  • Scans the last 10 days on incremental runs (7-day weekly cadence + 3-day GA4 late-export buffer), 90 days on prod full-refresh (configurable via backfill_days), and 7 days in dev/CI.
  • Added --full-refresh to pr_validation.yml (ephemeral CI dataset) and an optional full_refresh checkbox to weekly_run.yml workflow_dispatch.
  1. Docs & Housekeeping:
  • Added .venv setup instructions to README.md, removed duplicated check commands from models/README.md in favor of CONTRIBUTING.md, updated .gitignore, and completed the truncated Links & Screenshots field in .github/ISSUE_TEMPLATE/05_technical_bug.yml.

Verification

  • yamllint --strict . — passed
  • ruff check . & ruff format --check . — passed
  • coverage run -m unittest discover -s scripts -v && coverage report — 21/21 passed, 100% statement (122/122) & branch (72/72) coverage
  • sqlfluff lint models/ tests/ — passed
  • dbt deps + dbt parse --show-all-deprecations — passed (zero deprecation warnings)
  • python3 scripts/check_dbt_coverage.py — 100% across all dbt coverage & DAG layering checks

Post-Merge Note

Will trigger one manual run of Weekly Production Analytics Run with full_refresh = true (dropping the old non-partitioned oppia-analytics-prod.analytics_production_staging.stg_web_analytics__events table first if BigQuery rejects replacing a non-partitioned table in place). Subsequent Sunday scheduled runs will run incrementally.

@seanlip
seanlip requested a review from a team as a code owner November 25, 2026 10:01
@seanlip

seanlip commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Merging to ensure the repo is in a good state to make contributions to (this PR adds a lot of test/lint coverage).

@seanlip
seanlip merged commit 7b60dc7 into develop Nov 25, 2026
2 checks passed
@seanlip
seanlip deleted the add-tests branch November 25, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant