Skip to content

test(integration): add scenario-driven integration tests #5

test(integration): add scenario-driven integration tests

test(integration): add scenario-driven integration tests #5

name: Integration Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
# Parity check runs on every PR and push: confirms every scenario in
# www.hotdata.dev/api/test-scenarios.yaml has a matching test file in this
# repo. www.hotdata.dev is private, so we fetch via the GitHub App token —
# same pattern as regenerate.yml.
scenario-parity:
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
with:
app-id: 3060111
private-key: ${{ secrets.HOTDATA_AUTOMATION_PRIVATE_KEY }}
owner: hotdata-dev
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: '3.12'
- name: Install PyYAML
run: pip install --quiet pyyaml
- name: Fetch scenarios manifest
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
curl -sS -f -L \
-H "Accept: application/vnd.github.v3.raw" \
-H "Authorization: Bearer $GH_TOKEN" \
https://api.github.com/repos/hotdata-dev/www.hotdata.dev/contents/api/test-scenarios.yaml \
-o test-scenarios.yaml
- name: Check parity
run: |
python3 - <<'PY'
import sys, pathlib, yaml
scenarios = yaml.safe_load(pathlib.Path("test-scenarios.yaml").read_text())["scenarios"]
missing = []
for s in scenarios:
if "python" in (s.get("optional_for") or []):
continue
expected = pathlib.Path("tests/integration") / f"test_{s['name']}.py"
if not expected.exists():
missing.append(str(expected))
if missing:
print(f"::error::sdk-python is missing tests for {len(missing)} scenarios:")
for m in missing:
print(f" - {m}")
sys.exit(1)
print(f"All {len(scenarios)} scenarios have corresponding test files.")
PY
# Integration tests run against production. Skipped automatically by the
# conftest if HOTDATA_SDK_TEST_API_KEY / HOTDATA_SDK_TEST_WORKSPACE_ID aren't
# set (e.g. PRs from forks where secrets aren't injected).
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: '3.12'
- name: Install package and test deps
run: |
pip install --quiet -r requirements.txt -r test-requirements.txt
pip install --quiet -e .
- name: Run integration tests
env:
HOTDATA_SDK_TEST_API_URL: ${{ vars.HOTDATA_SDK_TEST_API_URL }}
HOTDATA_SDK_TEST_API_KEY: ${{ secrets.HOTDATA_SDK_TEST_API_KEY }}
HOTDATA_SDK_TEST_WORKSPACE_ID: ${{ vars.HOTDATA_SDK_TEST_WORKSPACE_ID }}
HOTDATA_SDK_TEST_CONNECTION_ID: ${{ vars.HOTDATA_SDK_TEST_CONNECTION_ID }}
run: pytest tests/integration -v