Skip to content
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

Demo/bigquery pr #23

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/pr_job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: dbt pull request job

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- '!master' # TODO: change to your main branch name

env:
#TODO(developer): update PROJECT_ID
PROJECT_ID: "dbt-demo-386220"
DBT_PROFILES_DIR: ./
GOOGLE_APPLICATION_CREDENTIALS: ./service_account.json

jobs:
run:
runs-on: ubuntu-20.04
if: ${{ !github.event.pull_request.draft }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: checkout
uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: install requirements
run: pip install -q -r requirements.txt

- name: install datafold-sdk
run: pip install -q datafold-sdk

- name: Authenticate dbt to BigQuery
run: 'echo "$KEYFILE" > ./service_account.json' # persist file in root dir
shell: bash
env:
KEYFILE: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}} # TODO: add a github secret

- name: dbt deps
run: dbt deps

- name: Find Current Pull Request
uses: jwalton/[email protected]
id: findPR

- name: dbt build
run: dbt build --full-refresh --profiles-dir ./

# TODO: update the --config-id to your config id
- name: submit artifacts to datafold to compare to the production manifest
run: |
set -ex
datafold dbt upload --ci-config-id 272 --run-type ${DATAFOLD_RUN_TYPE} --commit-sha ${GIT_SHA}
env:
DATAFOLD_APIKEY: ${{ secrets.DATAFOLD_APIKEY }}
DATAFOLD_RUN_TYPE: "${{ 'pull_request' }}"
GIT_SHA: "${{ github.event.pull_request.head.sha }}"
2 changes: 1 addition & 1 deletion .github/workflows/prod_job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
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 }}"
GIT_SHA: "${{ github.ref == 'refs/heads/master' && github.sha || github.event.pull_request.head.sha }}" # TODO: update refs/heads/master for your main branch name
4 changes: 4 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ quoting:
identifier: true
schema: true # translates to gcp dataset

vars:
data_diff:
datasource_id: 6575

seeds:
jaffle_shop: # you must include the project name
# +project: lumpy-space-prince # if you want to create a model in a separate project
Expand Down
2 changes: 1 addition & 1 deletion models/core/fct_orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ final as (

)

select * from final
select * from final limit 10
2 changes: 1 addition & 1 deletion profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jaffle_shop:
type: bigquery
method: service-account # for production runs: https://docs.getdbt.com/docs/profile-bigquery#section-service-account-file-authentication
project: "{{ env_var('PROJECT_ID', 'dbt-demo-386220') }}" # parameterize project for dbt runs based on environment variable with default project
dataset: dbt_sung # You can also use "schema" here
dataset: "{{ env_var('SCHEMA_OVERRIDE', 'dbt_sung') }}" # You can also use "schema" here
threads: 24 # https://docs.getdbt.com/docs/configure-your-profile#section-understanding-threads
keyfile: "{{ env_var('GOOGLE_APPLICATION_CREDENTIALS', 'service_account.json') }}"
timeout_seconds: 300
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dbt-bigquery==1.6.5
dbt-bigquery==1.6.5
data-diff==0.8.4
Loading