Skip to content

Commit

Permalink
Add CircleCI config (#3)
Browse files Browse the repository at this point in the history
Start running integration tests in CircleCI.
  • Loading branch information
camphillips22 authored Aug 25, 2023
1 parent 212d27d commit 1395a34
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
123 changes: 123 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
version: 2.1

commands:
setup_job:
steps:
- checkout
- run:
name: "Generate cache key"
command: ./integration_tests/ci/checksum.sh

- restore_cache:
key: &deps1-cache deps1-{{ .Branch }}-{{ checksum "/tmp/checksum.txt" }}
- run:
name: "Setup profile"
command: |
mkdir -p ~/.dbt
cp integration_tests/ci/profiles.yml ~/.dbt/profiles.yml
- run:
name: "Setup BigQuery Credentials"
command: |
echo $BIGQUERY_SERVICE_ACCOUNT_JSON > ${HOME}/bigquery-service-key.json
jobs:
setup_commit:
docker:
- image: cimg/python:3.11.4
steps:
- setup_job

- run:
name: "Setup dbt"
command: |
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
cd integration_tests
dbt deps
- save_cache:
key: *deps1-cache
paths:
- "venv"
- "integration_tests/dbt_packages"

compile:
docker:
- image: cimg/python:3.11.4

steps:
- setup_job
- run:
name: "Compile - BigQuery"
environment:
BIGQUERY_SERVICE_KEY_PATH: "/home/circleci/bigquery-service-key.json"
command: |
. venv/bin/activate
echo `pwd`
cd integration_tests
dbt compile --target bigquery
- run:
name: "Compile - Snowflake"
command: |
. venv/bin/activate
echo `pwd`
cd integration_tests
dbt compile --target snowflake
bigquery_test:
docker:
- image: cimg/python:3.11.4
steps:
- setup_job

- run:
name: "Test - BigQuery"
environment:
BIGQUERY_SERVICE_KEY_PATH: "/home/circleci/bigquery-service-key.json"
command: |
. venv/bin/activate
echo `pwd`
cd integration_tests
dbt seed --target bigquery
dbt compile --target bigquery
dbt run --target bigquery
dbt test --target bigquery
snowflake_test:
docker:
- image: cimg/python:3.11.4
steps:
- setup_job

- run:
name: "Test - Snowflake"
command: |
. venv/bin/activate
echo `pwd`
cd integration_tests
dbt seed --target snowflake
dbt compile --target snowflake
dbt run --target snowflake
dbt test --target snowflake
workflows:
commit:
jobs:
- setup_commit
- compile:
requires:
- setup_commit
- wait_for_approval:
type: approval
requires:
- compile
- bigquery_test:
requires:
- wait_for_approval
- snowflake_test:
requires:
- wait_for_approval
1 change: 1 addition & 0 deletions integration_tests/ci/checksum.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find . '(' -name "packages.yml" -o -name "requirements.txt" ')' -not -path "./dbt_packages/*" -exec md5sum {} \; >/tmp/checksum.txt
26 changes: 26 additions & 0 deletions integration_tests/ci/profiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
config:
send_anonymous_usage_stats: False
use_colors: True

dbt_fullstory_integration_tests:
target: bigquery
outputs:
bigquery:
type: bigquery
method: service-account
keyfile: "{{ env_var('BIGQUERY_SERVICE_KEY_PATH') }}"
project: "{{ env_var('BIGQUERY_GCP_PROJECT') }}"
dataset: "dbt_fullstory_testing"
threads: 4
priority: interactive

snowflake:
type: snowflake
account: "{{ env_var('SNOWFLAKE_ACCOUNT') }}"
user: "{{ env_var('SNOWFLAKE_TEST_USER') }}"
password: "{{ env_var('SNOWFLAKE_TEST_PASSWORD') }}"
role: "{{ env_var('SNOWFLAKE_TEST_ROLE') }}"
database: "{{ env_var('SNOWFLAKE_TEST_DATABASE') }}"
warehouse: "{{ env_var('SNOWFLAKE_TEST_WAREHOUSE') }}"
schema: dbt_fullstory_testing
threads: 4

0 comments on commit 1395a34

Please sign in to comment.