Skip to content

Commit

Permalink
Доработки в презентации
Browse files Browse the repository at this point in the history
  • Loading branch information
LimeBeck committed Apr 15, 2024
1 parent a9ae7a4 commit 5bdf1cb
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 74 deletions.
38 changes: 14 additions & 24 deletions gitlab-ci-kts/script-definition/example/.gitlab-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,33 @@
stages:
- build-dev-0
- deploy-dev-0
- build-dev-1
- deploy-dev-1
- build-dev-2
- deploy-dev-2
build-dev-0:
stage: build-dev-0
- build
- deploy
build:
stage: build
image:
name: alpine:latest
script:
- echo 'Hello World from dev-0'
- echo 'Hello World from build'
deploy-dev-0:
stage: deploy-dev-0
stage: deploy
image:
name: alpine:latest
needs:
- build
script:
- echo Deployed dev-0
build-dev-1:
stage: build-dev-1
image:
name: alpine:latest
script:
- echo 'Hello World from dev-1'
deploy-dev-1:
stage: deploy-dev-1
stage: deploy
image:
name: alpine:latest
needs:
- build
script:
- echo Deployed dev-1
build-dev-2:
stage: build-dev-2
image:
name: alpine:latest
script:
- echo 'Hello World from dev-2'
deploy-dev-2:
stage: deploy-dev-2
stage: deploy
image:
name: alpine:latest
needs:
- build
script:
- echo Deployed dev-2
11 changes: 7 additions & 4 deletions gitlab-ci-kts/script-definition/example/main.gitlab-ci.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
val build = job("build") {
stage = Stage("build")
image = Image.of("alpine:latest")
script("echo 'Hello World from build'")
}
listOf("dev-0", "dev-1", "dev-2").forEach {
job("build-$it") {
image = Image.of("alpine:latest")
script("echo 'Hello World from $it'")
}
job("deploy-$it") {
stage = Stage("deploy")
needs(build)
image = Image.of("alpine:latest")
script("echo Deployed $it")
}
Expand Down
115 changes: 69 additions & 46 deletions presentation/kotlin-script.reveal.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ slides {
"Техлид JVM Backend в Банке Центр-инвест",
"Пишу на Kotlin больше 5 лет",
"Фанат Kotlin",
"Написал эту презентацию на Kotlin"
),
fragmented = false
)
Expand All @@ -61,13 +60,6 @@ slides {
}
}

verticalSlide {
slide {
+title { "Kotlin Script" }
+title { "для кого, зачем и как" }
}
}

verticalSlide {
slide {
+smallTitle { "Примеры использования" }
Expand All @@ -80,13 +72,6 @@ slides {
}
}

slide {
+smallTitle { "Простое CLI приложение" }
+kotlinCode {
loadAsset("test.main.kts").decodeToString()
}
}

// slide {
// +smallTitle { "Jetbrains Teamcity CI/CD DSL" }
// +kotlinCode {
Expand All @@ -108,6 +93,13 @@ slides {
}
}

slide {
+smallTitle { "Простое CLI приложение" }
+kotlinCode {
loadAsset("test.main.kts").decodeToString()
}
}

