Skip to content

[CI] Add auto run generate_exports.py to pre-commit#23848

Merged
RattataKing merged 4 commits intoiree-org:mainfrom
RattataKing:ci
Mar 20, 2026
Merged

[CI] Add auto run generate_exports.py to pre-commit#23848
RattataKing merged 4 commits intoiree-org:mainfrom
RattataKing:ci

Conversation

@RattataKing
Copy link
Copy Markdown
Contributor

It is easy to forget updating C API exports when adding new Python bindings.
This change adds a pre-commit hook that runs generate_exports.py whenever header files under compiler/bindings/c/iree/compiler/ are modified.

Copy link
Copy Markdown
Contributor

@bangtianliu bangtianliu left a comment

Choose a reason for hiding this comment

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

Thanks, this is very helpful.

Copy link
Copy Markdown
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for automating this.

Have you tried adding a new CAPI to see what the output looks like? Could you show an example?

@kuhar kuhar requested review from hanhanW and qedawkins March 19, 2026 00:14
@RattataKing RattataKing marked this pull request as draft March 19, 2026 00:37
Copy link
Copy Markdown
Contributor

@hanhanW hanhanW left a comment

Choose a reason for hiding this comment

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

Does it print out how to fix the failure (e.g., running the script) when it fails?

Copy link
Copy Markdown
Member

@ScottTodd ScottTodd left a comment

Choose a reason for hiding this comment

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

This does looks appropriate for a pre-commit hook, thanks.

Comment thread .github/workflows/lint.yml
Comment thread .pre-commit-config.yaml
@RattataKing
Copy link
Copy Markdown
Contributor Author

RattataKing commented Mar 19, 2026

Does it print out how to fix the failure (e.g., running the script) when it fails?

It's included in the pre-commit test, CI will print If you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`.

@RattataKing RattataKing marked this pull request as ready for review March 19, 2026 17:09
@RattataKing
Copy link
Copy Markdown
Contributor Author

Have you tried adding a new CAPI to see what the output looks like? Could you show an example?

Declare a test sample in /compiler/bindings/c/iree/compiler/dialects/iree_codegen.h

MLIR_CAPI_EXPORTED bool TestPreCommitForCAPI();

Run pre-commit run --all-files, and get terminal output:

...
Regenerate CAPI export files.............................................Failed
- hook id: generate_capi_exports
- files were modified by this hook

Comment thread .github/workflows/lint.yml Outdated
RattataKing added a commit that referenced this pull request Mar 19, 2026
Using the `generate_exports.py` scripts.
To resolve ci errors for #23848.
@RattataKing RattataKing force-pushed the ci branch 2 times, most recently from 67afd30 to 9926a0b Compare March 19, 2026 21:06
Comment thread .github/workflows/lint.yml Outdated
@RattataKing RattataKing merged commit 5662189 into iree-org:main Mar 20, 2026
52 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants