Skip to content

Commit

Permalink
ci: set up lint, ci, publish workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Jun 7, 2024
1 parent 50a5c0a commit 05da18e
Show file tree
Hide file tree
Showing 20 changed files with 487 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ max_line_length = off
[*.{json,yml,toml,xml}]
indent_size = 2

[*.bat]
[*.{bat,ps1}]
end_of_line = crlf

# noinspection EditorConfigKeyCorrectness
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

/gradlew linguist-generated
/gradlew.bat linguist-generated eol=crlf
/.github/scripts/build-jni.ps1 eol=crlf
/gradle/wrapper/gradle-wrapper.jar binary
14 changes: 14 additions & 0 deletions .github/scripts/build-jni.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env pwsh

& cmake -S ktreesitter -B ktreesitter/.cmake/build `
-DCMAKE_VERBOSE_MAKEFILE=ON `
-DCMAKE_INSTALL_BINDIR="$env:CMAKE_INSTALL_LIBDIR"
& cmake --build ktreesitter/.cmake/build --config Debug
& cmake --install ktreesitter/.cmake/build --config Debug --prefix ktreesitter/src/jvmMain/resources

foreach ($dir in Get-ChildItem -Directory -Path languages) {
& cmake -S "$dir" -B "$dir/.cmake/build" `
-DCMAKE_INSTALL_BINDIR="$env:CMAKE_INSTALL_LIBDIR"
& cmake --build "$dir/.cmake/build" --config Debug
& cmake --install "$dir/.cmake/build" --config Debug --prefix "$dir/src/jvmMain/resources"
}
19 changes: 19 additions & 0 deletions .github/scripts/build-jni.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -eu

cmake -S ktreesitter -B ktreesitter/.cmake/build \
-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_INSTALL_LIBDIR="$CMAKE_INSTALL_LIBDIR"

cmake --build ktreesitter/.cmake/build
cmake --install ktreesitter/.cmake/build --prefix ktreesitter/src/jvmMain/resources

for dir in languages/*/; do
cmake -S "$dir" -B "${dir}.cmake/build" \
-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_INSTALL_LIBDIR="$CMAKE_INSTALL_LIBDIR"
cmake --build "${dir}.cmake/build"
cmake --install "${dir}.cmake/build" --prefix "${dir}src/jvmMain/resources"
done
105 changes: 105 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: CI

on:
push:
branches: [master]
paths:
- "**/*.kt"
- "**/*.kts"
- "**/jni/*"
- gradle/**
pull_request:
paths:
- "/*.kt"
- "**/*.kts"
- "**/jni/*"
- gradle/**

concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref_name}}

permissions:
contents: write

jobs:
test:
runs-on: ${{matrix.os}}
name: >-
Test ${{matrix.platform}} platform
${{matrix.lib_platform && format('({0}-{1})', matrix.lib_platform, matrix.lib_arch)}}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: JVM
targets: jvmTest
lib_platform: linux
lib_arch: x64
- os: windows-latest
platform: JVM
targets: jvmTest
lib_platform: windows
lib_arch: x64
- os: macos-latest
platform: JVM
targets: jvmTest
lib_platform: macos
lib_arch: aarch64
# - os: ubuntu-latest
# platform: Android
# targets: testDebugUnitTest
- os: ubuntu-latest
platform: Linux
targets: compileKotlinLinuxArm64 linuxX64Test
- os: windows-latest
platform: Windows
targets: mingwX64Test
- os: macos-latest
platform: macOS/iOS
targets: macosX64Test macosArm64Test iosSimulatorArm64Test
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
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'
- name: Cache Kotlin/Native prebuilt
uses: actions/cache@v4
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-1.9
- name: Build JNI libraries
if: matrix.platform == 'JVM'
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
uses: actions/cache@v4
if: matrix.platform != 'JVM' && matrix.platform != 'Android'
with:
path: ${{runner.tool_cache}}/konan/dependencies
key: konan-${{runner.os}}-dependencies
- name: Run tests
run: ./gradlew --no-daemon ${{matrix.targets}}
env:
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
- name: Report test results
uses: mikepenz/action-junit-report@v4
if: matrix.platform == 'JVM' && !cancelled()
with:
annotate_only: true
detailed_summary: true
report_paths: ktreesitter/build/reports/xml/*
14 changes: 5 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
name: Docs

# run-name: ${{github.event.workflow_run.head_commit.message}}
run-name: ${{github.event.workflow_run.head_commit.message}}

on:
push:
workflow_run:
workflows: [CI]
types: [completed]
branches: [master]
paths:
- ktreesitter/**
# workflow_run:
# workflows: [CI]
# types: [completed]
# branches: [master]

concurrency:
cancel-in-progress: true
Expand All @@ -24,7 +20,7 @@ jobs:
docs:
runs-on: ubuntu-latest
name: Publish docs on GitHub pages
# if: github.event.workflow_run.conclusion == 'success'
if: github.event.workflow_run.conclusion == 'success'
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Lint

on:
push:
branches: [master]
paths:
- "**/*.kt"
- "**.kts"
pull_request:
paths:
- "**/*.kt"
- "**.kts"

concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref_name}}

permissions:
contents: read
security-events: write

jobs:
ktlint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Install ktlint
run: |-
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.2.1/ktlint
chmod a+x ktlint && mv ktlint $RUNNER_TOOL_CACHE/ktlint
- name: Run ktlint
id: ktlint
run: $RUNNER_TOOL_CACHE/ktlint --reporter=sarif,output=build/reports/ktlint.sarif
- name: Upload report
uses: github/codeql-action/upload-sarif@v3
if: "!cancelled() && steps.ktlint.outcome == 'failure'"
with:
sarif_file: build/reports/ktlint.sarif
category: ktlint
detekt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Install detekt
run: |-
curl -sSLO https://github.com/detekt/detekt/releases/download/v1.23.6/detekt-cli-1.23.6-all.jar
mv detekt-cli-1.23.6-all.jar $RUNNER_TOOL_CACHE/detekt-cli.jar
- name: Run detekt
id: detekt
run: >-
java -jar $RUNNER_TOOL_CACHE/detekt-cli.jar --build-upon-default-config
--jvm-target 17 -c .github/detekt.yml -r sarif:build/reports/detekt.sarif
- name: Upload report
uses: github/codeql-action/upload-sarif@v3
if: "!cancelled() && steps.detekt.outcome == 'failure'"
with:
sarif_file: build/reports/detekt.sarif
category: detekt
Loading

0 comments on commit 05da18e

Please sign in to comment.