Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,11 @@ jobs:
contents: read
environment: dev
steps:
- *checkout-with-history
- uses: actions/checkout@v6
with:
ref: main
persist-credentials: false
filter: blob:none
- *setup-python
- *restore-venv
- *auth-gcp-dryrun
Expand All @@ -714,7 +718,7 @@ jobs:
bqetl_script="$PWD/script/bqetl"

# Get parent commit on main from which this branch diverged
MAIN_MERGE_BASE=$(git merge-base HEAD origin/main || true)
MAIN_MERGE_BASE=$(git merge-base HEAD $GITHUB_REF || true)
echo "merge base with main: $MAIN_MERGE_BASE"

# Check if the generated-sql branch can be re-used
Expand All @@ -735,6 +739,11 @@ jobs:
cd "$bigquery_etl"
export GENERATED_SQL_CHANGED=false

if [[ -n $MAIN_MERGE_BASE ]]; then
echo "Checking out $MAIN_MERGE_BASE for diff"
git checkout $MAIN_MERGE_BASE
fi

# If SQL generators changed, re-run SQL generation
if [[ $(git diff --name-only --diff-filter=d ${LATEST_TAG_GENERATED_SQL:-HEAD}...HEAD -- sql_generators) ]]; then
echo "SQL generator changed; re-generate SQL"
Expand All @@ -747,6 +756,8 @@ jobs:
GENERATED_SQL_CHANGED=true
fi

git checkout main

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scholtzan the CircleCI version of the main-generate-sql-and-dags job wasn't switching back to main before rerunning the SQL generation, but I think this will result in a more accurate diff of what would be changed if the PR was merged into main. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this makes sense. I wonder if we didn't do it in CircleCI to reduce diff noise and ignore changes due to the branch being out-of-date, though I don't fully remember. This is at least something we should try and see.


if [ "$GENERATED_SQL_CHANGED" = "true" ]; then
# Re-run SQL generation
$bqetl_script generate all \
Expand Down
Loading