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 pre-commits preventing accidental API changes in common.sql #27962

Merged
merged 1 commit into from
Dec 5, 2022

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Nov 28, 2022

We had recently some mishaps when it comes to changes to the common.sql provider that accidentally changed API of the common.sql providers and they passed both tests and reviews.

Common.sql is pretty special provider because it used by other providers and we have to make sure the API it epxoses is backwards compatible, otherwise upgrading common.sql provider might break those providers.

This had already happened:

This change introduces tools and process to flag common.sql API changes that are likely backwards compatible.

They will require a deliberate action from the contributor who introduces a breaking API to common.sql, it will also help to flag to reviewer when such a change is made.

The idea is based on how Android OS handles flagging API changes for their public APIs paired with the tooling that MyPy provides with generating stubs and verifying usage of packages in the stubs.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@potiuk
Copy link
Member Author

potiuk commented Nov 28, 2022

cc: @kazanzhy @vincbeck -> this is even better than the "custom" API check :)

@potiuk
Copy link
Member Author

potiuk commented Nov 28, 2022

The comparision and reporting part is unchanged:

Example parameter removal:

image

image

@potiuk potiuk force-pushed the add-pre-commmits-sql-mypy branch 2 times, most recently from 80ae4a9 to b6e7a33 Compare November 28, 2022 16:30
Copy link
Contributor

@vincbeck vincbeck left a comment

Choose a reason for hiding this comment

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

Just a minor comment, other than that, LGTM :)

airflow/providers/common/sql/README_API.md Outdated Show resolved Hide resolved
@potiuk potiuk force-pushed the add-pre-commmits-sql-mypy branch 2 times, most recently from cfcc168 to 3f03d22 Compare November 28, 2022 19:39
@potiuk
Copy link
Member Author

potiuk commented Nov 28, 2022

Just a minor comment, other than that, LGTM :)

Fixed and also updated the description a little for the future work.

@potiuk
Copy link
Member Author

potiuk commented Nov 28, 2022

All looks good :)

@potiuk
Copy link
Member Author

potiuk commented Nov 30, 2022

🙏

setup.py Outdated Show resolved Hide resolved
@potiuk potiuk force-pushed the add-pre-commmits-sql-mypy branch 2 times, most recently from 4f7fc72 to 8dad054 Compare December 2, 2022 22:51
@potiuk
Copy link
Member Author

potiuk commented Dec 3, 2022

OK. No __init__.pyi files, all tests passing (rebased to check it again). I think it is pretty cool now.

airflow/providers/common/sql.pyi Outdated Show resolved Hide resolved
@potiuk potiuk force-pushed the add-pre-commmits-sql-mypy branch 4 times, most recently from 0d31796 to 2da265b Compare December 5, 2022 19:56
We had recently some mishaps when it comes to changes to the
common.sql provider that accidentally changed API of the common.sql
providers and they passed both tests and reviews.

Common.sql is pretty special provider because it used by other
providers and we have to make sure the API it epxoses is backwards
compatible, otherwise upgrading common.sql provider might break
those providers.

This had already happened:

* The apache#26761 refactored common.sql provided and removed some
  methods that were actually used by Google Provider

* This caused a problem described in apache#27838 and forced us ot
  yank common.sql 1.3.0 and release 1.3.1 with the methods
  added back in apache#27843

This change introduces tools and process to flag common.sql API
changes that are likely backwards compatible.

They will require a deliberate action from the contributor who
introduces a breaking API to common.sql, it will also help to
flag to reviewer when such a change is made.

The idea is based on how Android OS handles flagging API changes
for their public APIs paired with the tooling that MyPy provides
with generating stubs and verifying usage of packages in the
stubs.
@potiuk potiuk merged commit 6852f3f into apache:main Dec 5, 2022
@potiuk potiuk deleted the add-pre-commmits-sql-mypy branch December 5, 2022 22:44
@pierrejeambrun pierrejeambrun added this to the Airflow 2.5.1 milestone Jan 9, 2023
@pierrejeambrun pierrejeambrun added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) provider:common-sql
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants