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 format checker to the CI #120

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open

Add format checker to the CI #120

wants to merge 32 commits into from

Conversation

Dtenwolde
Copy link

@Dtenwolde Dtenwolde commented Dec 10, 2024

This PR adds a more extensive formatting checker for extensions and a format check step to the CI.

I copied the format.py script from https://github.com/duckdb/duckdb/blob/main/scripts/format.py and renamed it to format_extension.py since it has different directories to check. I also added similar Makerules such as format-check and format-fix. I think keeping the pipeline consistent with the main duckdb repo makes sense for the code quality of extensions. Extension maintainers can always opt out or disable the workflow if they so desire.

Two things I am not sure about:

  • The current format script works for C++, Python, Java and .test files. What do you think about extensions written in Rust?
  • There is code to check the header of .hpp files (see below for the strings), but can we enforce that extensions have such a header? I am not sure how strict we should be about this check or if it is even relevant. Curious about your thoughts.
header_top = "//===----------------------------------------------------------------------===//\n"
header_top += "//                         DuckDB\n" + "//\n"
header_bottom = "//\n" + "//\n"
header_bottom += "//===----------------------------------------------------------------------===//\n\n"

I added a PR to the extension-template to trigger this workflow: duckdb/extension-template#99

@carlopi
Copy link
Collaborator

carlopi commented Dec 10, 2024

Hi, thanks a lot!

I have not take a look at the code yet, one feedback on the setup we have is that https://github.com/duckdb/extension-ci-tools/blob/main/.github/workflows/TestCITools.yml should likely invoke the formatting workflow, so that directly on this PR that is invoked, and on changes to the formatting script this is still run once so that it's checked to still make sense (where make sense means not exploding).

Note that it's possible that adding the test means it would fail, since extension-template might not be formatted properly yet, but that's OK, relevant thing is checking it completes without burning.

cmake-format -i CMakeLists.txt
# Rule to fix formatting
format-check:
python extension-ci-tools/scripts/format_extension.py
Copy link

Choose a reason for hiding this comment

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

curious, why L137 uses python while L140 and L143 uses python3?

Copy link
Author

Choose a reason for hiding this comment

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

Fair point, using python for all in cff0722 (#120)

@@ -0,0 +1,400 @@
#!/usr/bin/python
Copy link

Choose a reason for hiding this comment

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

Maybe I'm too sensitive, I'm not sure whether MIT license should be included
From doc, the copyright notice needs necessary.
(Though I know these two repositories belong to the same organization...)

Copy link
Author

Choose a reason for hiding this comment

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

I wouldn't be opposed to adding this, but the other scripts in this repo also don't have this in the header. So I think this is up to @carlopi whether this should be added or not.

- name: Generated Check
shell: bash
run: |
git diff --ignore-submodules --exit-code
Copy link

Choose a reason for hiding this comment

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

nit: newliner

Copy link
Author

Choose a reason for hiding this comment

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

@dentiny
Copy link

dentiny commented Dec 10, 2024

Thank you so much!

Comment on lines 21 to 25
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should add a step like:

      - uses: actions/checkout@v4
        name: Checkout Extension CI tools
        with:
          path: 'extension-ci-tools'
          ref: ${{ inputs.ci_tools_version }}
          repository: ${{ inputs.override_ci_tools_repository }}

and add ci_tools_version AND override_ci_tools to the input, AND pass them down on the test invocation so that they are the current branch / current repo.

You can look at how https://github.com/duckdb/extension-ci-tools/blob/main/.github/workflows/_extension_distribution.yml works, or I can take over later.

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.

3 participants