Analytics team members should push feature branches directly to oppia/analytics-data-platform rather than from a personal fork:
git checkout develop
git pull origin develop
git checkout -b feature/<short-description>Why upstream branches instead of forks? GitHub withholds cloud credentials from fork-origin PRs for security. PRs from forks will still run offline linting and
dbt parse, but BigQuery Build & Test will fail and block merging until the PR is reopened from a branch inoppia/analytics-data-platform.
Install dev dependencies once (pip install -r requirements-dev.txt), then verify your changes:
# Offline linting, Python unit tests (100% coverage), dbt parsing, and dbt coverage checks
yamllint --strict .
ruff check .
ruff format --check .
coverage run -m unittest discover -s scripts -v && coverage report
sqlfluff lint models/ tests/
dbt parse
python3 scripts/check_dbt_coverage.py
# Full build and data tests in your personal oppia-analytics-test sandbox
dbt build --target devFor SQL conventions, folder placement, and partitioning/clustering rules, see models/README.md.
- All models: Must have a
descriptionand at least onedata_testsentry inschema.yml. intermediate/andmarts/models: Must also include at least one native dbtunit_tests:entry inschema.ymlto verify transformation logic against mocked rows (useformat: sqlif inputs contain BigQuerySTRUCT/ARRAYcolumns; trivial passthrough models can opt out withconfig: {meta: {unit_test_exempt: true}}). Example:unit_tests: - name: test_fct_lesson_completions_dedup model: fct_lesson_completions given: - input: ref('stg_web_analytics__events') rows: - {user_pseudo_id: 'u1', event_name: 'lesson_complete', event_date: '20261101'} expect: rows: - {user_pseudo_id: 'u1', completion_count: 1}
- Custom macros (
macros/): Must be exercised by at least one model or test intests/. - Sources (
src_*.yml): Must include adescription,config.loaded_at_field, andconfig.freshness(orconfig: {meta: {freshness_exempt: true}}for static lookup tables).
- Keep PRs focused on a single logical change and link the relevant GitHub issue.
- Include a brief summary of what changed, which models/tests were added or updated, and any expected schema or metric impact.
- Never commit
profiles.yml, service account JSON keys, ortarget/artifacts. - Wait for both Static Checks (Lint & dbt Parse) and BigQuery Build & Test to pass, then request review from an approved reviewer.
Reviewers should verify the following before approving and merging into develop:
- CI checks: Confirm both Static Checks (Lint & dbt Parse) and BigQuery Build & Test are green. (Fork PRs intentionally fail BigQuery Build & Test; ask the author to reopen the PR from an upstream branch in
oppia/analytics-data-platform.) - SQL & dbt hygiene:
- Models use
{{ ref() }}/{{ source() }}(no hardcoded project or dataset names). - Final
SELECTlists columns explicitly (noSELECT *in final projections) and queries are idempotent. - High-volume intermediate and mart tables define
partition_byandcluster_byconfigs.
- Models use
- Documentation & tests: New or changed models have clear descriptions,
data_tests(not_null,unique, etc.) on critical keys, and meaningfulunit_testsforintermediate/andmarts/logic (verify anyunit_test_exemptorfreshness_exemptopt-outs are genuinely justified). - Safety & scope: No credentials or local config files committed, and any changes to
.github/workflows/ordbt_project.ymlare intentional and carefully reviewed.
CI uses GCP Workload Identity Federation (WIF) via google-github-actions/auth@v3 — no static service account JSON keys are stored in GitHub. Test and production credentials are strictly separated:
| Workflow | GCP Project | GitHub Secrets | GCP IAM Attribute Condition |
|---|---|---|---|
| pr_validation.yml | oppia-analytics-test |
GCP_TEST_WIF_PROVIDER, GCP_TEST_SERVICE_ACCOUNT |
assertion.repository == 'oppia/analytics-data-platform' |
| weekly_run.yml | oppia-analytics-prod |
GCP_PROD_WIF_PROVIDER, GCP_PROD_SERVICE_ACCOUNT |
assertion.repository == 'oppia/analytics-data-platform' && assertion.ref == 'refs/heads/develop' |
Because the production WIF provider restricts assertion.ref to refs/heads/develop, PR branches cannot authenticate to oppia-analytics-prod even at the GCP IAM layer.
Protect develop with a branch protection rule / ruleset that:
- Blocks direct pushes and force-pushes to
develop. - Requires pull request approval from approved reviewers (
CODEOWNERS). - Requires the Static Checks (Lint & dbt Parse) and BigQuery Build & Test status checks to pass before merging.
- Enables "Automatically delete head branches" so merged feature branches stay cleaned up.