Skip to content

Commit

Permalink
Lint actions (#61)
Browse files Browse the repository at this point in the history
* build: Adds crashlytics for iOS (#58)

* chore: Update .pre-commit-config.yaml to include ktlint and detekt (#59)

* Adds kotlin lint actions (#60)

* chore: Exclude build files from kotlin linter

* build: Adds kotlin linting github action
  • Loading branch information
sarvesh-sharma-yral authored Dec 4, 2024
1 parent efb7aaf commit 99276c1
Show file tree
Hide file tree
Showing 16 changed files with 948 additions and 49 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/kotlintlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: KotlinLint

on:
pull_request:
types: [opened, ready_for_review, synchronize]

jobs:
code-analysis:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Get Changed Files
id: changed_files
uses: tj-actions/changed-files@v36
with:
files: |
'**/*.kt'
'**/*.kts'
- name: Run ktlint on Changed Files
if: steps.changed_files.outputs.any_changed == 'true'
run: |
echo "Changed files for ktlint: ${{ steps.changed_files.outputs.all_changed_files }}"
changed_files=$(echo "${{ steps.changed_files.outputs.all_changed_files }}" | tr ' ' '\n')
./gradlew ktlintCheck -PktlintFiles="$changed_files" --console=plain
continue-on-error: true

- name: Run detekt on Changed Files
if: steps.changed_files.outputs.any_changed == 'true'
run: |
echo "Changed files for detekt: ${{ steps.changed_files.outputs.all_changed_files }}"
changed_files=$(echo "${{ steps.changed_files.outputs.all_changed_files }}" | tr ' ' ',')
./gradlew detekt -PdetektFiles="$changed_files" --console=plain
continue-on-error: true

- name: Annotate ktlint Issues
if: failure()
uses: reviewdog/action-setup@v1
with:
name: ktlint
reporter: github-pr-review
filter_mode: added
fail_on_error: true
level: error
format: ktlint
github_token: ${{ secrets.GITHUB_TOKEN }}
tool_name: ktlint
# Read ktlint report
input: './build/reports/ktlint/ktlintMainSourceSetCheck.txt'

- name: Annotate detekt Issues
if: failure()
uses: reviewdog/action-setup@v1
with:
name: detekt
reporter: github-pr-review
filter_mode: added
fail_on_error: true
level: error
format: checkstyle
github_token: ${{ secrets.GITHUB_TOKEN }}
tool_name: detekt
# Read detekt report
input: './build/reports/detekt/detekt.xml'

- name: Upload detekt SARIF Report
if: always() && steps.changed_files.outputs.any_changed == 'true'
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: build/reports/detekt/detekt.sarif
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,19 @@ repos:
hooks:
- id: swiftlint
entry: swiftlint --strict

- repo: local
hooks:
- id: ktlint
name: ktlint
entry: ktlint
language: system
pass_filenames: true
files: \.kt$

- id: detekt
name: detekt
entry: detekt
language: system
pass_filenames: true
files: \.kt$
45 changes: 43 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidApplication).apply(false)
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
Expand All @@ -10,5 +9,47 @@ plugins {

subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "io.gitlab.arturbosch.detekt" )
apply(plugin = "io.gitlab.arturbosch.detekt")

ktlint {
val ktlintFiles = project.findProperty("ktlintFiles") as? String
if (ktlintFiles != null) {
filter {
include(ktlintFiles.split("\n"))
}
}
reporters {
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN)
}
}

detekt {
toolVersion = "1.23.1"
config = files("$rootDir/detekt-config.yml")
buildUponDefaultConfig = true

val detektFiles = project.findProperty("detektFiles") as? String
if (detektFiles != null) {
source = files(detektFiles.split(","))
} else {
// Default source
source = files("src/main/java", "src/main/kotlin")
}

reports {
xml.required.set(true)
xml.outputLocation.set(file("build/reports/detekt/detekt.xml"))
sarif.required.set(true)
sarif.outputLocation.set(file("build/reports/detekt/detekt.sarif"))
}
}

tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
exclude { fileTreeElement ->
val path = fileTreeElement.file.absolutePath
path.contains("/build/") ||
path.endsWith("build.gradle.kts") ||
path.endsWith("settings.gradle.kts")
}
}
}
1 change: 0 additions & 1 deletion iosApp/Generated/SwiftBridgeCore.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swiftlint:disable all

import Foundation

extension RustString {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swiftlint:disable all

public func get_secp256k1_identity(_ jwk_key: JwkEcKey) throws -> Secp256k1Identity {
try { let val = __swift_bridge__$get_secp256k1_identity({jwk_key.isOwned = false; return jwk_key.ptr;}()); if val.is_ok { return Secp256k1Identity(ptr: val.ok_or_err!) } else { throw Secp256k1Error(ptr: val.ok_or_err!) } }()
}
Expand Down
30 changes: 30 additions & 0 deletions iosApp/Prod/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyCAOd0DVP3TLiQ4K-ftmwLR3EhEJDBqedA</string>
<key>GCM_SENDER_ID</key>
<string>1035262663512</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.yral.ios</string>
<key>PROJECT_ID</key>
<string>yral-mobile</string>
<key>STORAGE_BUCKET</key>
<string>yral-mobile.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:1035262663512:ios:52e9d4481e2a5f9b1c232d</string>
</dict>
</plist>
File renamed without changes.
30 changes: 30 additions & 0 deletions iosApp/Staging/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyDS2lgvSQoyx4mWThl0fJF3BDu0S5Jy3Yg</string>
<key>GCM_SENDER_ID</key>
<string>240456866818</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.yral.ios.staging</string>
<key>PROJECT_ID</key>
<string>yral-staging</string>
<key>STORAGE_BUCKET</key>
<string>yral-staging.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:240456866818:ios:e8d8eb052fa6716d791b1b</string>
</dict>
</plist>
48 changes: 48 additions & 0 deletions iosApp/Staging/Info-Staging.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>UILaunchScreen</key>
<dict/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
Loading

0 comments on commit 99276c1

Please sign in to comment.