Skip to content

Commit 3cc3bae

Browse files
authored
Format and simplify intergration test (#245)
1 parent 5e27341 commit 3cc3bae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+479
-452
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
build/
2-
.cache
2+
.cache

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Diagnostics:
2-
UnusedIncludes: None
2+
UnusedIncludes: None

.github/workflows/check-format.yml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ on:
44
push:
55
branches: [main]
66
paths:
7-
- .clang-format
7+
- ".clang-format"
8+
- ".pre-commit-config.yaml"
9+
- "**/*.py"
10+
- "pyproject.toml"
811
- "include/**"
912
- "src/**"
1013
- "tests/**"
1114

1215
pull_request:
1316
branches: [main]
1417
paths:
15-
- .clang-format
18+
- ".clang-format"
19+
- ".pre-commit-config.yaml"
20+
- "**/*.py"
21+
- "pyproject.toml"
1622
- "include/**"
1723
- "src/**"
1824
- "tests/**"
@@ -25,23 +31,34 @@ jobs:
2531
- name: Checkout code
2632
uses: actions/checkout@v4
2733

28-
- name: Install clang-format
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v6
36+
37+
- name: Run check
38+
id: precommit
2939
run: |
30-
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm.asc
31-
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" | sudo tee /etc/apt/sources.list.d/llvm20.list
32-
echo "deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" | sudo tee -a /etc/apt/sources.list.d/llvm20.list
33-
sudo apt-get update && sudo apt-get install -y clang-format-20
34-
clang-format-20 --version
40+
uv venv
41+
uv pip install pre-commit
42+
uv run pre-commit run --all-files
43+
continue-on-error: true
3544

36-
- name: Run clang-format check
45+
- name: Show diff on failure
46+
if: steps.precommit.outcome == 'failure'
3747
run: |
38-
FILES=$(find ./ -type f | grep -P '^\.\/(src|include)(\/[^\/]+)*\/[^\/]+\.(h|cpp|cc)$')
48+
echo "❌ pre-commit found issues that it auto-fixed."
49+
echo " Please run 'pre-commit run --all-files' locally,"
50+
echo " commit the changes, and push again."
51+
echo ""
52+
echo "👇 The required changes are shown below:"
53+
git diff
3954
40-
UNFORMATTED=$(clang-format-20 --dry-run --Werror $FILES)
55+
- name: Fail the job if pre-commit failed
56+
if: steps.precommit.outcome == 'failure'
57+
run: |
58+
echo "pre-commit checks failed."
59+
exit 1
4160
42-
if [ $? -ne 0 ]; then
43-
echo "× Some files are not properly formatted. Run clang-format to fix them."
44-
exit 1
45-
else
46-
echo "✓ All files are properly formatted."
47-
fi
61+
- name: Auto correct
62+
uses: huacnlee/autocorrect-action@main
63+
with:
64+
args: --lint ./docs

.github/workflows/cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
with:
3535
buckets: main
3636
apps: ninja
37-
37+
3838
- name: Setup llvm & libstdc++ & cmake & ninja
3939
if: matrix.os == 'ubuntu-24.04'
4040
run: |

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ tests/unit/Local/
5151

5252
**/node_modules
5353
docs/.vitepress/dist
54-
docs/.vitepress/cache
54+
docs/.vitepress/cache

.pre-commit-config.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
# .pre-commit-config.yaml
2+
13
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- id: check-merge-conflict
12+
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.12.12
15+
hooks:
16+
- id: ruff
17+
args: [--fix]
18+
- id: ruff-format
19+
220
- repo: https://github.com/pre-commit/mirrors-clang-format
3-
rev: "v20.1.0"
21+
rev: v21.1.0
422
hooks:
523
- id: clang-format
6-
files: '^(src|include)(/[^/]+)*/[^/]+\.(h|cpp|cc)$'
24+
types_or: [c++, c]

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ endif()
3535

3636
message(STATUS "Fetching tomlplusplus...")
3737
FetchContent_Declare(
38-
tomlplusplus
38+
tomlplusplus
3939
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
4040
)
4141

@@ -87,9 +87,9 @@ endif()
8787
file(GLOB_RECURSE CLICE_SOURCES CONFIGURE_DEPENDS
8888
"${CMAKE_SOURCE_DIR}/src/AST/*.cpp"
8989
"${CMAKE_SOURCE_DIR}/src/Async/*.cpp"
90-
"${CMAKE_SOURCE_DIR}/src/Basic/*.cpp"
91-
"${CMAKE_SOURCE_DIR}/src/Compiler/*.cpp"
92-
"${CMAKE_SOURCE_DIR}/src/Index/*.cpp"
90+
"${CMAKE_SOURCE_DIR}/src/Basic/*.cpp"
91+
"${CMAKE_SOURCE_DIR}/src/Compiler/*.cpp"
92+
"${CMAKE_SOURCE_DIR}/src/Index/*.cpp"
9393
"${CMAKE_SOURCE_DIR}/src/Feature/*.cpp"
9494
"${CMAKE_SOURCE_DIR}/src/Server/*.cpp"
9595
"${CMAKE_SOURCE_DIR}/src/Support/*.cpp"

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /usr/share/keyrings/ll
1010
echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.key] http://apt.llvm.org/trixie/ llvm-toolchain-trixie main" >> /etc/apt/sources.list && \
1111
echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.key] http://apt.llvm.org/trixie/ llvm-toolchain-trixie-20 main" >> /etc/apt/sources.list && \
1212
apt-get update && apt-get install -y \
13-
clang-20 lld-20
13+
clang-20 lld-20
1414
RUN ln -s /usr/bin/lld-20 /usr/bin/lld
1515

1616
# Adds source code
@@ -28,7 +28,7 @@ RUN cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang-20 -DCMAKE_CXX_COMPILER=cla
2828
RUN cmake --build build -j && \
2929
cmake --install build --prefix=/opt/clice
3030

31-
FROM debian:13
31+
FROM debian:13
3232

3333
COPY --from=builder /opt/clice /opt/clice/
3434
COPY LICENSE /opt/clice/LICENSE

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ Download the latest `clice` binary from the [releases page](https://github.com/c
3535
3636
## Documentation
3737

38-
To learn more about building, installing, and configuring clice, or to dive deep into its features and architecture, please visit our official documentation at [**clice.io**](https://clice.io/).
38+
To learn more about building, installing, and configuring clice, or to dive deep into its features and architecture, please visit our official documentation at [**clice.io**](https://clice.io/).

cmake/github.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ function(github_lookup_tag_commit REPO_OWNER REPO_NAME TAG_NAME OUTPUT_VAR)
55
set(GITHUB_API_URL "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/ref/tags/${TAG_NAME}")
66

77
message(STATUS "Fetching tag info from: ${GITHUB_API_URL}")
8-
8+
99
# Download tag info directly into a string
1010
download_to_string(${GITHUB_API_URL} TAG_JSON DOWNLOAD_RESULT)
1111
if(NOT DOWNLOAD_RESULT EQUAL "0")
1212
message(WARNING "Failed to fetch tag info. Result: ${DOWNLOAD_RESULT}")
1313
set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE)
1414
return()
1515
endif()
16-
16+
1717
# Parse the JSON to get object type and SHA
1818
parse_json_field_from_string("${TAG_JSON}" object "type" OBJECT_TYPE)
1919
parse_json_field_from_string("${TAG_JSON}" object "sha" OBJECT_SHA)
20-
20+
2121
if(OBJECT_TYPE STREQUAL "NOTFOUND" OR OBJECT_SHA STREQUAL "NOTFOUND")
2222
message(WARNING "Could not find object type or SHA in the JSON response.")
2323
set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE)
2424
return()
2525
endif()
26-
26+
2727
set(COMMIT_SHA "NOTFOUND")
2828

2929
if(OBJECT_TYPE STREQUAL "commit")
@@ -34,24 +34,24 @@ function(github_lookup_tag_commit REPO_OWNER REPO_NAME TAG_NAME OUTPUT_VAR)
3434
set(TAG_API_URL "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/tags/${OBJECT_SHA}")
3535

3636
message(STATUS "Fetching annotated tag info from: ${TAG_API_URL}")
37-
37+
3838
# Download annotated tag info directly into a string
3939
download_to_string(${TAG_API_URL} ANNOTATED_TAG_JSON TAG_DOWNLOAD_RESULT)
4040
if(NOT TAG_DOWNLOAD_RESULT EQUAL "0")
4141
message(WARNING "Failed to fetch annotated tag info. Result: ${TAG_DOWNLOAD_RESULT}")
4242
set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE)
4343
return()
4444
endif()
45-
45+
4646
# Parse the annotated tag JSON to get the commit SHA
4747
parse_json_field_from_string("${ANNOTATED_TAG_JSON}" object "sha" COMMIT_SHA_FROM_TAG)
48-
48+
4949
if(NOT COMMIT_SHA_FROM_TAG STREQUAL "NOTFOUND")
5050
set(COMMIT_SHA ${COMMIT_SHA_FROM_TAG})
5151
endif()
5252
else()
5353
message(WARNING "Unknown object type: ${OBJECT_TYPE}")
5454
endif()
55-
55+
5656
set(${OUTPUT_VAR} ${COMMIT_SHA} PARENT_SCOPE)
57-
endfunction()
57+
endfunction()

0 commit comments

Comments
 (0)