-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add source contract tests * Fix source contract test Improved setup instructions * Upgrade to dbt 1.5 Upgrade dbt dependencies * Add model contract for mart model * Add support for Github Codespaces * Fix Github Codespaces name * Add initial CD pipeline definition * Add debug connection step to the pipeline * Inject postgres configuration via configuration variables and secrets * Change CI config to run unit and component tests * Run tests against test postgres database * Add pipeline job to deploy to test environment * Fix deploy to test job to deploy with any branch * Add missing install dependencies step in deployment job * Extract deployment job into a reusable workflow * Associate specific Github environment to the deployment * Split deployment workflow into multiple jobs
- Loading branch information
Showing
15 changed files
with
242 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "Python 3", | ||
"dockerComposeFile": "../docker-compose.yml", | ||
"service": "devcontainer", | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
"postCreateCommand": "pip3 install --user -r requirements.txt", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "zsh" | ||
}, | ||
"extensions": [ | ||
"GitHub.codespaces" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: CD Pipeline | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/dbt-labs/dbt-postgres:1.6.3 | ||
env: | ||
POSTGRES_HOST: ${{ vars.POSTGRES_HOST }} | ||
POSTGRES_USER: ${{ vars.POSTGRES_USER }} | ||
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
POSTGRES_DB: ${{ vars.POSTGRES_DB }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: | | ||
dbt deps | ||
- name: Run unit tests | ||
run: | | ||
dbt test --target test --select tag:unit-test | ||
- name: Run component tests | ||
run: | | ||
dbt test --target test --select tag:unit-test | ||
deploy-test: | ||
name: Deploy to test | ||
needs: [test] | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment-name: test | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Deploy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment-name: | ||
required: true | ||
type: string | ||
|
||
env: | ||
POSTGRES_HOST: ${{ vars.POSTGRES_HOST }} | ||
POSTGRES_USER: ${{ vars.POSTGRES_USER }} | ||
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
POSTGRES_DB: ${{ vars.POSTGRES_DB }} | ||
|
||
jobs: | ||
seed-source-tables: | ||
name: Seed source tables | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment-name }} | ||
container: | ||
image: ghcr.io/dbt-labs/dbt-postgres:1.6.3 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: | | ||
dbt deps | ||
- name: Run seeds | ||
run: | | ||
dbt seed --target ${{ inputs.environment-name }} | ||
source-contract-tests: | ||
name: Run source contract tests | ||
needs: [seed-source-tables] | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment-name }} | ||
container: | ||
image: ghcr.io/dbt-labs/dbt-postgres:1.6.3 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: | | ||
dbt deps | ||
- name: Run seeds | ||
run: | | ||
dbt seed --target ${{ inputs.environment-name }}\ | ||
- name: Run source contract tests | ||
run: | | ||
dbt test --target ${{ inputs.environment-name }} --select tag:contract-test-source | ||
deploy: | ||
name: Deploy | ||
needs: [source-contract-tests] | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment-name }} | ||
container: | ||
image: ghcr.io/dbt-labs/dbt-postgres:1.6.3 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: | | ||
dbt deps | ||
- name: Run data transformations | ||
run: | | ||
dbt run --target ${{ inputs.environment-name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ target/ | |
dbt_packages/ | ||
logs/ | ||
dbt | ||
profiles.yml | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
version: '3.1' | ||
version: '3.8' | ||
|
||
services: | ||
devcontainer: | ||
image: mcr.microsoft.com/devcontainers/python:0-3.10-bullseye | ||
volumes: | ||
- .:/workspaces:cached | ||
network_mode: service:db | ||
command: sleep infinity | ||
|
||
db: | ||
image: postgres | ||
restart: always | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
POSTGRES_PASSWORD: example | ||
|
||
adminer: | ||
image: adminer | ||
restart: always | ||
ports: | ||
- 8080:8080 | ||
network_mode: service:db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: gym_app | ||
schema: dbt_testing_example | ||
tables: | ||
- name: raw_height | ||
tags: ["data-quality", "contract-test-source"] | ||
columns: | ||
- name: height_unit | ||
tests: | ||
- dbt_expectations.expect_column_values_to_be_of_type: | ||
column_type: text | ||
- accepted_values: | ||
values: ["cm", "inches"] | ||
- name: user_id | ||
tests: | ||
- not_null | ||
- dbt_expectations.expect_column_values_to_be_of_type: | ||
column_type: integer | ||
- name: height | ||
tests: | ||
- not_null | ||
- dbt_expectations.expect_column_values_to_be_of_type: | ||
column_type: double precision | ||
- dbt_utils.accepted_range: | ||
min_value: 0 | ||
inclusive: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: gym_app | ||
schema: dbt_testing_example | ||
tables: | ||
- name: raw_weight | ||
tags: ["data-quality", "contract-test-source"] | ||
columns: | ||
- name: measurement_unit | ||
tests: | ||
- dbt_expectations.expect_column_values_to_be_of_type: | ||
column_type: text | ||
- accepted_values: | ||
values: ["kg", "pounds"] | ||
- name: user_id | ||
tests: | ||
- not_null | ||
- dbt_expectations.expect_column_values_to_be_of_type: | ||
column_type: integer | ||
- name: weight | ||
tests: | ||
- not_null | ||
- dbt_expectations.expect_column_values_to_be_of_type: | ||
column_type: double precision | ||
- dbt_utils.accepted_range: | ||
min_value: 0 | ||
inclusive: false |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
packages: | ||
- package: dbt-labs/dbt_utils | ||
version: 1.0.0 | ||
version: 1.1.1 | ||
|
||
- package: calogica/dbt_expectations | ||
version: 0.8.5 | ||
|
||
- git: "https://github.com/EqualExperts/dbt-unit-testing" | ||
revision: v0.2.6 | ||
revision: v0.2.7 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
dbt_testing_example: | ||
target: dev | ||
outputs: | ||
dev: | ||
type: postgres | ||
host: localhost | ||
user: postgres | ||
password: "{{ env_var('POSTGRES_PASSWORD') }}" | ||
port: 5432 | ||
dbname: postgres | ||
schema: dbt_testing_example | ||
threads: 4 | ||
test: | ||
type: postgres | ||
host: "{{ env_var('POSTGRES_HOST') }}" | ||
user: "{{ env_var('POSTGRES_USER') }}" | ||
password: "{{ env_var('POSTGRES_PASSWORD') }}" | ||
port: 5432 | ||
dbname: "{{ env_var('POSTGRES_DB') }}" | ||
schema: dbt_testing_example | ||
threads: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dbt-postgres |