Skip to content

Commit 746ce41

Browse files
Modernize test-github-action.yml to use e2e_dbt_project and latest action version (#2131)
* Modernize test-github-action.yml to use e2e_dbt_project - Replace deprecated dbt-data-reliability integration tests with the newer e2e_dbt_project (matching test-warehouse.yml approach) - Use generate_profiles.py + profiles.yml.j2 instead of the TEST_GITHUB_ACTION_PROFILES_YML secret - Update run-elementary-action from v1.8 to v1.12 - Add concurrency management and schema cleanup - Add generate-data workflow input - Temporarily add pull_request trigger for CI testing Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Add masking for profiles.yml credentials in GITHUB_OUTPUT Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Fix jq validation to work correctly under bash -e Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Temporarily point action at Python 3.10 fix branch The run-elementary-action Docker image uses Python 3.9, but elementary-data 0.22.0 dropped Python 3.9 support. Point at the fix branch (devin/1772355616-fix-python-version) which updates the Dockerfile to Python 3.10. This should be updated to the new release tag once elementary-data/run-elementary-action#15 is merged and tagged. Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Update run-elementary-action to v1.13 (with Python 3.10 fix) Replace temporary branch reference with the official v1.13 release tag which includes the Python 3.10 Dockerfile fix. Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Add -t snowflake to edr monitor report command Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Remove temporary pull_request trigger Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Remove Notify Slack job Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Itamar Hartstein <haritamar@gmail.com>
1 parent 8f2d7a9 commit 746ce41

1 file changed

Lines changed: 94 additions & 33 deletions

File tree

.github/workflows/test-github-action.yml

Lines changed: 94 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,26 @@ on:
1616
type: string
1717
required: false
1818
description: dbt's version to test with
19+
generate-data:
20+
type: boolean
21+
required: false
22+
default: false
23+
description: Whether to generate new data
1924

2025
env:
21-
DBT_PKG_INTEG_TESTS_DIR: ${{ github.workspace }}/dbt-data-reliability/integration_tests/deprecated_tests
26+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
27+
ELEMENTARY_DBT_PACKAGE_PATH: ${{ github.workspace }}/dbt-data-reliability
28+
E2E_DBT_PROJECT_DIR: ${{ github.workspace }}/elementary/tests/e2e_dbt_project
2229

2330
jobs:
2431
test:
2532
runs-on: ubuntu-latest
2633
defaults:
2734
run:
2835
working-directory: elementary
36+
concurrency:
37+
group: test_action_snowflake_dbt_${{ inputs.dbt-version }}_${{ github.head_ref || github.ref_name }}
38+
cancel-in-progress: true
2939
steps:
3040
- name: Checkout Elementary
3141
uses: actions/checkout@v4
@@ -40,29 +50,39 @@ jobs:
4050
path: dbt-data-reliability
4151
ref: ${{ inputs.dbt-data-reliability-ref }}
4252

43-
- name: Write dbt profiles
44-
id: profiles
45-
env:
46-
PROFILES_YML: ${{ secrets.TEST_GITHUB_ACTION_PROFILES_YML }}
47-
run: |
48-
mkdir -p ~/.dbt
49-
echo "$PROFILES_YML" > ~/.dbt/profiles.yml
50-
5153
- name: Setup Python
5254
uses: actions/setup-python@v5
5355
with:
5456
python-version: "3.10"
5557

5658
- name: Install dbt
57-
run: pip install --pre
59+
run: >
60+
pip install
5861
"dbt-core${{ inputs.dbt-version && format('=={0}', inputs.dbt-version) }}"
59-
"dbt-snowflake${{ inputs.dbt-version && format('<={0}', inputs.dbt-version) }}"
62+
"dbt-snowflake${{ inputs.dbt-version && format('~={0}', inputs.dbt-version) }}"
6063
6164
- name: Install Elementary
6265
run: |
6366
pip install -r dev-requirements.txt
6467
pip install ".[snowflake]"
6568
69+
- name: Write dbt profiles
70+
env:
71+
CI_WAREHOUSE_SECRETS: ${{ secrets.CI_WAREHOUSE_SECRETS || '' }}
72+
run: |
73+
CONCURRENCY_GROUP="test_action_snowflake_dbt_${{ inputs.dbt-version }}_${BRANCH_NAME}"
74+
SHORT_HASH=$(echo -n "$CONCURRENCY_GROUP" | sha256sum | head -c 8)
75+
SAFE_BRANCH=$(echo "${BRANCH_NAME}" | awk '{print tolower($0)}' | sed "s/[^a-z0-9]/_/g; s/__*/_/g" | head -c 19)
76+
DATE_STAMP=$(date -u +%y%m%d_%H%M%S)
77+
SCHEMA_NAME="ga_${DATE_STAMP}_${SAFE_BRANCH}_${SHORT_HASH}"
78+
79+
echo "Schema name: $SCHEMA_NAME (branch='${BRANCH_NAME}', timestamp=${DATE_STAMP}, hash of concurrency group)"
80+
81+
python "${{ github.workspace }}/elementary/tests/profiles/generate_profiles.py" \
82+
--template "${{ github.workspace }}/elementary/tests/profiles/profiles.yml.j2" \
83+
--output ~/.dbt/profiles.yml \
84+
--schema-name "$SCHEMA_NAME"
85+
6686
- name: Install dbt package
6787
run: |
6888
ELEMENTARY_PKG_LOCATION=$(pip show elementary-data | grep -i location | awk '{print $2}')
@@ -72,21 +92,70 @@ jobs:
7292
rm -rf "$DBT_PKGS_PATH/elementary"
7393
ln -vs "$GITHUB_WORKSPACE/dbt-data-reliability" "$DBT_PKGS_PATH/elementary"
7494
75-
- name: Run dbt package integration tests
76-
working-directory: ${{ env.DBT_PKG_INTEG_TESTS_DIR }}
95+
- name: Run deps for E2E dbt project
96+
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
97+
env:
98+
ELEMENTARY_DBT_PACKAGE_PATH: ${{ env.ELEMENTARY_DBT_PACKAGE_PATH }}
7799
run: |
78100
dbt deps
79-
python run_e2e_tests.py -t "snowflake" --clear-tests "True" -e "regular"
101+
102+
- name: Seed e2e dbt project
103+
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
104+
if: inputs.generate-data
105+
run: |
106+
python generate_data.py
107+
dbt seed -f --target snowflake
108+
109+
- name: Run e2e dbt project
110+
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
111+
run: |
112+
dbt run --target snowflake || true
113+
114+
# Validate run_results.json: only error_model should be non-success
115+
if jq -e '
116+
[.results[] | select(.status != "success") | .unique_id]
117+
| length == 1 and .[0] == "model.elementary_integration_tests.error_model"
118+
' target/run_results.json > /dev/null; then
119+
echo "Validation passed: only error_model failed."
120+
else
121+
echo "Validation failed. Unexpected failures:"
122+
jq '[.results[] | select(.status != "success") | .unique_id] | join(", ")' target/run_results.json
123+
exit 1
124+
fi
125+
126+
- name: Test e2e dbt project
127+
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
128+
continue-on-error: true
129+
run: |
130+
dbt test --target snowflake
131+
132+
- name: Read generated profiles
133+
id: profiles
134+
run: |
135+
# Mask credentials so they don't appear in logs
136+
while IFS= read -r line; do
137+
echo "::add-mask::$line"
138+
done < ~/.dbt/profiles.yml
139+
{
140+
echo "profiles_yml<<EOFPROFILES"
141+
cat ~/.dbt/profiles.yml
142+
echo "EOFPROFILES"
143+
} >> "$GITHUB_OUTPUT"
80144
81145
- name: Run Elementary
82-
uses: elementary-data/run-elementary-action@v1.8
146+
uses: elementary-data/run-elementary-action@v1.13
83147
with:
84148
warehouse-type: snowflake
85-
profiles-yml: ${{ secrets.TEST_GITHUB_ACTION_PROFILES_YML }}
86-
edr-command:
87-
edr monitor -t "snowflake" --slack-token "${{ secrets.CI_SLACK_TOKEN }}" --slack-channel-name data-ops
149+
profile-target: snowflake
150+
profiles-yml: ${{ steps.profiles.outputs.profiles_yml }}
151+
edr-command: >
152+
edr monitor
153+
-t snowflake
154+
--slack-token "${{ secrets.CI_SLACK_TOKEN }}"
155+
--slack-channel-name data-ops
88156
&&
89-
edr report
157+
edr monitor report
158+
-t snowflake
90159
--file-path "report.html"
91160
92161
- name: Upload report
@@ -102,17 +171,9 @@ jobs:
102171
name: edr.log
103172
path: edr_target/edr.log
104173

105-
notify_failures:
106-
name: Notify Slack
107-
needs: test
108-
if: |
109-
always() &&
110-
! cancelled() &&
111-
! contains(needs.test.result, 'success') &&
112-
! contains(needs.test.result, 'cancelled') &&
113-
${{ github.event_name == 'schedule' }}
114-
uses: ./.github/workflows/notify_slack.yml
115-
with:
116-
result: "failure"
117-
run_id: ${{ github.run_id }}
118-
workflow_name: "Test Elementary GitHub action"
174+
- name: Drop test schemas
175+
if: always()
176+
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
177+
continue-on-error: true
178+
run: |
179+
dbt run-operation elementary_integration_tests.drop_test_schemas --target snowflake

0 commit comments

Comments
 (0)