Skip to content

Commit

Permalink
Fix Check Artifact Changes Action (#9635)
Browse files Browse the repository at this point in the history
* Remove extraneous `/` in `schema-check.yml`

We have hypothesis that the extra `/` in `schema-check` is causing
issues we're seeing currently in the artifact check failing. It may
not be the final solution, but we should fix it anyway.

* Move `artifact_minor_upgrade` label check to job level of `Check Artifact Changes`

Previously the checking for `artifact_minor_upgrade` was happening in each job
step of `Check Artifact Changes`. By moving it up to the job level instead of
in the job steps we make it so the check for the label only happens once and
it simplifies the job steps.

* Update `Check Artifact Changes` to use `dorny/paths-filter`

Previously we were using `git diff` to check if any files had changed
in `core/dbt/artifacts`. However, our `git diff` usage was including any
changes that happened on `main` which the PR branch did not have. This
commit switches the check from using `git diff` to `dorny/paths-filter`,
which is what we use for checking for changelog existence as well. The
`dorny/paths-fitler` includes logic for excluding changes that are on main
but not the PR branch (which is what want to happen).
  • Loading branch information
QMalcolm authored Feb 23, 2024
1 parent 83e5161 commit 9bc80d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/check-artifact-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,32 @@ on:
jobs:
check-artifact-changes:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'artifact_minor_upgrade') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check for changes in core/dbt/artifacts
id: check_changes
run: |
# Check for changes in dbt/artifacts
CHANGED_FILES=$(git diff --name-only origin/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} | grep 'core/dbt/artifacts/')
if [ ! -z "$CHANGED_FILES" ]; then
echo "CHANGED=true" >> $GITHUB_ENV
echo "Changed files in core/dbt/artifacts:"
echo "$CHANGED_FILES"
else
echo "CHANGED=false" >> $GITHUB_ENV
fi
# https://github.com/marketplace/actions/paths-changes-filter
uses: dorny/paths-filter@v3
id: check_artifact_changes
with:
filters: |
artifacts_changed:
- 'core/dbt/artifacts/**'
list-files: shell

- name: Fail CI if artifacts have changed
if: env.CHANGED == 'true' && !contains(github.event.pull_request.labels.*.name, 'artifact_minor_upgrade')
if: steps.check_artifact_changes.outputs.artifacts_changed == 'true'
run: |
echo "CI failure: Artifact changes checked in core/dbt/artifacts directory."
echo "Files changed: ${{ steps.check_artifact_changes.outputs.artifacts_changed_files }}"
echo "To bypass this check, confirm that the change is not breaking (https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/artifacts/README.md#breaking-changes) and add the 'artifact_minor_upgrade' label to the PR."
exit 1
- name: CI check passed
if: env.CHANGED == 'false' || contains(github.event.pull_request.labels.*.name, 'artifact_minor_upgrade')
if: steps.check_artifact_changes.outputs.artifacts_changed == 'false'
run: |
echo "No prohibited artifact changes checked in core/dbt/artifacts, or 'artifact_minor_upgrade' label found. CI check passed."
echo "No prohibited artifact changes found in core/dbt/artifacts. CI check passed."
2 changes: 1 addition & 1 deletion .github/workflows/schema-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ permissions: read-all

env:
LATEST_SCHEMA_PATH: ${{ github.workspace }}/new_schemas
SCHEMA_DIFF_ARTIFACT: ${{ github.workspace }}//schema_schanges.txt
SCHEMA_DIFF_ARTIFACT: ${{ github.workspace }}/schema_schanges.txt
DBT_REPO_DIRECTORY: ${{ github.workspace }}/dbt
SCHEMA_REPO_DIRECTORY: ${{ github.workspace }}/schemas.getdbt.com

Expand Down

0 comments on commit 9bc80d5

Please sign in to comment.