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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c84d868
Add yaml file for code quality checker
Dtenwolde Dec 9, 2024
16d4a63
Merge pull request #1 from Dtenwolde/code-quality-check
Dtenwolde Dec 9, 2024
b6b2bf1
Update workflow file
Dtenwolde Dec 9, 2024
26d6e40
Go up one dir
Dtenwolde Dec 9, 2024
f0ef9af
Check cur directory
Dtenwolde Dec 9, 2024
2fdbe0c
Add ls
Dtenwolde Dec 9, 2024
67c549c
Add ls to extension-ci-tools
Dtenwolde Dec 9, 2024
3c351b6
Fetch extension-ci-tools
Dtenwolde Dec 9, 2024
e533e10
Remove debug step
Dtenwolde Dec 9, 2024
b026daa
Add a make format-check rule
Dtenwolde Dec 9, 2024
68bc76a
Update workflow
Dtenwolde Dec 9, 2024
3831e31
Fix format-check not exiting properly whenever an incorrectly formatt…
Dtenwolde Dec 9, 2024
c035c7e
Simplify format makerule
Dtenwolde Dec 9, 2024
6a37058
Add format-fix rule
Dtenwolde Dec 9, 2024
3c09b5e
Format fix
Dtenwolde Dec 9, 2024
43e24b2
Should say format-fix
Dtenwolde Dec 9, 2024
f4e3936
Commit with formatting mistake
Dtenwolde Dec 9, 2024
e5b9d69
Updated make format with some incorrectly formatted code
Dtenwolde Dec 9, 2024
a254f05
Fetch submodules
Dtenwolde Dec 9, 2024
3d021a0
Move format_extension.py to extension-ci-tools
Dtenwolde Dec 10, 2024
ea13557
Add open_utf8 function to format_extension.py
Dtenwolde Dec 10, 2024
87c94e1
Update paths
Dtenwolde Dec 10, 2024
34c2efc
Add code quality check to TestCITools.yml
Dtenwolde Dec 10, 2024
cff0722
Use python instead of python3 everywhere
Dtenwolde Dec 10, 2024
eb48b6e
Add newline
Dtenwolde Dec 10, 2024
1eb4f17
Add override to checkout repo
Dtenwolde Dec 10, 2024
82fda34
Remove override repository
Dtenwolde Dec 10, 2024
35f8ba3
Add the corresponding inputs
Dtenwolde Dec 10, 2024
714173d
Change to use main ci tools version
Dtenwolde Dec 10, 2024
762791f
Add some debugging
Dtenwolde Dec 10, 2024
f09ed60
Try cd ..
Dtenwolde Dec 10, 2024
ac95c03
Output content of makefile
Dtenwolde Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/TestCITools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,10 @@ jobs:
duckdb_version: v1.1.3
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools;windows_amd64'
extra_toolchains: 'rust'

code-quality-check:
name: Code quality check
uses: ./.github/workflows/_extension_code_quality.yml
with:
override_ci_tools_repository: "Dtenwolde/extension-ci-tools"
ci_tools_version: main
65 changes: 65 additions & 0 deletions .github/workflows/_extension_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CodeQuality

on:
workflow_call:
inputs:
explicit_checks:
required: false
type: string
# The version of the https://github.com/duckdb/extension-ci-tools submodule of the extension. In most cases will be identical to `duckdb_version`.
# Passing this explicitly is required because of https://github.com/actions/toolkit/issues/1264
ci_tools_version:
required: true
type: string
# Override the repo for the CI tools (for testing CI tools itself)
override_ci_tools_repository:
required: false
type: string
default: "duckdb/extension-ci-tools"


jobs:
format-check:
name: Format Check
runs-on: ubuntu-20.04

env:
CC: gcc-10
CXX: g++-10
GEN: ninja

steps:
- uses: actions/checkout@v4
name: Checkout current repository
with:
fetch-depth: 0
submodules: 'true'

- 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 }}

- name: Install
shell: bash
run: sudo apt-get update -y -qq && sudo apt-get install -y -qq ninja-build clang-format-11 && sudo pip3 install cmake-format black cxxheaderparser pcpp

- name: List Installed Packages
shell: bash
run: pip3 freeze

- name: Format Check
shell: bash
run: |
clang-format --version
clang-format --dump-config
black --version
cat makefiles/duckdb_extension.Makefile
make format-check-silent

- name: Generated Check
shell: bash
run: |
git diff --ignore-submodules --exit-code
12 changes: 9 additions & 3 deletions makefiles/duckdb_extension.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@ wasm_threads:
emmake make -j8 -Cbuild/wasm_threads

#### Misc
format:
find src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --sort-includes=0 -style=file -i
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)


format-check-silent:
python extension-ci-tools/scripts/format_extension.py --all --check --silent

format-fix:
python extension-ci-tools/scripts/format_extension.py --all --fix --noconfirm

update:
git submodule update --remote --merge
Expand Down
Loading
Loading