-
Notifications
You must be signed in to change notification settings - Fork 25
test(cloud): add staging smoke test for recce-cloud upload #1114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ebe5a23
f7becfe
897c0ad
3771429
2da709a
27245a8
524aa8c
997c2ee
368dd28
a37992e
3b00604
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: Upload Smoke Test (recce-cloud) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "recce_cloud/**" | ||
| - "integration_tests/recce_cloud/**" | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - "recce_cloud/**" | ||
| - "integration_tests/recce_cloud/**" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| authorize: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| authorized: ${{ steps.check.outputs.authorized }} | ||
| steps: | ||
| - name: Check if PR author has write permission | ||
| id: check | ||
| run: | | ||
| if [[ "${{ github.event_name }}" == "push" ]]; then | ||
| echo "authorized=true" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
| PERMISSION=$(gh api repos/${{ github.repository }}/collaborators/${{ github.triggering_actor }}/permission --jq '.permission' 2>/dev/null || echo "none") | ||
| if [[ "$PERMISSION" == "write" || "$PERMISSION" == "admin" ]]; then | ||
| echo "authorized=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "authorized=false" >> $GITHUB_OUTPUT | ||
| echo "::warning::Upload smoke test skipped — requires write permission." | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| upload-smoke-test: | ||
| needs: authorize | ||
| if: needs.authorize.outputs.authorized == 'true' | ||
| concurrency: | ||
| group: upload-smoke-test | ||
| cancel-in-progress: false | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| max-parallel: 1 | ||
| matrix: | ||
| python-version: ["3.11"] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| version: "latest" | ||
|
|
||
| - name: Install recce-cloud | ||
| working-directory: recce_cloud | ||
| run: uv sync --no-dev --python ${{ matrix.python-version }} | ||
|
|
||
| - name: Run upload smoke test | ||
| working-directory: recce_cloud | ||
| run: uv run ../integration_tests/recce_cloud/smoke_test_upload.sh | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.RECCE_CLOUD_TOKEN }} | ||
| SMOKE_TEST_API_TOKEN: ${{ secrets.SMOKE_TEST_API_TOKEN }} | ||
| SMOKE_TEST_ORG: ${{ secrets.SMOKE_TEST_ORG }} | ||
| SMOKE_TEST_PROJECT: ${{ secrets.SMOKE_TEST_PROJECT }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "metadata": { | ||
| "dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1/catalog.json", | ||
| "dbt_version": "1.8.0", | ||
| "adapter_type": "duckdb", | ||
| "generated_at": "2026-01-01T00:00:00.000000Z", | ||
| "invocation_id": "00000000-0000-0000-0000-000000000000", | ||
| "env": {} | ||
| }, | ||
| "nodes": {}, | ||
| "sources": {}, | ||
| "errors": null | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "metadata": { | ||
| "dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v11/manifest.json", | ||
| "dbt_version": "1.8.0", | ||
| "adapter_type": "duckdb", | ||
| "generated_at": "2026-01-01T00:00:00.000000Z", | ||
| "invocation_id": "00000000-0000-0000-0000-000000000000", | ||
| "env": {} | ||
| }, | ||
| "nodes": {}, | ||
| "sources": {}, | ||
| "macros": {}, | ||
| "docs": {}, | ||
| "exposures": {}, | ||
| "metrics": {}, | ||
| "groups": {}, | ||
| "selectors": {}, | ||
| "disabled": [], | ||
| "parent_map": {}, | ||
| "child_map": {} | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,217 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| set -euo pipefail | ||||||
|
|
||||||
| # ============================================================ | ||||||
| # Smoke test for `recce-cloud upload` | ||||||
| # | ||||||
| # Tests all upload flows against the staging server: | ||||||
| # 1. GitHub PR Upload (GITHUB_TOKEN, platform-specific) | ||||||
| # 2. GitHub Prod Upload (GITHUB_TOKEN, --type prod) | ||||||
| # 3. RECCE_API_TOKEN PR Upload (generic endpoint) | ||||||
| # 4. RECCE_API_TOKEN Prod Upload (generic endpoint, --type prod) | ||||||
| # 5. Session Name Upload (--session-name, dev session) | ||||||
| # 6. Session ID Upload (--session-id, reuses session from test 5) | ||||||
| # | ||||||
| # Required env vars: | ||||||
| # GITHUB_TOKEN - PAT with repo scope for the test repo | ||||||
| # | ||||||
| # Optional env vars: | ||||||
| # SMOKE_TEST_API_TOKEN - RECCE_API_TOKEN for generic endpoint tests (tests 3-6) | ||||||
| # SMOKE_TEST_ORG - Recce Cloud org ID for session-name/ID tests (tests 5-6) | ||||||
| # SMOKE_TEST_PROJECT - Recce Cloud project ID for session-name/ID tests (tests 5-6) | ||||||
| # | ||||||
| # Provided by GitHub Actions (already set): | ||||||
| # GITHUB_ACTIONS, GITHUB_SHA, GITHUB_REF_NAME | ||||||
| # ============================================================ | ||||||
|
|
||||||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||
| FIXTURES_DIR="${SCRIPT_DIR}/fixtures/minimal-target" | ||||||
| SMOKE_TEST_GITHUB_REPO="DataRecce/recce-smoke-test" | ||||||
| TEST_BRANCH="smoke-test-upload-$(date +%s)" | ||||||
| DEV_SESSION_NAME="smoke-test-dev-$(date +%s)" | ||||||
|
Comment on lines
+29
to
+31
|
||||||
| DEV_SESSION_ID="" | ||||||
| PASS_COUNT=0 | ||||||
| FAIL_COUNT=0 | ||||||
|
|
||||||
| # ---- Prerequisite checks ---- | ||||||
| if [[ "${GITHUB_ACTIONS:-}" != "true" ]]; then | ||||||
| echo "ERROR: This test must run inside GitHub Actions" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| if [[ -z "${GITHUB_TOKEN:-}" ]]; then | ||||||
| echo "ERROR: GITHUB_TOKEN is required" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| # ---- Recce Cloud config ---- | ||||||
| export RECCE_CLOUD_API_HOST="${RECCE_CLOUD_API_HOST:-https://staging.cloud.datarecce.io}" | ||||||
|
|
||||||
| # Disable anonymous tracking | ||||||
| mkdir -p ~/.recce | ||||||
| cat > ~/.recce/profile.yml <<EOF | ||||||
| user_id: 00000000000000000000000000000000 | ||||||
| anonymous_tracking: false | ||||||
| EOF | ||||||
|
|
||||||
| # ---- Create synthetic GitHub event file ---- | ||||||
| SYNTHETIC_EVENT=$(mktemp) | ||||||
| cat > "$SYNTHETIC_EVENT" <<EOF | ||||||
| { | ||||||
| "pull_request": { | ||||||
| "number": 1 | ||||||
| } | ||||||
| } | ||||||
| EOF | ||||||
|
|
||||||
| # ---- Cleanup trap ---- | ||||||
| cleanup() { | ||||||
| echo "" | ||||||
| echo "=== Cleanup ===" | ||||||
| # Delete PR sessions created during tests. | ||||||
| # Uses GITHUB_TOKEN (platform auto-detect delete) — works for both | ||||||
| # GitHub-flow and RECCE_API_TOKEN-flow created sessions. | ||||||
| env -u RECCE_API_TOKEN \ | ||||||
| GITHUB_REPOSITORY="$SMOKE_TEST_GITHUB_REPO" \ | ||||||
| GITHUB_EVENT_PATH="$SYNTHETIC_EVENT" \ | ||||||
| GITHUB_HEAD_REF="$TEST_BRANCH" \ | ||||||
| GITHUB_BASE_REF="main" \ | ||||||
| recce-cloud delete --force 2>/dev/null || true | ||||||
|
|
||||||
| # Delete dev session created by session-name test (if any). | ||||||
| if [[ -n "$DEV_SESSION_ID" ]]; then | ||||||
| env RECCE_API_TOKEN="$SMOKE_TEST_API_TOKEN" \ | ||||||
| recce-cloud delete --session-id "$DEV_SESSION_ID" --force 2>/dev/null || true | ||||||
| fi | ||||||
|
|
||||||
| rm -f "$SYNTHETIC_EVENT" | ||||||
| echo "Cleanup complete" | ||||||
| } | ||||||
| trap cleanup EXIT | ||||||
|
|
||||||
| # ---- Test helper ---- | ||||||
| run_test() { | ||||||
| local test_name="$1" | ||||||
| shift | ||||||
| echo "" | ||||||
| echo "=== $test_name ===" | ||||||
| if "$@"; then | ||||||
| echo "PASS: $test_name" | ||||||
| PASS_COUNT=$((PASS_COUNT + 1)) | ||||||
| else | ||||||
| echo "FAIL: $test_name (exit code: $?)" | ||||||
| FAIL_COUNT=$((FAIL_COUNT + 1)) | ||||||
| fi | ||||||
| } | ||||||
|
|
||||||
| echo "============================================" | ||||||
| echo "Upload Smoke Test" | ||||||
| echo "============================================" | ||||||
| echo "Test repo: $SMOKE_TEST_GITHUB_REPO" | ||||||
| echo "Test branch: $TEST_BRANCH" | ||||||
| echo "Fixtures: $FIXTURES_DIR" | ||||||
| echo "API host: $RECCE_CLOUD_API_HOST" | ||||||
| echo "API token: ${SMOKE_TEST_API_TOKEN:+set}${SMOKE_TEST_API_TOKEN:-not set}" | ||||||
|
||||||
| echo "API token: ${SMOKE_TEST_API_TOKEN:+set}${SMOKE_TEST_API_TOKEN:-not set}" | |
| echo "API token: $( if [[ -n ${SMOKE_TEST_API_TOKEN:-} ]]; then echo 'set'; else echo 'not set'; fi )" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description mentions a required
SMOKE_TEST_GITHUB_REPOsecret, but this workflow doesn't pass it to the smoke test script. If the repo should be configurable, addSMOKE_TEST_GITHUB_REPO: ${{ secrets.SMOKE_TEST_GITHUB_REPO }}(or a repo variable) toenv:and ensure the script reads it.