Skip to content
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

Add Github workflow to populate the persistent source schema #715

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

plypaul
Copy link
Contributor

@plypaul plypaul commented Aug 8, 2023

Description

When the definitions of the tables used in tests change, the persistent source schema needs to be repopulated manually. This PR adds a Github workflow to do this that can be trigged with the Reload Test Data in SQL Engines label.

@cla-bot cla-bot bot added the cla:yes label Aug 8, 2023
@plypaul plypaul added the Reload Test Data in SQL Engines Should be run when test data changes label Aug 8, 2023
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS August 8, 2023 18:45 — with GitHub Actions Inactive
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from e283ae8 to b7950bf Compare August 8, 2023 20:05
@plypaul plypaul added Reload Test Data in SQL Engines Should be run when test data changes and removed Reload Test Data in SQL Engines Should be run when test data changes labels Aug 8, 2023
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from b7950bf to a739d97 Compare August 8, 2023 20:10
@plypaul plypaul added Reload Test Data in SQL Engines Should be run when test data changes and removed Reload Test Data in SQL Engines Should be run when test data changes labels Aug 8, 2023
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS August 8, 2023 20:12 — with GitHub Actions Inactive
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from a739d97 to 7ba0977 Compare August 8, 2023 20:38
@plypaul plypaul added Reload Test Data in SQL Engines Should be run when test data changes and removed Reload Test Data in SQL Engines Should be run when test data changes labels Aug 8, 2023
@plypaul plypaul had a problem deploying to DW_INTEGRATION_TESTS August 8, 2023 20:41 — with GitHub Actions Error
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from 7ba0977 to c9d00fe Compare August 8, 2023 20:44
@plypaul plypaul added Reload Test Data in SQL Engines Should be run when test data changes and removed Reload Test Data in SQL Engines Should be run when test data changes labels Aug 8, 2023
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS August 8, 2023 20:44 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS August 8, 2023 20:44 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS August 8, 2023 20:44 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS August 8, 2023 20:44 — with GitHub Actions Inactive
@plypaul plypaul marked this pull request as ready for review August 8, 2023 20:55
@plypaul plypaul requested a review from WilliamDee August 8, 2023 20:55
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from c9d00fe to 9278608 Compare August 8, 2023 20:57
Makefile Outdated
.PHONY: test-bigquery
test-bigquery:
hatch -v run bigquery-env:pytest -vv -n $(PARALLELISM) $(ADDITIONAL_PYTEST_OPTIONS) metricflow/test/

.PHONY: populate-persistent-source-schema-bigquery
populate-persistent-source-schema:
Copy link
Contributor

Choose a reason for hiding this comment

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

add -bigquery suffix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. Apparently, if the name it wrong, make still succeeds with nothing to do

@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from 9278608 to 0f6a14c Compare August 8, 2023 23:02
@plypaul plypaul added Reload Test Data in SQL Engines Should be run when test data changes and removed Reload Test Data in SQL Engines Should be run when test data changes labels Aug 8, 2023
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS August 8, 2023 23:03 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 02:20 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 02:20 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 02:20 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 02:20 — with GitHub Actions Inactive
@github-actions github-actions bot removed the Reload Test Data in SQL Engines Should be run when test data changes label Sep 19, 2023
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch 2 times, most recently from 7d3b842 to 0977192 Compare September 19, 2023 05:56
@plypaul
Copy link
Contributor Author

plypaul commented Sep 19, 2023

Updated logic to run the workflow when the label is set, and remove the label when workflow finishes. Hopefully Github's concurrency controls work as expected, and this seems good enough for a try.

@plypaul plypaul requested a review from tlento September 19, 2023 05:58
Copy link
Contributor

@tlento tlento left a comment

Choose a reason for hiding this comment

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

Sure, let's give it a go. Please address inline comments before merge.

Comment on lines +11 to +13
on:
pull_request:
types: [labeled]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add workflow_dispatch so we don't have to label random PRs if something gets borked off main.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, but iterating on this PR has been a huge pain as it can't be tested locally.

jobs:
snowflake-populate:
environment: DW_INTEGRATION_TESTS
if: github.event.action == 'labeled' && github.event.label.name == 'Reload Test Data in SQL Engines'
Copy link
Contributor

Choose a reason for hiding this comment

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

This may need an update for workflow_dispatch to fire, but it should be simple enough.

Makefile Outdated
.PHONY: test-bigquery
test-bigquery:
hatch -v run bigquery-env:pytest -vv -n $(PARALLELISM) $(ADDITIONAL_PYTEST_OPTIONS) metricflow/test/

.PHONY: populate-persistent-source-schema-bigquery
populate-persistent-source-schema-bigquery:
hatch -v run bigquery-env:pytest -vv $(ADDITIONAL_PYTEST_OPTIONS) $(POPULATE_PERSISTENT_SOURCE_SCHEMA)
Copy link
Contributor

@tlento tlento Sep 19, 2023

Choose a reason for hiding this comment

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

I think it's better to define a make command that just works, instead of one that relies on someone knowing that they have to set up the ADDITIONAL_PYTEST_OPTIONS=--use-persistent-source-schema environment flag.

I just know I'm going to perpetually be in a loop of:

make populate-persistent....databricks
<fail>
make -e "ADDITIONAL_PYTEST_OPTIONS=--use-persistent-source-schema" populate-persistent...databricks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. Updated.

Comment on lines +8 to +9
group: POPULATE_PERSISTENT_SOURCE_SCHEMA
cancel-in-progress: true
Copy link
Contributor

Choose a reason for hiding this comment

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

I am very curious to see how this works.

additional-pytest-options: ${{ env.ADDITIONAL_PYTEST_OPTIONS }}
make-target: "populate-persistent-source-schema-databricks"

remove-label:
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh if this works we should TOTALLY add it to the sql engine tests...... I've got some updates I want to make over there so I can do that once this is in.


name: Reload Test Data in SQL Engines

# We don't want multiple workflows trying to create the same table.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I guess if this ever happens in different schemas the last one in will be wrong anyway.

@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from 0977192 to dc1ad0d Compare September 19, 2023 19:21
@plypaul plypaul added the Reload Test Data in SQL Engines Should be run when test data changes label Sep 19, 2023
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from dc1ad0d to 3f88ff4 Compare September 19, 2023 19:26
@plypaul plypaul added Reload Test Data in SQL Engines Should be run when test data changes and removed Reload Test Data in SQL Engines Should be run when test data changes labels Sep 19, 2023
@plypaul plypaul had a problem deploying to DW_INTEGRATION_TESTS September 19, 2023 19:26 — with GitHub Actions Failure
@plypaul plypaul had a problem deploying to DW_INTEGRATION_TESTS September 19, 2023 19:26 — with GitHub Actions Failure
@plypaul plypaul had a problem deploying to DW_INTEGRATION_TESTS September 19, 2023 19:26 — with GitHub Actions Failure
@plypaul plypaul had a problem deploying to DW_INTEGRATION_TESTS September 19, 2023 19:27 — with GitHub Actions Failure
@plypaul plypaul force-pushed the plypaul--53--populate-persistent-source-schema-gha branch from 3f88ff4 to 609c080 Compare September 19, 2023 19:33
@plypaul plypaul added Reload Test Data in SQL Engines Should be run when test data changes and removed Reload Test Data in SQL Engines Should be run when test data changes labels Sep 19, 2023
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 19:33 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 19:33 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 19:33 — with GitHub Actions Inactive
@plypaul plypaul temporarily deployed to DW_INTEGRATION_TESTS September 19, 2023 19:33 — with GitHub Actions Inactive
@github-actions github-actions bot removed the Reload Test Data in SQL Engines Should be run when test data changes label Sep 19, 2023
@plypaul plypaul merged commit e285189 into main Sep 19, 2023
22 checks passed
@plypaul plypaul deleted the plypaul--53--populate-persistent-source-schema-gha branch September 19, 2023 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants