Skip to content

Commit decd5f6

Browse files
authored
Merge pull request #1 from maize-genetics/init-clikt-commands
Initial biokotlin-tools repository
2 parents df73c58 + c2f0901 commit decd5f6

13 files changed

+1379
-0
lines changed
+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Run Deployment When Pushing to Master
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'src/**'
10+
11+
jobs:
12+
13+
check-app-changes:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
app_changed: ${{ steps.check_app_changes.outputs.app_changed }}
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v3
20+
with:
21+
token: ${{secrets.BIOKOTLINTOOLSCD}}
22+
fetch-depth: 0
23+
24+
- name: Check if app directory changed
25+
id: check_app_changes
26+
run: |
27+
LAST_RELEASE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
28+
echo "LAST_RELEASE_TAG was $LAST_RELEASE_TAG"
29+
LAST_RELEASE_COMMIT=$(git rev-list -n 1 $LAST_RELEASE_TAG)
30+
echo "LAST_RELEASE_COMMIT was $LAST_RELEASE_COMMIT"
31+
32+
changed_files=$(git diff-tree --no-commit-id --name-only $LAST_RELEASE_COMMIT $GITHUB_SHA | grep '^src' || echo "none")
33+
echo "Changed app files: $changed_files"
34+
35+
if [ "$changed_files" != "none" ]; then
36+
echo "App directory has changed since the last release."
37+
echo "app_changed=true" >> "$GITHUB_OUTPUT"
38+
else
39+
echo "App directory hasn't changed since the last release."
40+
echo "app_changed=false" >> "$GITHUB_OUTPUT"
41+
fi
42+
43+
build-and-release:
44+
runs-on: ubuntu-latest
45+
needs: check-app-changes
46+
if: ${{ needs.check-app-changes.outputs.app_changed == 'true' }}
47+
steps:
48+
49+
- name: Checkout repo
50+
uses: actions/checkout@v3
51+
with:
52+
token: ${{secrets.BIOKOTLINTOOLSCD}}
53+
54+
- name: Setup Miniconda
55+
uses: conda-incubator/setup-miniconda@v2
56+
with:
57+
auto-activate-base: true
58+
activate-environment: ""
59+
miniconda-version: "latest"
60+
61+
# Uses semantic commits to automate version bumping.
62+
# No scope or "fix:" = PATCH, "feat:" or "minor:" = MINOR, "BREAKING CHANGE:", "major:", or fix/feat with appended "!" = MAJOR
63+
# Additional details: https://www.conventionalcommits.org/en/v1.0.0/
64+
- name: Increment version
65+
run: |
66+
#!/bin/bash
67+
COMMIT_MSG=$(git log -1 --pretty=format:"%b" || git log -1 --pretty=format:"%B")
68+
source version.properties
69+
BUMP_TYPE="patchVersion"
70+
71+
if [[ $COMMIT_MSG == *"BREAKING CHANGE"* || $COMMIT_MSG == *"!"* || $COMMIT_MSG == *"major:"* ]]; then
72+
majorVersion=$((majorVersion + 1))
73+
minorVersion=0
74+
patchVersion=0
75+
BUMP_TYPE="majorVersion"
76+
elif [[ $COMMIT_MSG == *"feat:"* || $COMMIT_MSG == *"minor:"* ]]; then
77+
minorVersion=$((minorVersion + 1))
78+
patchVersion=0
79+
BUMP_TYPE="minorVersion"
80+
else
81+
patchVersion=$((patchVersion + 1))
82+
fi
83+
84+
echo "majorVersion=$majorVersion" > version.properties
85+
echo "minorVersion=$minorVersion" >> version.properties
86+
echo "patchVersion=$patchVersion" >> version.properties
87+
88+
VERSION=$majorVersion.$minorVersion.$patchVersion
89+
RELEASE=$majorVersion.$minorVersion
90+
echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_ENV
91+
echo "VERSION=$VERSION" >> $GITHUB_ENV
92+
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
93+
echo "BUMP_TYPE=$BUMP_TYPE" >> $GITHUB_ENV
94+
95+
- name: Commit version changes
96+
uses: EndBug/add-and-commit@v7
97+
with:
98+
add: 'version.properties'
99+
message: Bump ${{ env.BUMP_TYPE }}
100+
author_email: [email protected]
101+
author_name: Git Action Bot
102+
103+
- name: Push changes
104+
uses: ad-m/github-push-action@master
105+
with:
106+
github_token: ${{ secrets.GITHUB_TOKEN }}
107+
branch: ${{ github.ref }}
108+
109+
- name: Set up JDK 17
110+
uses: actions/setup-java@v3
111+
with:
112+
distribution: temurin
113+
java-version: '17'
114+
cache: 'gradle'
115+
- name: Update applications.conf
116+
run: src/scripts/update_applications_conf.sh
117+
- name: Make gradlew executable
118+
run: chmod +x ./gradlew
119+
120+
- name: Build BioKotlin Tools
121+
run: ./gradlew clean build --no-daemon
122+
123+
- name: Get matching release
124+
uses: cardinalby/[email protected]
125+
id: matching_release
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
with:
129+
releaseName: v${{ env.RELEASE }}
130+
doNotFailIfNotFound: 'true'
131+
132+
- name: Delete matching release if exists
133+
if: steps.matching_release.outputs.id != ''
134+
run: |
135+
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.matching_release.outputs.id}}"
136+
137+
# Updates the latest release if just a new patch, drafts a new prerelease if major or minor version has changed
138+
- name: Make github release
139+
uses: svenstaro/upload-release-action@v2
140+
with:
141+
repo_token: ${{ secrets.GITHUB_TOKEN }}
142+
release_name: v${{ env.RELEASE }}
143+
tag: ${{ env.VERSION }}
144+
file: build/distributions/biokotlin-tools.tar
145+
asset_name: BioKotlinTools-v${{ env.RELEASE }}.tar
146+
overwrite: ${{ env.BUMP_TYPE == 'patchVersion' }}
147+
prerelease: ${{ env.BUMP_TYPE != 'patchVersion' }}
148+
body: |
149+
${{ steps.matching_release.outputs.body }}
150+
${{ env.COMMIT_MSG }}
151+

