Skip to content

Commit f42d47e

Browse files
authored
Merge pull request #8 from DataRecce/feature/drc-307-prepare-github-action-template-for-jaffle-shop-demo
[Feature] drc-307 prepare GitHub action template for jaffle shop demo
2 parents ea62d5d + fdd75a4 commit f42d47e

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

.github/workflows/dbt_base.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: DBT Base Environment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: DBT Runner
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: "3.10.x"
22+
23+
- name: Install dependencies
24+
run: |
25+
pip install -r requirements.txt
26+
27+
- name: Run DBT
28+
run: |
29+
dbt deps
30+
dbt seed --target ${{ env.DBT_BASE_TARGET }} --target-path target-base
31+
dbt run --target ${{ env.DBT_BASE_TARGET }} --target-path target-base
32+
dbt docs generate --target ${{ env.DBT_BASE_TARGET }} --target-path target-base
33+
env:
34+
DBT_BASE_TARGET: "prod"
35+
36+
- name: Package DBT artifacts
37+
run: |
38+
tar -czvf dbt-artifacts.tar.gz target-base ${{ env.DB_FILE }}
39+
mv dbt-artifacts.tar.gz $GITHUB_WORKSPACE/${{ github.sha }}.tar.gz
40+
env:
41+
DB_FILE: "jaffle_shop.duckdb"
42+
43+
- name: Upload to S3
44+
run: |
45+
aws s3 cp $GITHUB_WORKSPACE/${{ github.sha }}.tar.gz s3://${{ env.AWS_S3_BUCKET }}/${{ github.sha }}.tar.gz
46+
env:
47+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} # Set these in your repository secrets
48+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} # Set these in your repository secrets
49+
AWS_REGION: ${{ secrets.AWS_REGION }} # Set these in your repository secrets
50+
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} # Set these in your repository secrets

.github/workflows/recce_ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Jaffle Shop Recce CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
check-pull-request:
9+
name: Check pull request by Recce CI
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.10.x"
20+
- name: Install dependencies
21+
run: |
22+
pip install -r requirements.txt
23+
- name: Install Recce - Nightly
24+
run: |
25+
pip install recce-nightly
26+
- name: Prepare dbt Base environment
27+
run: |
28+
if aws s3 cp s3://$AWS_S3_BUCKET/${{ github.event.pull_request.base.sha }}.tar.gz .; then
29+
echo "Base environment found in S3"
30+
tar -xvf ${{ github.event.pull_request.base.sha }}.tar.gz
31+
else
32+
echo "Base environment not found in S3. Running dbt to create base environment"
33+
git checkout ${{ github.event.pull_request.base.sha }}
34+
dbt deps
35+
dbt seed --target ${{ env.DBT_BASE_TARGET }} --target-path target-base
36+
dbt run --target ${{ env.DBT_BASE_TARGET }} --target-path target-base
37+
dbt docs generate --target ${{ env.DBT_BASE_TARGET }} --target-path target-base
38+
fi
39+
env:
40+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
41+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
42+
AWS_REGION: ${{ secrets.AWS_REGION }}
43+
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
44+
DBT_BASE_TARGET: "prod"
45+
46+
- name: Prepare dbt Current environment
47+
run: |
48+
git checkout ${{ github.event.pull_request.head.sha }}
49+
dbt deps
50+
dbt seed --target ${{ env.DBT_CURRENT_TARGET}}
51+
dbt run --target ${{ env.DBT_CURRENT_TARGET}}
52+
dbt docs generate --target ${{ env.DBT_CURRENT_TARGET}}
53+
env:
54+
DBT_CURRENT_TARGET: "dev"
55+
56+
- name: Run Recce CI
57+
run: |
58+
recce run --github-pull-request-url ${{ github.event.pull_request.html_url }}
59+
60+
- name: Archive Recce State File
61+
uses: actions/upload-artifact@v4
62+
id: recce-artifact-uploader
63+
with:
64+
name: recce-state-file
65+
path: recce_state.json
66+
67+
- name: Comment on pull request
68+
uses: thollander/actions-comment-pull-request@v2
69+
with:
70+
message: |
71+
Recce `run` successfully completed.
72+
Please download the [artifact](${{ env.ARTIFACT_URL }}) for the state file.
73+
env:
74+
ARTIFACT_URL: ${{ steps.recce-artifact-uploader.outputs.artifact-url }}

0 commit comments

Comments
 (0)