slide {
+smallTitle { "Live-Plugin" }
+smallTitle { "(простые плагины для IDEA)" }
Expand Down Expand Up @@ -437,7 +429,7 @@ slides {
+smallTitle { "Shebang для .java" }
+code(lang = "bash") {
"""
///usr/bin/env java "${'$'}0" "${'$'}@" ; exit ${'$'}?
///usr/bin/env java "$`$`0" "$`$`@" ; exit $`$`?
""".trimIndent()
}
}
Expand Down Expand Up @@ -691,12 +683,15 @@ slides {
+smallTitle { "Gitlab-CI.kts" }
+kotlinCode {
"""
val build = job("build") {
stage = Stage("build")
image = Image.of("alpine:latest")
script("echo 'Hello World from build'")
}
listOf("dev-0", "dev-1", "dev-2").forEach {
job("build-$`$`it") {
image = Image.of("alpine:latest")
script("echo 'Hello World from $`$`it'")
}
job("deploy-$`$`it") {
stage = Stage("deploy")
needs(build)
image = Image.of("alpine:latest")
script("echo Deployed $`$`it")
}
Expand All @@ -705,7 +700,47 @@ slides {
}
+code(lang = "bash") {
"""
> java -jar gitlab-cli.jar ./main.gitlab-ci.kts > .gitlab.ci.yaml
> java -jar gitlab-cli.jar ./main.gitlab-ci.kts > .gitlab-ci.yaml
""".trimIndent()
}
}
slide {
+regular { ".gitlab-ci.yaml" }
+code(lang = "yaml", lines = "|1-3|4-9|10-17|18-25|26-33") {
"""
stages:
- build
- deploy
build:
stage: build
image:
name: alpine:latest
script:
- echo 'Hello World from build'
deploy-dev-0:
stage: deploy
image:
name: alpine:latest
needs:
- build
script:
- echo Deployed dev-0
deploy-dev-1:
stage: deploy
image:
name: alpine:latest
needs:
- build
script:
- echo Deployed dev-1
deploy-dev-2:
stage: deploy
image:
name: alpine:latest
needs:
- build
script:
- echo Deployed dev-2
""".trimIndent()
}
}
Expand Down Expand Up @@ -792,30 +827,31 @@ slides {
"Импорты по умолчанию",
"Конфигурация IDE",
"Параметры компилятора Kotlin",
"Доступные в скрипте свойства",
"Определение неявных (implicit) ресиверов",
"Доступные в скрипте свойства"
)
}

slide {
+compilationTitle
+exampleTitle
+kotlinCode(
lines = "|2-4|5-10|11|12"
lines = "|2-4|5-9|10|11|12|13"
) {
"""
object GitlabCiKtScriptCompilationConfiguration : ScriptCompilationConfiguration({
jvm {
dependenciesFromClassContext(PipelineBuilder::class, wholeClasspath = true)
}
defaultImports(DependsOn::class, Repository::class)
defaultImports(
"dev.otbe.gitlab.ci.core.model.*",
"dev.otbe.gitlab.ci.dsl.*",
"dev.otbe.gitlab.ci.core.goesTo"
)
implicitReceivers(PipelineBuilder::class)
ide { acceptedLocations(ScriptAcceptedLocation.Everywhere) }
compilerOptions.append("-Xcontext-receivers")
providedProperties("propName" to String::class)
implicitReceivers(PipelineBuilder::class)
})
""".trimIndent()
}
Expand All @@ -827,9 +863,9 @@ slides {
+kotlinCode {
"""
class PipelineBuilder {
private var stages: List<Stage> = emptyList()
fun stages(vararg stage: Stage) {
stages = stage.asList()
var stages: List<Stage> = mutableListOf()
fun stages(vararg stage: String) {
stages += stage.asList().map { Stage(it) }
}
}
""".trimIndent()
Expand Down Expand Up @@ -860,9 +896,10 @@ slides {
slide {
+compilationTitle
+externalDeps
+kotlinCode(lines = "2-9") {
+kotlinCode(lines = "2-10") {
"""
object GitlabCiKtScriptCompilationConfiguration : ScriptCompilationConfiguration({
defaultImports(DependsOn::class, Repository::class)
refineConfiguration {
onAnnotations(
DependsOn::class,
Expand All @@ -875,14 +912,15 @@ slides {
jvm {
dependenciesFromClassContext(PipelineBuilder::class, wholeClasspath = true)
}
defaultImports(DependsOn::class, Repository::class)
defaultImports(
"dev.otbe.gitlab.ci.core.model.*",
"dev.otbe.gitlab.ci.dsl.*",
"dev.otbe.gitlab.ci.core.goesTo"
)
implicitReceivers(PipelineBuilder::class)
ide { acceptedLocations(ScriptAcceptedLocation.Everywhere) }
compilerOptions.append("-Xcontext-receivers")
providedProperties("propName" to String::class)
implicitReceivers(PipelineBuilder::class)
}
""".trimIndent()
}
Expand Down Expand Up @@ -1018,10 +1056,6 @@ slides {
slide {
+loaderTitle
}
slide {
+loaderTitle
+smallTitle { "\"Evaluate and run\"" }
}
slide {
+loaderTitle
+kotlinCode {
Expand Down Expand Up @@ -1097,13 +1131,6 @@ slides {
slide {
+smallTitle { "Абстракция в JVM для исполнения скриптов" }
}
// slide {
// +smallTitle { "Kotlin Script > JSR223" }
// +unorderedListOf(
// "Интеграция с IDE",
// fragmented = false
// )
// }
slide {
+smallTitle { "Kotlin Script + JSR223" }
+regular { "Обертка поверх BasicJvmScriptingHost" }
Expand Down Expand Up @@ -1146,10 +1173,6 @@ slides {
}
}

// slide {
// +smallTitle { "Компиляция скриптов с исходниками" }
// }

slide {
+smallTitle { "Итого по Kotlin Script" }
+unorderedListOf(
Expand Down

0 comments on commit 5bdf1cb

Please sign in to comment.