Skip to content

N: End-to-end automated pipeline test — two countries (Rwanda + Ethiopia), fresh environment #163

Description

@EBukin

What to build

An automated end-to-end test that proves the full data preparation pipeline works on a fresh R environment with no pre-existing project data, for two different countries. This test is the definitive quality gate for the entire pipeline redesign (#149).

What it tests

Two country scenarios run in sequence (or in parallel if CI supports it):

  1. Rwanda — the default template country; uses get_country_shapes("RWA") + the bundled Rwanda synthetic metadata Excel
  2. Ethiopia — a second country with different admin structure; uses get_country_shapes("ETH") + auto-generated metadata skeleton

For each country, the test:

  1. Scaffolds a new project into withr::local_tempdir() via create_new_pti(path, app_name = "<Country> PTI", open = FALSE)
  2. Verifies all placeholder tokens ({{APP_NAME}}, {{COUNTRY NAME}}) are replaced
  3. Calls get_country_shapes(iso3) and verifies the returned list passes validate_geometries()
  4. Runs the full 00-master.R pipeline headlessly — via quarto::quarto_render() calls matching the current master script
  5. Asserts all expected app-data/ outputs exist and are valid:
    • app-data/shapes.rds — loadable with readRDS(); passes validate_geometries()
    • app-data/metadata.xlsx — loadable with fct_template_reader(); has at least one variable
    • app-data/metadata-hex.xlsx — exists (Step 4 runs by default)
    • app-data/pti-metadata.html — exists and is non-empty
    • docs/index.html — exists (Quarto website rendered)
  6. Verifies shiny::testApp() or equivalent headless launch completes without error

Test location

tests/testthat/test-e2e-pipeline.R

Tagged with a custom skip condition so it does not run on every devtools::test() call — only in CI or when explicitly opted in:

skip_if_not(
  identical(Sys.getenv("PTI_RUN_E2E"), "true"),
  "Skipping E2E pipeline test (set PTI_RUN_E2E=true to run)"
)

CI configuration

A separate GitHub Actions workflow e2e-pipeline.yml that:

  • Runs on push to main and on a weekly schedule
  • Sets PTI_RUN_E2E=true
  • Has internet access (fetches live WB parquets and hex data)
  • Uses a clean R environment (no cached project data)

Ethiopia metadata note

Ethiopia requires a metadata workbook. For the E2E test, generate a minimal skeleton automatically using the auto-generation path (if #7 lands) or generate a synthetic one from the shapes using a test helper. The test does not need real indicator data — synthetic random values per polygon are sufficient to exercise the pipeline.

Acceptance criteria

  • Test runs to completion for both Rwanda and Ethiopia in CI
  • All six assertions pass for each country
  • Test is skipped by default in devtools::test(); runs with PTI_RUN_E2E=true
  • CI workflow file present in .github/workflows/e2e-pipeline.yml
  • Test fails loudly with an actionable message if any pipeline step errors
  • Rwanda run completes in under 10 minutes on a standard CI runner

Blocked by

#148 (Inf-4 — get_country_shapes() must exist)
Issues A through J of #149 (full pipeline must be in place)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions