diff --git a/.github/workflows/recce_ci.yml b/.github/workflows/recce_ci.yml index c6cde9d..381bb06 100644 --- a/.github/workflows/recce_ci.yml +++ b/.github/workflows/recce_ci.yml @@ -6,11 +6,14 @@ on: jobs: check-pull-request: name: Prepare for Recce + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + RECCE_STATE_PASSWORD: ${{ secrets.RECCE_STATE_PASSWORD }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 - uses: actions/setup-python@v5 with: @@ -18,7 +21,9 @@ jobs: cache: "pip" - name: Install dependencies - run: pip install -r requirements.txt + run: | + pip install -r requirements.txt + pip install -U recce - name: Trigger the dbt cloud job and fetch artifacts for Recce uses: datarecce/dbt-cloud-action@main @@ -27,7 +32,9 @@ jobs: dbt_cloud_token: ${{ secrets.DBT_CLOUD_API_TOKEN }} dbt_cloud_account_id: 62083 dbt_cloud_base_job_id: 747906 - dbt_cloud_current_job_id: 747907 + dbt_cloud_current_job_id: 768650 + git_sha: ${{ github.event.pull_request.head.sha }} + schema_override: "PR_${{ github.event.pull_request.number }}" failure_on_error: true - uses: "google-github-actions/auth@v2" @@ -35,26 +42,27 @@ jobs: with: credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY_JSON }} - - name: Run Recce in cloud mode + - name: Run dbt + run: | + pwd + tree -L 1 + dbt deps + dbt docs generate --select state:modified --defer --state target-base env: BQ_PROJECT: ${{ steps.google-auth.outputs.project_id }} - BQ_DATASET: recce_ci + BQ_DATASET: "PR_${{ github.event.pull_request.number }}" BQ_KEYFILE_PATH: ${{ steps.google-auth.outputs.credentials_file_path }} - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - RECCE_STATE_PASSWORD: ${{ secrets.RECCE_STATE_PASSWORD }} - run: recce run --cloud - - name: Prepare Recce Summary - id: recce-summary + - name: Run Recce in cloud mode + run: recce run --cloud env: BQ_PROJECT: ${{ steps.google-auth.outputs.project_id }} - BQ_DATASET: recce_ci + BQ_DATASET: "PR_${{ github.event.pull_request.number }}" BQ_KEYFILE_PATH: ${{ steps.google-auth.outputs.credentials_file_path }} - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - RECCE_STATE_PASSWORD: ${{ secrets.RECCE_STATE_PASSWORD }} - run: | - set -eo pipefail + - name: Prepare Recce Summary + id: recce-summary + run: | recce summary --cloud > recce_summary.md # Add next steps message @@ -76,6 +84,10 @@ jobs: For the full summary, please check the Job Summary page: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} " >> recce_summary.md fi + env: + BQ_PROJECT: ${{ steps.google-auth.outputs.project_id }} + BQ_DATASET: "PR_${{ github.event.pull_request.number }}" + BQ_KEYFILE_PATH: ${{ steps.google-auth.outputs.credentials_file_path }} - name: Comment on pull request uses: thollander/actions-comment-pull-request@v2 diff --git a/models/marts/customers.sql b/models/marts/customers.sql index 129eb8f..30736fd 100644 --- a/models/marts/customers.sql +++ b/models/marts/customers.sql @@ -18,7 +18,7 @@ customer_orders_summary as ( orders.customer_id, count(distinct orders.order_id) as count_lifetime_orders, - count(distinct orders.order_id) > 1 as is_repeat_buyer, + count(distinct orders.order_id) > 2 as is_repeat_buyer, min(orders.ordered_at) as first_ordered_at, max(orders.ordered_at) as last_ordered_at, sum(orders.subtotal) as lifetime_spend_pretax, diff --git a/recce.yml b/recce.yml new file mode 100644 index 0000000..7497496 --- /dev/null +++ b/recce.yml @@ -0,0 +1,13 @@ +# Preset Checks +# Please see https://datarecce.io/docs/features/preset-checks/ +checks: +- name: Row count diff + description: Check the row count diff for all table models. + type: row_count_diff + params: + select: state:modified,config.materialized:table +- name: Schema diff + description: Check the schema diff for all nodes. + type: schema_diff + params: + select: state:modified,config.materialized:table diff --git a/requirements.txt b/requirements.txt index 2e5cd51..8ea0581 100644 --- a/requirements.txt +++ b/requirements.txt @@ -249,7 +249,7 @@ pyyaml==6.0.1 # dbt-core # dbt-semantic-interfaces # pre-commit -recce==0.37.0 +recce~=0.37.0 # via -r requirements.in referencing==0.35.1 # via