Skip to content

Commit 968016d

Browse files
authored
Merge pull request #22 from techindicium/feature/testing-configs
Feature: testing README and configurations
2 parents ac1896e + 2885c9d commit 968016d

6 files changed

Lines changed: 105 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
elif [[ $BRANCH_NAME =~ ^(feature|minor|Feature|Minor)/ ]]; then
5050
VERSION_PARTS[1]=$((VERSION_PARTS[1] + 1))
5151
VERSION_PARTS[2]=0
52-
elif [[ $BRANCH_NAME =~ ^(patch|fix|hotfix|Patch|Fix|Hotfix)/ ]]; then
52+
elif [[ $BRANCH_NAME =~ ^(patch|fix|hotfix|bugfix|Patch|Fix|Hotfix|Bugfix)/ ]]; then
5353
VERSION_PARTS[2]=$((VERSION_PARTS[2] + 1))
5454
fi
5555
NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ integration_tests/logs/
22
integration_tests/target/
33
integration_tests/.env
44
integration_tests/.user.yml
5-
integration_tests/dbt_packages
5+
integration_tests/dbt_packages
6+
integration_tests/env
7+
integration_tests/package-lock.yml

README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,26 @@
44

55
This package allows you to easily monitor and manage your BigQuery query costs, identifying costly queries in order to enhance optimizing and resource saving.
66

7+
# Table of Contents
8+
9+
- [Before creating a branch](#Before-creating-a-branch)
10+
- [Quickstart](#:running:-Quickstart)
11+
- [Requirements](#Requirements)
12+
- [Installation](#Installation)
13+
- [Configuring package](#Configuring-models-package)
14+
- [Models](#Models)
15+
- [Vars](#Vars)
16+
- [Source](#Source)
17+
- [Running the models](#Running-the-models)
18+
- [Testing modifications in the project](#Testing-modifications-in-the-project)
19+
720
## Before creating a branch
821

922
Pay attention, it is very important to know if your modification to this repository is a release (breaking changes), a feature (functionalities) or a patch(to fix bugs). With that information, create your branch name like this:
1023

1124
- `release/<branch-name>` or `major/<branch-name>` or `Release/<branch-name>` or `Major/<branch-name>`
1225
- `feature/<branch-name>` or `minor/<branch-name>` with capitalised letters work as well
13-
- `patch/<branch-name>` or `fix/<branch-name>` or `hotfix/<branch-name>` with capitalised letters work as well
26+
- `patch/<branch-name>` or `fix/<branch-name>` or `hotfix/<branch-name>` or `bugfix/<branch-name>` with capitalised letters work as well
1427

1528
If branch is already made, just rename it _before passing the pull request_.
1629

@@ -37,7 +50,7 @@ packages:
3750

3851

3952

40-
## Configuring models package
53+
## Configuring package
4154

4255
The package's models can be configured in your `dbt_project.yml` by specifying the package under `models` node.
4356

@@ -81,12 +94,10 @@ vars:
8194
dbt_prod_monitoring_dataset: 'public_monitoring' # if you have one, add the destination dataset of your monitoring transformed data
8295
```
8396

84-
## Configuring project sources
97+
### Source
8598

8699
The project's sources can be configured in your `source.yml`, normally on your staging folder. Attention is needed while naming the source' schema and tables names to ensure you are matching the name BigQuery sets on the and schema and table with your source. If the names match, your package will work as expected.
87100

88-
### Source configuration
89-
90101
```yaml
91102
version: 2
92103
@@ -102,3 +113,29 @@ sources:
102113
## Running the models
103114

104115
After setting up the package in `dbt_project.yml` and `source.yml` as the previous steps, you can now run the package with the following command line: `dbt run -s bigquery_analytics`. After running it, the 5 models of the package will materialize in your target schema as they have been configured.
116+
117+
## Testing modifications in the project
118+
119+
Inside the integration_tests folder, you can use the setup.sh to auxiliate the creation of an env and installation of requirements.txt for you.
120+
121+
The only commands that you need to do is:
122+
123+
```chmod +x setup.sh```
124+
and
125+
```source setup.sh```
126+
127+
Inside the integration_tests folder, you have the dbt_project already configured, you have profiles.yml already set to BigQuery.
128+
To make a connection to BigQuery, so you can start testing, you should have credentials in indicium-sandbox project.
129+
130+
To set your credentials in your environment, you should rename the example.env:
131+
```example.env``` --> ```.env```.
132+
133+
You should put the name of your dataset
134+
135+
```dev_firstName_lastName```
136+
137+
and then do the command
138+
139+
```source .env```
140+
141+
Now you can use your credentials in your environment. Dbt debug it!

dbt_project.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,29 @@ clean-targets: ["target", "dbt_modules", "dbt_packages"]
1010
macro-paths: ["macros"]
1111
log-path: "logs"
1212

13-
vars:
14-
region: "region-us" ## vars to fit your use case
13+
# When running dbt-bigquery-analytics in your project, you must add the following configurations:
14+
15+
# models:
16+
# bigquery_analytics:
17+
# staging:
18+
# materialized: ephemeral
19+
# marts:
20+
# materialized: table
21+
22+
# vars:
23+
# dbt_bigquery_analytics:
24+
# bigquery_analytics_start_date: cast('2023-01-01' as date) # inside the double quotes, add the start date of the project
25+
# region: "region-us"
26+
# usd_dollars_real: 5.58 # here you can add the price of the dollar in reais
27+
# price_per_tib: 6.25 # here you can add the price per terabyte processed
28+
# price_per_tib_brl: 40.167405531
29+
# dbt_sources: [
30+
# 'adw'
31+
# , 'adf'
32+
# , 'databricks_workflow'
33+
# ] # you can configure the sources of your procject here
34+
# ci_dbt_target: 'ci' # add the CI/CD target of your dbt project
35+
# prod_dbt_target: 'prod' # add the development target of your dbt project
36+
# dev_dbt_target: 'dev' # add the production target of your dbt project
37+
# dbt_source_monitoring_dataset: 'raw_monitoring' # if you have one, add a source dataset of your monitoring data
38+
# dbt_prod_monitoring_dataset: 'public_monitoring' # if you have one, add the destination dataset of your monitoring transformed data

integration_tests/example.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export DBT_DEFAULT_TARGET="bigquery";
2+
export BIGQUERY_DATASET="";
3+
export BIGQUERY_PROJECT="indicium-sandbox";
4+
export DBT_JOB_TIMEOUT="300";
5+
export DBT_THREADS="16";
6+
export DBT_JOB_RETRIES="1";

integration_tests/setup.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
#if something goes wrong, stop the script
4+
set -e
5+
6+
# exports all variables in .env file. Any variable defined in the script will be available in the environment.
7+
set -a
8+
9+
# Install virtualenv if not installed
10+
pip install virtualenv
11+
12+
# Create a new virtual environment
13+
virtualenv env
14+
15+
# It gives permission to activate the virtual environment
16+
chmod +x env/bin/activate
17+
18+
# Activate the virtual environment
19+
source env/bin/activate # On Windows, use `env\Scripts\activate`
20+
21+
# # Load the environment variables
22+
source .env
23+
24+
# Install requirements
25+
pip install -r ../requirements.txt
26+
27+
dbt deps

0 commit comments

Comments
 (0)