build.gradle.kts

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
// Note Kotlin version needs to be updated in both the buildscript and plugins.
4+
// Dependencies will follow the buildscript
5+
6+
group = "org.biokotlin"
7+
8+
// This build script is need to use the early access
9+
buildscript {
10+
val kotlinVersion by extra("1.9.24")
11+
12+
repositories {
13+
mavenCentral()
14+
gradlePluginPortal()
15+
}
16+
17+
dependencies {
18+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
19+
classpath(kotlin("serialization", version = kotlinVersion))
20+
}
21+
}
22+
23+
24+
plugins {
25+
val kotlinVersion = "1.9.24"
26+
java
27+
kotlin("jvm") version kotlinVersion
28+
kotlin("plugin.serialization") version kotlinVersion
29+
// Shadow allows for the creation of fat jars (all dependencies)
30+
id("com.github.johnrengelman.shadow") version "8.1.1"
31+
32+
application
33+
`java-library`
34+
}
35+
apply {
36+
plugin("kotlinx-serialization")
37+
}
38+
39+
repositories {
40+
mavenCentral()
41+
gradlePluginPortal()
42+
maven("https://maven.imagej.net/content/groups/public/")
43+
maven("https://jitpack.io")
44+
maven("https://dl.bintray.com/kotlin/kotlin-eap")
45+
maven("https://kotlin.bintray.com/kotlinx")
46+
}
47+
48+
dependencies {
49+
50+
val kotlinVersion = rootProject.extra["kotlinVersion"]
51+
52+
implementation("org.biokotlin:biokotlin:0.18")
53+
54+
implementation("org.apache.logging.log4j:log4j-core:2.23.1")
55+
implementation("org.apache.logging.log4j:log4j-api:2.23.1")
56+
57+
implementation("com.github.ajalt.clikt:clikt:4.2.2")
58+
59+
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
60+
implementation("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}")
61+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
62+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2")
63+
64+
implementation("org.nield:kotlin-statistics:1.2.1")
65+
implementation("com.github.holgerbrandl:krangl:0.18")
66+
implementation("org.jetbrains.kotlinx:dataframe:0.8.0-rc-7")
67+
68+
// Biology possible dependencies
69+
// Support fasta, bam, sam, vcf, bcf support
70+
implementation("com.github.samtools:htsjdk:4.0.1")
71+
72+
implementation("org.graalvm.sdk:graal-sdk:21.2.0")
73+
implementation("org.apache.commons:commons-csv:1.8")
74+
75+
implementation("com.google.guava:guava:33.1.0-jre")
76+
implementation("org.apache.tinkerpop:gremlin-core:3.5.1")
77+
implementation("org.jgrapht:jgrapht-core:1.5.1")
78+
79+
implementation("io.github.oshai:kotlin-logging-jvm:5.0.0")
80+
implementation(group = "ch.qos.logback", name = "logback-classic", version = "1.2.6")
81+
implementation("it.unimi.dsi:fastutil:8.5.12")
82+
implementation("org.lz4:lz4-java:1.8.0")
83+
84+
testImplementation("org.junit.jupiter:junit-jupiter:5.8.0")
85+
86+
val kotestVersion = "5.6.2"
87+
listOf("runner-junit5", "assertions-core", "property", "framework-datatest").forEach {
88+
testImplementation("io.kotest:kotest-$it-jvm:$kotestVersion")
89+
}
90+
91+
}
92+
93+
// include versions.properties file in jar file
94+
tasks.jar {
95+
from(sourceSets.main.get().output)
96+
from(projectDir) {
97+
include("version.properties")
98+
}
99+
}
100+
101+
java {
102+
withSourcesJar()
103+
}
104+
105+
tasks.withType<KotlinCompile>().configureEach {
106+
kotlinOptions.jvmTarget = "17"
107+
}
108+
109+
tasks {
110+
println("Source directories: ${sourceSets["main"].allSource.srcDirs}")
111+
}
112+
113+
application {
114+
mainClass.set("biokotlin.cli.BiokotlinToolsKt")
115+
116+
// Set name of generated scripts in bin/
117+
applicationName = "biokotlin-tools"
118+
}
119+
120+
tasks.test {
121+
useJUnitPlatform()
122+
testLogging {
123+
events("passed", "skipped", "failed")
124+
}
125+
}
126+
127+
tasks.jar {
128+
from(sourceSets.main.get().output)
129+
}

gradle/wrapper/gradle-wrapper.jar

42.4 KB
Binary file not shown.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)