From 0bcd26fe3b9a02342e94bab9e664a16114c10574 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Thu, 9 Jun 2022 01:23:36 +0300 Subject: [PATCH 1/2] Build and send prod manifest on each PR It guarantees that for each PR we'll always have corresponding prod manifest. That's especially important if prod build runs on long cadence. --- .github/workflows/dbt.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/dbt.yml b/.github/workflows/dbt.yml index 576d33a..e19de88 100644 --- a/.github/workflows/dbt.yml +++ b/.github/workflows/dbt.yml @@ -16,6 +16,10 @@ jobs: steps: - name: checkout uses: actions/checkout@v2 + with: + # We need to checkout full git tree to be able to find and checkout + # the merge-base. By default the action checks out only PR HEAD commit. + fetch-depth: 0 - uses: actions/setup-python@v2 with: @@ -47,10 +51,29 @@ jobs: run: | set -ex datafold dbt upload --ci-config-id 77 --run-type ${DATAFOLD_RUN_TYPE} --target-folder ./target/ --commit-sha ${GIT_SHA} + + # Switch to "merge base" commit + export PR_COMMIT=$(git rev-parse HEAD) + export MERGE_BASE=$(git merge-base origin/master HEAD) + echo "merge base is $MERGE_BASE" + git checkout $MERGE_BASE + + # Do compile of the "merge base" in prod environment + export SNOWFLAKE_SCHEMA=BEERS + dbt compile --full-refresh --profiles-dir ./ + datafold dbt upload --ci-config-id 77 --run-type production --target-folder ./target/ --commit-sha ${MERGE_BASE} + + # Switch back to the HEAD of the current PR in case later stages + # do something with the repo. + git checkout $PR_COMMIT env: DATAFOLD_APIKEY: ${{ secrets.DATAFOLD_APIKEY }} DATAFOLD_RUN_TYPE: "${{ github.ref == 'refs/heads/master' && 'production' || 'pull_request' }}" GIT_SHA: "${{ github.ref == 'refs/heads/master' && github.sha || github.event.pull_request.head.sha }}" + SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + SNOWFLAKE_SCHEMA: "${{ github.ref == 'refs/heads/master' && 'BEERS' || 'BEERS_DEV' }}" - name: dbt test run: dbt test --profiles-dir ./ From da6e666f6a2ec72f1e1784123397959bb723d47f Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Thu, 9 Jun 2022 02:30:22 +0300 Subject: [PATCH 2/2] et's increase the price --- models/beers/sales.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/beers/sales.sql b/models/beers/sales.sql index 4f5779e..9baa0dd 100644 --- a/models/beers/sales.sql +++ b/models/beers/sales.sql @@ -23,7 +23,7 @@ SELECT order_lines.order_line AS order_line, orders.created_at AS order_created_at, order_lines.quantity AS order_li_quantity, - order_lines.price AS order_li_price_each, + order_lines.price + 1 AS order_li_price_each, order_lines.quantity * order_lines.price AS order_li_price_total FROM {{ ref('orders') }} orders