TECHNOLOGIESTieInn Technologies

Running data tests in CI with GitHub Actions

Data Quality Automation with Python · 8 questions

Short notes

Key idea

Tests only protect you when they run automatically. CI (such as GitHub Actions) runs code tests on every pull request and data tests on a schedule or after each load. A non-zero exit code fails the run, and quality gates block merges or stop dashboard refreshes.

Syntax

# .github/workflows/data-tests.yml
on:
  pull_request:
  schedule:
    - cron: "30 1 * * *"   # 07:00 IST (cron is UTC)
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: {python-version: "3.12", cache: pip}
      - run: pip install -r requirements.txt
      - run: pytest -q --junitxml=results.xml
        env: {DB_PASSWORD: "${{ secrets.DB_PASSWORD }}"}
      - if: always()
        uses: actions/upload-artifact@v4
        with: {name: test-results, path: results.xml}

Example

The shop scorecard gate prints ::error::payment_method not null and exits 1, so the run turns red and the refresh task is stopped.

Traps

  • Checks that print FAIL but exit 0.
  • Credentials in the repo; use secrets and read-only access.
  • Forgetting if: always() on the report upload.
  • Cron times are UTC.

Want the full lesson with step-by-step examples, a project and a certificate? Data Quality Automation with Python course, ₹120 →

Questions

Open in Code Lab5 free questions
5 questions

    Running data tests in CI with GitHub Actions

  1. Question 1easy

    What does a CI service like GitHub Actions do with your test suite?

  2. Running data tests in CI with GitHub Actions

  3. Question 2medium

    You want data tests every day at 07:00 IST. Which schedule?

  4. Running data tests in CI with GitHub Actions

  5. Question 3easy

    In a workflow step, what's the difference between uses: and run:?

  6. Running data tests in CI with GitHub Actions

  7. Question 4medium

    What does this print?

    checks = [("not null", "error", 1), ("unique", "error", 0), ("big orders", "warn", 4)]
    errors = [name for name, level, failing in checks if failing and level == "error"]
    print(1 if errors else 0)
  8. Running data tests in CI with GitHub Actions

  9. Question 5easy

    Where should the warehouse password for CI data tests live?

3 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.