-
Notifications
You must be signed in to change notification settings - Fork 214
Modernize test-github-action.yml to use e2e_dbt_project and latest action version #2131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1ea66b3
eb9e013
0e4b517
27d1b3b
3e38a97
aa4030b
e8570d4
deaf6ae
bece96e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| name: Test elementary GitHub action | ||
| on: | ||
| pull_request: | ||
| schedule: | ||
| - cron: "0 0 * * *" | ||
| workflow_dispatch: | ||
|
|
@@ -16,16 +17,26 @@ on: | |
| type: string | ||
| required: false | ||
| description: dbt's version to test with | ||
| generate-data: | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| description: Whether to generate new data | ||
|
|
||
| env: | ||
| DBT_PKG_INTEG_TESTS_DIR: ${{ github.workspace }}/dbt-data-reliability/integration_tests/deprecated_tests | ||
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
| ELEMENTARY_DBT_PACKAGE_PATH: ${{ github.workspace }}/dbt-data-reliability | ||
| E2E_DBT_PROJECT_DIR: ${{ github.workspace }}/elementary/tests/e2e_dbt_project | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: elementary | ||
| concurrency: | ||
| group: test_action_snowflake_dbt_${{ inputs.dbt-version }}_${{ github.head_ref || github.ref_name }} | ||
| cancel-in-progress: true | ||
| steps: | ||
| - name: Checkout Elementary | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -40,29 +51,39 @@ jobs: | |
| path: dbt-data-reliability | ||
| ref: ${{ inputs.dbt-data-reliability-ref }} | ||
|
|
||
| - name: Write dbt profiles | ||
| id: profiles | ||
| env: | ||
| PROFILES_YML: ${{ secrets.TEST_GITHUB_ACTION_PROFILES_YML }} | ||
| run: | | ||
| mkdir -p ~/.dbt | ||
| echo "$PROFILES_YML" > ~/.dbt/profiles.yml | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Install dbt | ||
| run: pip install --pre | ||
| run: > | ||
| pip install | ||
| "dbt-core${{ inputs.dbt-version && format('=={0}', inputs.dbt-version) }}" | ||
| "dbt-snowflake${{ inputs.dbt-version && format('<={0}', inputs.dbt-version) }}" | ||
| "dbt-snowflake${{ inputs.dbt-version && format('~={0}', inputs.dbt-version) }}" | ||
|
|
||
| - name: Install Elementary | ||
| run: | | ||
| pip install -r dev-requirements.txt | ||
| pip install ".[snowflake]" | ||
|
|
||
| - name: Write dbt profiles | ||
| env: | ||
| CI_WAREHOUSE_SECRETS: ${{ secrets.CI_WAREHOUSE_SECRETS || '' }} | ||
| run: | | ||
| CONCURRENCY_GROUP="test_action_snowflake_dbt_${{ inputs.dbt-version }}_${BRANCH_NAME}" | ||
| SHORT_HASH=$(echo -n "$CONCURRENCY_GROUP" | sha256sum | head -c 8) | ||
| SAFE_BRANCH=$(echo "${BRANCH_NAME}" | awk '{print tolower($0)}' | sed "s/[^a-z0-9]/_/g; s/__*/_/g" | head -c 19) | ||
| DATE_STAMP=$(date -u +%y%m%d_%H%M%S) | ||
| SCHEMA_NAME="ga_${DATE_STAMP}_${SAFE_BRANCH}_${SHORT_HASH}" | ||
|
|
||
| echo "Schema name: $SCHEMA_NAME (branch='${BRANCH_NAME}', timestamp=${DATE_STAMP}, hash of concurrency group)" | ||
|
|
||
| python "${{ github.workspace }}/elementary/tests/profiles/generate_profiles.py" \ | ||
| --template "${{ github.workspace }}/elementary/tests/profiles/profiles.yml.j2" \ | ||
| --output ~/.dbt/profiles.yml \ | ||
| --schema-name "$SCHEMA_NAME" | ||
|
Comment on lines
+71
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fail fast if warehouse secrets are missing. Line 72 defaults Suggested change - name: Write dbt profiles
env:
CI_WAREHOUSE_SECRETS: ${{ secrets.CI_WAREHOUSE_SECRETS || '' }}
run: |
+ if [ -z "$CI_WAREHOUSE_SECRETS" ]; then
+ echo "::error::CI_WAREHOUSE_SECRETS is not set"
+ exit 1
+ fi
+
CONCURRENCY_GROUP="test_action_snowflake_dbt_${{ inputs.dbt-version }}_${BRANCH_NAME}"
SHORT_HASH=$(echo -n "$CONCURRENCY_GROUP" | sha256sum | head -c 8)
SAFE_BRANCH=$(echo "${BRANCH_NAME}" | awk '{print tolower($0)}' | sed "s/[^a-z0-9]/_/g; s/__*/_/g" | head -c 19)🤖 Prompt for AI Agents |
||
|
|
||
| - name: Install dbt package | ||
| run: | | ||
| ELEMENTARY_PKG_LOCATION=$(pip show elementary-data | grep -i location | awk '{print $2}') | ||
|
|
@@ -72,21 +93,69 @@ jobs: | |
| rm -rf "$DBT_PKGS_PATH/elementary" | ||
| ln -vs "$GITHUB_WORKSPACE/dbt-data-reliability" "$DBT_PKGS_PATH/elementary" | ||
|
|
||
| - name: Run dbt package integration tests | ||
| working-directory: ${{ env.DBT_PKG_INTEG_TESTS_DIR }} | ||
| - name: Run deps for E2E dbt project | ||
| working-directory: ${{ env.E2E_DBT_PROJECT_DIR }} | ||
| env: | ||
| ELEMENTARY_DBT_PACKAGE_PATH: ${{ env.ELEMENTARY_DBT_PACKAGE_PATH }} | ||
| run: | | ||
| dbt deps | ||
| python run_e2e_tests.py -t "snowflake" --clear-tests "True" -e "regular" | ||
|
|
||
| - name: Seed e2e dbt project | ||
| working-directory: ${{ env.E2E_DBT_PROJECT_DIR }} | ||
| if: inputs.generate-data | ||
| run: | | ||
| python generate_data.py | ||
| dbt seed -f --target snowflake | ||
|
|
||
|
Comment on lines
+102
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because Line 105 gates the whole step, Suggested change - name: Seed e2e dbt project
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
- if: inputs.generate-data
run: |
- python generate_data.py
+ if [ "${{ inputs.generate-data }}" = "true" ]; then
+ python generate_data.py
+ fi
dbt seed -f --target snowflake🤖 Prompt for AI Agents |
||
| - name: Run e2e dbt project | ||
| working-directory: ${{ env.E2E_DBT_PROJECT_DIR }} | ||
| run: | | ||
| dbt run --target snowflake || true | ||
|
|
||
| # Validate run_results.json: only error_model should be non-success | ||
| jq -e ' | ||
| [.results[] | select(.status != "success") | .unique_id] | ||
| | length == 1 and .[0] == "model.elementary_integration_tests.error_model" | ||
| ' target/run_results.json > /dev/null | ||
| jq_exit=$? | ||
|
|
||
| if [ $jq_exit -eq 0 ]; then | ||
| echo "Validation passed: only error_model failed." | ||
| else | ||
| echo "Validation failed. Unexpected failures:" | ||
| jq '[.results[] | select(.status != "success") | .unique_id] | join(", ")' target/run_results.json | ||
| fi | ||
|
|
||
| exit $jq_exit | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Test e2e dbt project | ||
| working-directory: ${{ env.E2E_DBT_PROJECT_DIR }} | ||
| continue-on-error: true | ||
| run: | | ||
| dbt test --target snowflake | ||
|
|
||
| - name: Read generated profiles | ||
| id: profiles | ||
| run: | | ||
| { | ||
| echo "profiles_yml<<EOFPROFILES" | ||
| cat ~/.dbt/profiles.yml | ||
| echo "EOFPROFILES" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: Run Elementary | ||
| uses: elementary-data/run-elementary-action@v1.8 | ||
| uses: elementary-data/run-elementary-action@v1.12 | ||
| with: | ||
| warehouse-type: snowflake | ||
| profiles-yml: ${{ secrets.TEST_GITHUB_ACTION_PROFILES_YML }} | ||
| edr-command: | ||
| edr monitor -t "snowflake" --slack-token "${{ secrets.CI_SLACK_TOKEN }}" --slack-channel-name data-ops | ||
| profile-target: snowflake | ||
| profiles-yml: ${{ steps.profiles.outputs.profiles_yml }} | ||
| edr-command: > | ||
| edr monitor | ||
| -t snowflake | ||
| --slack-token "${{ secrets.CI_SLACK_TOKEN }}" | ||
| --slack-channel-name data-ops | ||
| && | ||
| edr report | ||
| edr monitor report | ||
| --file-path "report.html" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: Upload report | ||
|
|
@@ -102,6 +171,13 @@ jobs: | |
| name: edr.log | ||
| path: edr_target/edr.log | ||
|
|
||
| - name: Drop test schemas | ||
| if: always() | ||
| working-directory: ${{ env.E2E_DBT_PROJECT_DIR }} | ||
| continue-on-error: true | ||
| run: | | ||
| dbt run-operation elementary_integration_tests.drop_test_schemas --target snowflake | ||
|
|
||
| notify_failures: | ||
| name: Notify Slack | ||
| needs: test | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
pull_requesttrigger before merging.As noted in the PR objectives, this trigger is temporary for CI validation and must be removed before merge to avoid running this workflow on every PR.
🤖 Prompt for AI Agents