Skip to content

Commit eb3c821

Browse files
committed
continued build action
improved build action use dedicated task for apt-get removed python-software-properties from build action fixed syntax errror in build action skip apt-get and fixed sdkman initialization in github build action Use kotlin v1.4.32 in build action source sdk init more often in github build action fixed working directory in github build action Use bundled gradle in build action added ore debug statements to github action declare default shell in github action use bash shell in github action fixed syntax in github action fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) fixed syntax in github action (cont) Fixed version check and support api locator id Added test debugging bits in github action disabled packaging-test in github action github action debugging Fixed klaxon dependency in tests continued github action debugging fixed syntax error in action definition fixed syntax error in action definition fixed library versions in tests reenabled debug step in github action Added mock idea to PATH in github action Cleaned up github action
1 parent 6b0d4ea commit eb3c821

File tree

5 files changed

+79
-27
lines changed

5 files changed

+79
-27
lines changed

.github/workflows/build.yml

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,77 @@ jobs:
1212
build:
1313

1414
runs-on: ubuntu-latest
15+
# defaults:
16+
# run:
17+
# shell: bash
18+
# working-directory: $GITHUB_WORKSPACE
1519

1620
steps:
1721
- uses: actions/checkout@v2
18-
# https://stackoverflow.com/questions/56726429/how-to-run-multiple-commands-in-one-github-actions-docker
22+
# https://stackoverflow.com/questions/56726429/how-to-run-multiple-commands-in-one-github-actions-docker
23+
1924
- name: Set up JDK 11
2025
uses: actions/setup-java@v1
2126
with:
2227
java-version: 11
23-
- run: |
24-
apt-get update
25-
apt-get install -y python-software-properties
26-
apt-get install -y curl unzip zip wget
28+
29+
# - name: Update system dependencies
30+
# run: |
31+
# sudo apt-get update
32+
# sudo apt-get install -y curl unzip zip wget
33+
34+
- name: Install sdkman
35+
run: |
2736
bash -c "curl -s "https://get.sdkman.io" | bash"
28-
source "/home/travis/.sdkman/bin/sdkman-init.sh"
29-
- run: sdk install kotlin
30-
- run: sdk install gradle
31-
- name: Grant execute permission for gradlew
32-
run: chmod +x gradlew
37+
source "/home/runner/.sdkman/bin/sdkman-init.sh"
38+
39+
- name: Install kotlin
40+
run: |
41+
source "/home/runner/.sdkman/bin/sdkman-init.sh"
42+
sdk install kotlin 1.4.31
43+
44+
- name: Install gradle
45+
run: |
46+
source "/home/runner/.sdkman/bin/sdkman-init.sh"
47+
sdk install gradle 6.7
48+
49+
50+
# https://stackoverflow.com/questions/50104666/gradle-difference-between-test-and-check
3351
- name: Build and test with Gradle
34-
# https://stackoverflow.com/questions/50104666/gradle-difference-between-test-and-check
35-
# https://stackoverflow.com/questions/50104666/gradle-difference-between-test-and-check
36-
run: ./gradlew clean check --stacktrace --info
37-
- env:
38-
# https://docs.github.com/en/actions/reference/environment-variables
39-
KSCRIPT_HOME: $GITHUB_WORKSPACE
40-
- run: cd $KSCRIPT_HOME && ./gradlew assemble
41-
# install assert.h
42-
- run: get https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh && chmod +x assert.sh
52+
# working-directory: $GITHUB_WORKSPACE
53+
run: |
54+
echo $GITHUB_WORKSPACE
55+
chmod +x gradlew
56+
./gradlew clean check --stacktrace --info
57+
58+
59+
- name: Build kscript
60+
run: ./gradlew assemble
61+
62+
- name: Install assert.sh
63+
run: |
64+
wget https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh
65+
chmod +x assert.sh
66+
67+
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
68+
- name: Update PATH to include kscrript
69+
run: echo "${GITHUB_WORKSPACE}/build/libs" >> $GITHUB_PATH
70+
4371
- run: which kscript
44-
- run: kscript --version
45-
- run: touch idea && chmod +x idea
46-
- run: cd $KSCRIPT_HOME && ./test/test_suite.sh
72+
73+
- name: Print --version
74+
run: |
75+
source "/home/runner/.sdkman/bin/sdkman-init.sh"
76+
kscript --version
77+
78+
- name: Create mock idea executable
79+
run: |
80+
touch idea
81+
chmod +x idea
82+
echo "${PWD}" >> $GITHUB_PATH
83+
84+
- name: Run tests
85+
run: |
86+
source "/home/runner/.sdkman/bin/sdkman-init.sh"
87+
export KSCRIPT_HOME="$GITHUB_WORKSPACE"
88+
./test/test_suite.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ Using annotations instead of comment directives to configure scripts is cleaner
334334

335335
// Declare dependencies
336336
@file:DependsOn("com.github.holgerbrandl:kutils:0.12")
337-
@file:DependsOn("com.beust:klaxon:0.24", "com.github.kittinunf.fuel:fuel:1.3.1")
337+
@file:DependsOn("com.beust:klaxon:0.24", "com.github.kittinunf.fuel:fuel:2.3.1")
338338

339339

340340
// To use a custom maven repository you can declare it with

src/main/kotlin/kscript/app/Kscript.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import java.io.BufferedReader
77
import java.io.File
88
import java.io.FileInputStream
99
import java.io.InputStreamReader
10+
import java.lang.IllegalArgumentException
1011
import java.net.URI
1112
import java.net.URL
1213
import java.net.UnknownHostException
14+
import java.util.*
1315
import kotlin.system.exitProcess
1416

1517

@@ -304,7 +306,15 @@ private fun versionCheck() {
304306
return // skip version check here, since the use has no connection to the internet at the moment
305307
}
306308

307-
fun padVersion(version: String) = java.lang.String.format("%03d%03d%03d", *version.split(".").map { Integer.valueOf(it) }.toTypedArray())
309+
fun padVersion(version: String) = try{
310+
var versionNumbers = version.split(".").map { Integer.valueOf(it) }
311+
// adjust versions without a patch-release
312+
while(versionNumbers.size!=3){ versionNumbers = versionNumbers + 0 }
313+
314+
java.lang.String.format("%03d%03d%03d", *versionNumbers.toTypedArray())
315+
}catch(e: MissingFormatArgumentException){
316+
throw IllegalArgumentException("Could not pad version $version", e)
317+
}
308318

309319
if (padVersion(latestVersion) > padVersion(KSCRIPT_VERSION)) {
310320
info("""A new version (v${latestVersion}) of kscript is available.""")
@@ -392,7 +402,7 @@ private fun resolvePreambles(rawScript: File, enableSupportApi: Boolean): File {
392402
// prefix with text-processing preamble if kscript-support api is enabled
393403
if (enableSupportApi) {
394404
val textProcPreamble = """
395-
//DEPS com.github.holgerbrandl:kscript-support:1.2.5
405+
//DEPS com.github.holgerbrandl:kscript-support-api:1.2.5
396406
397407
import kscript.text.*
398408
val lines = resolveArgFile(args)

test/resources/custom_dsl/mydsl_test_with_deps.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env mydsl
22

3-
@file:DependsOn("com.beust:klaxon:0.24")
3+
@file:DependsOn("com.beust:klaxon:5.5")
44

55

66
// instantiate something from extra dep

test/resources/script_with_compile_flags.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env kscript
22

33
@file:DependsOn("org.jetbrains.kotlin:kotlin-reflect:1.1.60")
4-
@file:DependsOn("com.github.kittinunf.fuel:fuel-jackson:1.12.0")
4+
@file:DependsOn("com.github.kittinunf.fuel:fuel-jackson:2.3.1")
55

66
@file:CompilerOpts("-jvm-target 1.8")
77

0 commit comments

Comments
 (0)