Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ indent_size = 2
[*.{bat,ps1}]
end_of_line = crlf

[*.toml]
max_line_length = 120

# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
ktlint_code_style = android_studio
Expand Down
3 changes: 3 additions & 0 deletions .github/detekt.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
complexity:
CyclomaticComplexMethod:
ignoreFunction:
- "io.github.treesitter.ktreesitter.Query.Companion.init"
TooManyFunctions:
active: false
LongParameterList:
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/build-jni.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

& cmake -S ktreesitter -B ktreesitter/.cmake/build `
-DCMAKE_VERBOSE_MAKEFILE=ON `
-DCMAKE_INSTALL_PREFIX=ktreesitter/src/jvmMain/resources `
-DCMAKE_INSTALL_PREFIX=ktreesitter/src/jvmMain/resources `
-DCMAKE_INSTALL_BINDIR="$env:CMAKE_INSTALL_LIBDIR"
& cmake --build ktreesitter/.cmake/build --config Debug
& cmake --install ktreesitter/.cmake/build --config Debug
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/build-jni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
cmake -S ktreesitter -B ktreesitter/.cmake/build \
-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DCMAKE_INSTALL_PREFIX=ktreesitter/src/jvmMain/resources \
-DCMAKE_INSTALL_LIBDIR="$CMAKE_INSTALL_LIBDIR"
cmake --build ktreesitter/.cmake/build
Expand All @@ -12,7 +12,7 @@ cmake --install ktreesitter/.cmake/build
for dir in languages/*/; do
cmake -S "${dir}build/generated" -B "${dir}.cmake/build" \
-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DCMAKE_INSTALL_PREFIX="${dir}build/generated/src/jvmMain/resources" \
-DCMAKE_INSTALL_LIBDIR="$CMAKE_INSTALL_LIBDIR"
cmake --build "${dir}.cmake/build"
Expand Down
64 changes: 24 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ on:
- "**/jni/*"
- gradle/**
- gradle.properties
- ktreesitter/gradle.lockfile
pull_request:
paths:
- "/*.kt"
- "**/*.kts"
- "**/jni/*"
- gradle/**
- gradle.properties
- ktreesitter/gradle.lockfile

concurrency:
cancel-in-progress: true
Expand All @@ -30,27 +32,25 @@ jobs:
name: Generate grammar files
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Cache Kotlin/Native prebuilt
uses: actions/cache@v4
ktreesitter/gradle.lockfile
- name: Set up Kotlin/Native
uses: ObserverOfTime/setup-konan-action@v1
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
kotlin_version: 2.2.10
- name: Generate files
run: ./gradlew --no-daemon generateGrammarFiles
env:
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -101,28 +101,34 @@ jobs:
:ktreesitter:iosSimulatorArm64Test
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Set up Kotlin/Native
uses: ObserverOfTime/setup-konan-action@v1
with:
kotlin_version: 2.2.10
- name: Set up cross compilation
run: sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
if: matrix.platform == 'Linux'
- name: Restore Kotlin/Native prebuilt
uses: actions/cache/restore@v4
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
run: |-
sudo apt-get update
sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
- name: Set up Ninja
if: matrix.platform == 'Android'
run: |-
sudo apt-get update
sudo apt-get install -qy ninja-build
- name: Download generated files
uses: actions/download-artifact@v4
uses: actions/download-artifact@v5
with:
path: languages
name: generated-files
Expand All @@ -131,30 +137,8 @@ jobs:
run: .github/scripts/build-jni.${{matrix.os == 'windows-latest' && 'ps1' || 'sh'}}
env:
CMAKE_INSTALL_LIBDIR: lib/${{matrix.lib_platform}}/${{matrix.lib_arch}}
- name: Cache Kotlin/Native dependencies
id: cache-dependencies
uses: actions/cache@v4
if: matrix.platform != 'JVM' && matrix.platform != 'Android'
with:
path: ${{runner.tool_cache}}/konan/dependencies
key: konan-${{runner.os}}-dependencies
- name: Download Kotlin/Native dependencies
if: matrix.platform == 'macOS/iOS' && steps.cache-dependencies.outputs.cache-hit != 'true'
run: |-
mkdir -p "$RUNNER_TOOL_CACHE/konan/dependencies"
curl -LSs https://download-cdn.jetbrains.com/kotlin/native/$DEP.tar.gz | \
tar -xzf - -C "$RUNNER_TOOL_CACHE/konan/dependencies"
env:
DEP: apple-llvm-20200714-macos-aarch64-essentials
- name: Set up Ninja
if: matrix.platform == 'Android'
run: |-
sudo apt-get update
sudo apt-get install -y ninja-build
- name: Run tests
run: ./gradlew --no-daemon ${{matrix.targets}}
env:
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
run: ./gradlew --no-daemon -Pcmake.version=3.31.6 ${{matrix.targets}}
- name: Report test results
uses: mikepenz/action-junit-report@v5
if: matrix.platform == 'JVM' && !cancelled()
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ jobs:
url: ${{steps.deployment.outputs.page_url}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Restore Kotlin/Native prebuilt
uses: actions/cache/restore@v4
- name: Set up Kotlin/Native
uses: ObserverOfTime/setup-konan-action@v1
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
- name: Restore Kotlin/Native dependencies
uses: actions/cache/restore@v4
with:
path: ${{runner.tool_cache}}/konan/dependencies
key: konan-${{runner.os}}-dependencies
kotlin_version: 2.2.10
- name: Set up cross compilation
if: matrix.platform == 'Linux'
run: |-
sudo apt-get update
sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
- name: Set up Ninja
if: matrix.platform == 'Android'
run: |-
sudo apt-get update
sudo apt-get install -y ninja-build
sudo apt-get install -qy ninja-build
- name: Build documentation
run: ./gradlew --no-daemon generateFiles :ktreesitter:dokkaHtml
env:
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
run: >-
./gradlew --no-daemon -Pcmake.version=3.31.6
generateFiles :ktreesitter:dokkaGeneratePublicationHtml
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@v5
with:
path: ktreesitter/build/dokka/html
- name: Deploy to GitHub Pages
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Install ktlint
run: |-
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.3.1/ktlint
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.7.1/ktlint
chmod a+x ktlint && mv ktlint $RUNNER_TOOL_CACHE/ktlint
- name: Run ktlint
id: ktlint
Expand All @@ -51,16 +51,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Install detekt
run: |-
curl -sSLO https://github.com/detekt/detekt/releases/download/v1.23.7/detekt-cli-1.23.7-all.jar
mv detekt-cli-1.23.7-all.jar $RUNNER_TOOL_CACHE/detekt-cli.jar
curl -sSLO https://github.com/detekt/detekt/releases/download/v1.23.8/detekt-cli-1.23.8-all.jar
mv detekt-cli-1.23.8-all.jar $RUNNER_TOOL_CACHE/detekt-cli.jar
- name: Run detekt
id: detekt
run: >-
Expand Down
58 changes: 25 additions & 33 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ jobs:
-DCMAKE_OSX_ARCHITECTURES=arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
Expand Down Expand Up @@ -120,50 +120,44 @@ jobs:
:ktreesitter:publishIosArm64PublicationToLocalRepository
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Set up cross compilation
run: sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
if: matrix.platform == 'Linux' || matrix.platform == 'common'
- name: Restore Kotlin/Native prebuilt
uses: actions/cache/restore@v4
- name: Set up Kotlin/Native
uses: ObserverOfTime/setup-konan-action@v1
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
- name: Restore Kotlin/Native dependencies
uses: actions/cache/restore@v4
if: matrix.platform != 'JVM' && matrix.platform != 'Android'
with:
path: ${{runner.tool_cache}}/konan/dependencies
key: konan-${{runner.os}}-dependencies
kotlin_version: 2.2.10
- name: Set up cross compilation
if: matrix.platform == 'Linux'
run: |-
sudo apt-get update
sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
- name: Set up Ninja
if: matrix.platform == 'Android'
run: |-
sudo apt-get update
sudo apt-get install -qy ninja-build
- name: Download library artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v5
if: matrix.platform == 'JVM'
with:
path: ktreesitter/src/jvmMain/resources/lib
pattern: ktreesitter-lib-*
merge-multiple: true
- name: Set up Ninja
if: matrix.platform == 'Android'
run: |-
sudo apt-get update
sudo apt-get install -y ninja-build
- name: Build packages
run: ./gradlew --no-daemon ${{matrix.targets}}
run: ./gradlew --no-daemon -Pcmake.version=3.31.6 ${{matrix.targets}}
env:
SIGNING_KEY: ${{secrets.SIGNING_KEY}}
SIGNING_PASSWORD: ${{secrets.SIGNING_PASSWORD}}
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -186,7 +180,7 @@ jobs:
SONATYPE_AUTH: "Authorization: Bearer ${{secrets.SONATYPE_TOKEN}}"
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v5
with:
path: ktreesitter
pattern: ktreesitter-jars-*
Expand Down Expand Up @@ -223,26 +217,24 @@ jobs:
url: https://plugins.gradle.org/plugin/io.github.tree-sitter.ktreesitter-plugin
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Restore Kotlin/Native prebuilt
uses: actions/cache/restore@v4
- name: Set up Kotlin/Native
uses: ObserverOfTime/setup-konan-action@v1
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
kotlin_version: 2.2.10
- name: Publish Gradle plugin
run: ./gradlew --no-daemon :ktreesitter-plugin:publishPlugins
env:
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
GRADLE_PUBLISH_KEY: ${{secrets.GRADLE_PUBLISH_KEY}}
GRADLE_PUBLISH_SECRET: ${{secrets.GRADLE_PUBLISH_SECRET}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Gradle ###
.gradle/
build/
.kotlin/
kotlin-js-store/
dependency-graph-reports/
local.properties
Expand Down
Loading
Loading