Skip to content

Enhance pre-commit hook to automate migrations ref doc and revision metadata#21601

Merged
dstandish merged 3 commits into
apache:mainfrom
astronomer:use-yaml-config-for-migration-documentation
Mar 1, 2022
Merged

Enhance pre-commit hook to automate migrations ref doc and revision metadata#21601
dstandish merged 3 commits into
apache:mainfrom
astronomer:use-yaml-config-for-migration-documentation

Conversation

@dstandish

@dstandish dstandish commented Feb 15, 2022

Copy link
Copy Markdown
Contributor

Now the revision table in migrations-ref.rst is fully automated.

  • I updated each migration file to have the latest description from the migrations-ref doc.
  • I updated each migration file to include a literal constant expressing the version in which the migration was (or is expected to) be released

When a new migration file is committed, the pre-commit hook will insert the (expected release) airflow version (if it wasn't added manually). Then we'll walk the revisions, update the docs table, and update the version-revision map constant (for now located in db.py).

I had to make it a breeze hook since it depends on airflow itself.

Since we store the revision map in db.py, the hook will have to run every time db.py is modified. If that proves to be annoying, we can move the constant elsewhere.

How you can quickly verify this works locally

Test 1 - change version: Open airflow/migrations/versions/c306b5b5ae4a_switch_xcom_table_to_use_run_id.py and change the airflow version. Observe that map constant and migrations ref are updated.

Test 2 - new migration: Copy airflow/migrations/versions/c306b5b5ae4a_switch_xcom_table_to_use_run_id.py and name airflow/migrations/versions/c306b5b5ae4a_switch_xcom_table_to_use_run_id_2.py. Make it a new revision c306b5b5ae4a2 with down_revision=c306b5b5ae4a and remove line with airflow_version and try to commit. Observe that airflow version is added, doc updated, constant updated.

Comment thread docs/apache-airflow/migrations-ref.rst Outdated
@dstandish dstandish force-pushed the use-yaml-config-for-migration-documentation branch from c061b7f to 6c3e57a Compare February 16, 2022 05:23
@dstandish dstandish marked this pull request as draft February 16, 2022 22:56
@dstandish

Copy link
Copy Markdown
Contributor Author

converted to draft for now while i make some updates to make this a more comprehensive and robust solution

@dstandish dstandish force-pushed the use-yaml-config-for-migration-documentation branch 2 times, most recently from 09431ec to f2d5d61 Compare February 17, 2022 00:04
@dstandish dstandish marked this pull request as ready for review February 17, 2022 00:05
@dstandish dstandish changed the title Use yaml config for generation of migration reference Enhance pre-commit hook to automate migrations ref doc and map constant Feb 17, 2022

@jedcunningham jedcunningham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't need both a precommit and static check, right, as precommits are also run in static check?

Comment thread airflow/utils/db.py Outdated
Comment thread docs/apache-airflow/migrations-ref.rst Outdated
Comment thread scripts/ci/pre_commit/pre_commit_revision_map.py Outdated
Comment thread scripts/ci/pre_commit/pre_commit_revision_map.sh Outdated
Comment thread docs/apache-airflow/migrations-ref.rst Outdated
@dstandish dstandish force-pushed the use-yaml-config-for-migration-documentation branch from d68a17f to 317d11f Compare February 17, 2022 19:27
@dstandish dstandish changed the title Enhance pre-commit hook to automate migrations ref doc and map constant Enhance pre-commit hook to automate migrations ref doc and revision metadata Feb 17, 2022
@dstandish dstandish force-pushed the use-yaml-config-for-migration-documentation branch 2 times, most recently from 47fe197 to 8fbe74e Compare February 17, 2022 22:07
* document airflow version in each alembic migration module and use this to autogen the doc
* update each migration module to have the same description used in migration ref (so it can be used in autogen)

See PR apache#21596 for reference.
@dstandish dstandish force-pushed the use-yaml-config-for-migration-documentation branch from 8fbe74e to 3ef995c Compare February 26, 2022 19:25
@potiuk

potiuk commented Feb 28, 2022

Copy link
Copy Markdown
Member

Needs rebase.

@dstandish dstandish merged commit 69f6f9e into apache:main Mar 1, 2022
@dstandish dstandish deleted the use-yaml-config-for-migration-documentation branch March 1, 2022 07:25
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Apr 8, 2022
@ephraimbuddy ephraimbuddy added changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) and removed type:misc/internal Changelog: Misc changes that should appear in change log labels Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) kind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants