diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 0c444189..a7336663 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -48,5 +48,43 @@ jobs: - name: Run smoke test - dbt run: | ./integration_tests/dbt/smoke_test.sh + + smoke-test-cloud: + runs-on: ubuntu-latest + strategy: + max-parallel: 1 + matrix: + include: + - python-version: "3.11" + dbt-version: "1.8" + - python-version: "3.11" + dbt-version: "latest" + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" # caching pip dependencies + cache-dependency-path: setup.py + - run: | + python -m pip install --upgrade pip + if [ "${{ matrix.dbt-version }}" == "latest" ]; then + pip install dbt-core + pip install dbt-duckdb + else + pip install dbt-core~=${{ matrix.dbt-version }}.0 + pip install dbt-duckdb~=${{ matrix.dbt-version }}.0 + fi + + - name: Install Recce + run: | + pip install . + + - name: Run smoke test - dbt + run: | + ./integration_tests/dbt/smoke_test_cloud.sh env: - PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.RECCE_CLOUD_TOKEN }} + RECCE_STATE_PASSWORD: ${{ vars.RECCE_STATE_PASSWORD}} diff --git a/integration_tests/dbt/smoke_test.sh b/integration_tests/dbt/smoke_test.sh index 4b2be5aa..757b3b4c 100755 --- a/integration_tests/dbt/smoke_test.sh +++ b/integration_tests/dbt/smoke_test.sh @@ -51,25 +51,22 @@ function check_server_status() { if timeout 20 bash -c 'until curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/api/info | grep -q 200; do echo "Server not ready yet..." sleep 2 - done'; then + done'; then echo "Server is up and running." - EXITCODE=0 else echo "Failed to start the server within the time limit." - EXITCODE=1 + exit 1 fi echo "Stopping the server..." kill $(jobs -p) || true echo "Server stopped." - - exit $EXITCODE } echo "Starting the server..." recce server & check_server_status -echo "Starting the server (review mode)" +echo "Starting the server (review mode)..." recce server --review recce_state.json & -check_server_status \ No newline at end of file +check_server_status diff --git a/integration_tests/dbt/smoke_test_cloud.sh b/integration_tests/dbt/smoke_test_cloud.sh new file mode 100755 index 00000000..03c90a40 --- /dev/null +++ b/integration_tests/dbt/smoke_test_cloud.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +set -euo pipefail + +NEW_WORKSPACE=$(dirname "$GITHUB_WORKSPACE") +cd "$NEW_WORKSPACE" || exit +pwd + +# Clone jaffle_shop_duckdb +GIT_REPO="https://github.com/DataRecce/jaffle_shop_duckdb.git" +GIT_BRANCH="chore/smoke-test-cloud" + +git clone --depth 1 --branch $GIT_BRANCH $GIT_REPO +cd jaffle_shop_duckdb || exit + +# Prepare dbt artifacts +dbt --version +dbt deps +dbt seed +dbt run +dbt docs generate + +mkdir -p ~/.recce +echo "user_id: 00000000000000000000000000000000" > ~/.recce/profile.yml +echo "anonymous_tracking: false" >> ~/.recce/profile.yml + +# Hide PR information from GitHub Action +HOLD_GITHUB_EVENT_PATH="$GITHUB_EVENT_PATH" +unset GITHUB_EVENT_PATH + +# Recce artifacts +recce cloud upload-artifacts --branch $GIT_BRANCH +rm -rf target + +recce cloud download-base-artifacts --branch $GIT_BRANCH +recce cloud download-artifacts --branch $GIT_BRANCH + +# Recce Run +recce run --cloud + +# Recce state +recce cloud download +recce cloud purge --force +recce cloud upload recce_state.json + +# Recce Summary +recce summary --cloud + +function check_server_status() { + echo "Waiting for the server to respond..." + if timeout 20 bash -c 'until curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/api/info | grep -q 200; do + echo "Server not ready yet..." + sleep 2 + done'; then + echo "Server is up and running." + else + echo "Failed to start the server within the time limit." + exit 1 + fi + + echo "Stopping the server..." + kill $(jobs -p) || true + echo "Server stopped." +} + +# Recce Server +echo "Starting the server (cloud and review mode)..." +recce server --cloud --review & +check_server_status + +export GITHUB_EVENT_PATH="$HOLD_GITHUB_EVENT_PATH"