Skip to content

Commit 3d47bdc

Browse files
authored
Merge pull request #316 from fishtown-analytics/update/circleci-workflows
Switch to CircleCI workflow
2 parents ac78d49 + 6d7ff51 commit 3d47bdc

File tree

4 files changed

+63
-26
lines changed

4 files changed

+63
-26
lines changed

.circleci/config.yml

+46-18
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11

2-
version: 2
2+
version: 2.1
33

44
jobs:
5-
build:
5+
6+
integration-postgres:
67
docker:
78
- image: circleci/python:3.6.3-stretch
89
- image: circleci/postgres:9.6.5-alpine-ram
910

1011
steps:
1112
- checkout
12-
13-
- run:
14-
run: setup_creds
15-
command: |
16-
echo $BIGQUERY_SERVICE_ACCOUNT_JSON > ${HOME}/bigquery-service-key.json
17-
18-
- restore_cache:
19-
key: deps2-{{ .Branch }}
20-
2113
- run:
2214
name: "Run Tests - Postgres"
2315
environment:
@@ -27,22 +19,58 @@ jobs:
2719
POSTGRES_TEST_PORT: 5432
2820
POSTGRES_TEST_DBNAME: circle_test
2921
command: ./run_test.sh postgres
22+
- store_artifacts:
23+
path: ./logs
3024

25+
integration-redshift:
26+
docker:
27+
- image: circleci/python:3.6.3-stretch
28+
steps:
29+
- checkout
3130
- run:
3231
name: "Run Tests - Redshift"
3332
command: ./run_test.sh redshift
33+
- store_artifacts:
34+
path: ./logs
3435

36+
integration-snowflake:
37+
docker:
38+
- image: circleci/python:3.6.3-stretch
39+
steps:
40+
- checkout
3541
- run:
3642
name: "Run Tests - Snowflake"
3743
command: ./run_test.sh snowflake
38-
44+
- store_artifacts:
45+
path: ./logs
46+
47+
integration-bigquery:
48+
environment:
49+
BIGQUERY_SERVICE_KEY_PATH: "/home/circleci/bigquery-service-key.json"
50+
docker:
51+
- image: circleci/python:3.6.3-stretch
52+
steps:
53+
- checkout
54+
- run:
55+
name: "Set up credentials"
56+
command: echo $BIGQUERY_SERVICE_ACCOUNT_JSON > ${HOME}/bigquery-service-key.json
3957
- run:
4058
name: "Run Tests - BigQuery"
41-
environment:
42-
BIGQUERY_SERVICE_KEY_PATH: "/home/circleci/bigquery-service-key.json"
4359
command: ./run_test.sh bigquery
60+
- store_artifacts:
61+
path: ./logs
4462

45-
- save_cache:
46-
key: deps1-{{ .Branch }}
47-
paths:
48-
- "venv"
63+
workflows:
64+
version: 2
65+
test-all:
66+
jobs:
67+
- integration-postgres
68+
- integration-redshift:
69+
requires:
70+
- integration-postgres
71+
- integration-snowflake:
72+
requires:
73+
- integration-postgres
74+
- integration-bigquery:
75+
requires:
76+
- integration-postgres

integration_tests/ci/sample.profiles.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ integration_tests:
1717
port: "{{ env_var('POSTGRES_TEST_PORT') | as_number }}"
1818
dbname: "{{ env_var('POSTGRES_TEST_DBNAME') }}"
1919
schema: dbt_utils_integration_tests_postgres
20-
threads: 1
20+
threads: 5
2121

2222
redshift:
2323
type: redshift
@@ -27,15 +27,15 @@ integration_tests:
2727
dbname: "{{ env_var('REDSHIFT_TEST_DBNAME') }}"
2828
port: "{{ env_var('REDSHIFT_TEST_PORT') | as_number }}"
2929
schema: dbt_utils_integration_tests_redshift
30-
threads: 1
30+
threads: 5
3131

3232
bigquery:
3333
type: bigquery
3434
method: service-account
3535
keyfile: "{{ env_var('BIGQUERY_SERVICE_KEY_PATH') }}"
3636
project: "{{ env_var('BIGQUERY_TEST_DATABASE') }}"
3737
schema: dbt_utils_integration_tests_bigquery
38-
threads: 1
38+
threads: 10
3939

4040
snowflake:
4141
type: snowflake
@@ -46,4 +46,4 @@ integration_tests:
4646
database: "{{ env_var('SNOWFLAKE_TEST_DATABASE') }}"
4747
warehouse: "{{ env_var('SNOWFLAKE_TEST_WAREHOUSE') }}"
4848
schema: dbt_utils_integration_tests_snowflake
49-
threads: 1
49+
threads: 10

macros/materializations/insert_by_period_materialization.sql

+8-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@
142142
from {{tmp_relation.include(schema=False)}}
143143
);
144144
{%- endcall %}
145-
{%- set rows_inserted = (load_result('main-' ~ i)['status'].split(" "))[2] | int -%}
145+
{% set result = load_result('main-' ~ i) %}
146+
{% if 'response' in result.keys() %} {# added in v0.19.0 #}
147+
{% set rows_inserted = result['response']['rows_affected'] %}
148+
{% else %} {# older versions #}
149+
{% set rows_inserted = result['status'].split(" ")[2] | int %}
150+
{% endif %}
151+
146152
{%- set sum_rows_inserted = loop_vars['sum_rows_inserted'] + rows_inserted -%}
147153
{%- if loop_vars.update({'sum_rows_inserted': sum_rows_inserted}) %} {% endif -%}
148154

@@ -165,7 +171,7 @@
165171

166172
{%- set status_string = "INSERT " ~ loop_vars['sum_rows_inserted'] -%}
167173

168-
{% call noop_statement(name='main', status=status_string) -%}
174+
{% call noop_statement('main', status_string) -%}
169175
-- no-op
170176
{%- endcall %}
171177

run_test.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ if [[ ! -z $3 ]]; then _seeds="--select $3 --full-refresh"; fi
2424

2525
dbt deps --target $1
2626
dbt seed --target $1 $_seeds
27-
dbt run --target $1 $_models
28-
dbt test --target $1 $_models
27+
if [ $1 == 'redshift' ]; then
28+
dbt run -x -m test_insert_by_period --full-refresh --target redshift
29+
fi
30+
dbt run -x --target $1 $_models
31+
dbt test -x --target $1 $_models

0 commit comments

Comments
 (0)