Skip to content

Commit b05bc72

Browse files
Merge branch 'master' into feature/test-suite-validation
2 parents 4eeca04 + 817fbcd commit b05bc72

30 files changed

Lines changed: 497 additions & 263 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
java-version: 11
3030
distribution: temurin
3131
- name: Install system packages
32-
# libcurl is needed for ktor-client-curl, libc-bin for orchestrator
33-
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev libc-bin
32+
# libcurl is needed for ktor-client-curl
33+
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
3434
- name: Retrieve Kotlin version
3535
run: |
3636
kv=$(cat gradle/libs.versions.toml | grep '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
@@ -40,21 +40,8 @@ jobs:
4040
with:
4141
path: ~/.konan
4242
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
43-
# https://gvisor.dev/docs/user_guide/install/
44-
- name: Install gvisor runsc runtime
45-
run: |
46-
ARCH=$(uname -m)
47-
URL=https://storage.googleapis.com/gvisor/releases/release/latest/${ARCH}
48-
wget -nv ${URL}/runsc ${URL}/runsc.sha512 \
49-
${URL}/containerd-shim-runsc-v1 ${URL}/containerd-shim-runsc-v1.sha512
50-
sha512sum -c runsc.sha512 \
51-
-c containerd-shim-runsc-v1.sha512
52-
rm -f *.sha512
53-
chmod a+rx runsc containerd-shim-runsc-v1
54-
sudo mv runsc containerd-shim-runsc-v1 /usr/local/bin
55-
sudo /usr/local/bin/runsc install
56-
sudo systemctl reload docker
57-
- uses: gradle/gradle-build-action@v2
43+
- name: Build all (excluding tests for save-orchestrator-common)
44+
uses: gradle/gradle-build-action@v2
5845
with:
5946
gradle-version: wrapper
6047
gradle-home-cache-cleanup: true
@@ -63,6 +50,22 @@ jobs:
6350
-x detekt
6451
-x spotlessCheck
6552
-x :save-agent:linkDebugExecutableLinuxX64
53+
-x :save-orchestrator-common:check
54+
-Pdetekt.multiplatform.disabled=true
55+
-PgprUser=${{ github.actor }}
56+
-PgprKey=${{ secrets.GITHUB_TOKEN }}
57+
--scan
58+
--build-cache
59+
- name: Check save-orchestrator-common
60+
uses: gradle/gradle-build-action@v2
61+
with:
62+
gradle-version: wrapper
63+
gradle-home-cache-cleanup: true
64+
arguments: |
65+
:save-orchestrator-common:check
66+
-x detekt
67+
-x spotlessCheck
68+
-x :save-agent:linkDebugExecutableLinuxX64
6669
-Pdetekt.multiplatform.disabled=true
6770
-PgprUser=${{ github.actor }}
6871
-PgprKey=${{ secrets.GITHUB_TOKEN }}

gradle/plugins/src/main/kotlin/com/saveourtool/save/buildutils/save-cli-configuration.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ dependencies {
5151
)
5252
}
5353

54-
// todo: this logic is duplicated between agent and frontend, can be moved to a shared plugin in gradle/plugins
5554
val generateVersionFileTaskProvider = tasks.register("generateVersionFile") {
5655
val versionsFile = File("$buildDir/generated/src/generated/Versions.kt")
5756

5857
dependsOn(rootProject.tasks.named("getSaveCliVersion"))
5958
inputs.file(pathToSaveCliVersion)
60-
inputs.property("project version", version.toString())
6159
outputs.file(versionsFile)
6260

6361
doFirst {
@@ -68,7 +66,6 @@ val generateVersionFileTaskProvider = tasks.register("generateVersionFile") {
6866
package generated
6967
7068
internal const val SAVE_CORE_VERSION = "$saveCliVersion"
71-
internal const val SAVE_CLOUD_VERSION = "$version"
7269
7370
""".trimIndent()
7471
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Configuration utilities for projects which needs a generated file with SAVE_CLOUD_VERSION
3+
*/
4+
5+
package com.saveourtool.save.buildutils
6+
7+
import java.io.File
8+
9+
tasks.register("generateSaveCloudVersionFile") {
10+
val outputDir = File("$buildDir/generated/src")
11+
val versionsFile = outputDir.resolve("generated/SaveCloudVersion.kt")
12+
inputs.property("project version", version.toString())
13+
outputs.dir("$buildDir/generated/src")
14+
15+
doFirst {
16+
versionsFile.parentFile.mkdirs()
17+
versionsFile.writeText(
18+
"""
19+
package generated
20+
21+
internal const val SAVE_CLOUD_VERSION = "$version"
22+
23+
""".trimIndent()
24+
)
25+
}
26+
}

save-agent/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77
kotlin("multiplatform")
88
alias(libs.plugins.kotlin.plugin.serialization)
99
id("com.saveourtool.save.buildutils.code-quality-convention")
10+
id("com.saveourtool.save.buildutils.save-cloud-version-file-configuration")
1011
}
1112

1213
kotlin {
@@ -37,6 +38,13 @@ kotlin {
3738
}
3839

3940
commonMain {
41+
kotlin {
42+
srcDir(
43+
tasks.named("generateSaveCloudVersionFile").map {
44+
it.outputs.files.singleFile
45+
}
46+
)
47+
}
4048
dependencies {
4149
implementation(libs.save.common)
4250
implementation(projects.saveCloudCommon)

save-agent/src/commonMain/kotlin/com/saveourtool/save/agent/AgentConfiguration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.saveourtool.save.agent.utils.requiredEnv
1010
import com.saveourtool.save.core.config.LogType
1111
import com.saveourtool.save.core.config.OutputStreamType
1212
import com.saveourtool.save.core.config.ReportType
13+
import generated.SAVE_CLOUD_VERSION
1314

1415
import kotlinx.serialization.Serializable
1516

@@ -46,7 +47,7 @@ data class AgentConfiguration(
4647
info = AgentInfo(
4748
containerId = requiredEnv(AgentEnvName.CONTAINER_ID),
4849
containerName = requiredEnv(AgentEnvName.CONTAINER_NAME),
49-
version = requiredEnv(AgentEnvName.AGENT_VERSION),
50+
version = SAVE_CLOUD_VERSION,
5051
),
5152
heartbeat = HeartbeatConfig(
5253
url = requiredEnv(AgentEnvName.HEARTBEAT_URL),

save-agent/src/commonMain/kotlin/com/saveourtool/save/agent/utils/Utils.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ internal fun AgentConfiguration.updateFromEnv(): AgentConfiguration {
2020
info = info.copy(
2121
containerId = optionalEnv(AgentEnvName.CONTAINER_ID) ?: info.containerId,
2222
containerName = optionalEnv(AgentEnvName.CONTAINER_NAME) ?: info.containerName,
23-
version = optionalEnv(AgentEnvName.AGENT_VERSION) ?: info.version,
2423
),
2524
heartbeat = heartbeat.copy(
2625
url = optionalEnv(AgentEnvName.HEARTBEAT_URL) ?: heartbeat.url,

save-agent/src/commonTest/kotlin/com/saveourtool/save/agent/SaveAgentTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ open class SaveAgentTest {
2929
init {
3030
setenv(AgentEnvName.CONTAINER_ID.name, "agent-for-test")
3131
setenv(AgentEnvName.CONTAINER_NAME.name, "save-agent-for-test")
32-
setenv(AgentEnvName.AGENT_VERSION.name, "save-agent-version")
3332
setenv(AgentEnvName.HEARTBEAT_URL.name, HEARTBEAT_ENDPOINT.toLocalhostUrl())
3433
setenv(AgentEnvName.CLI_COMMAND.name, "echo Doing nothing it test mode")
3534
setenv(AgentEnvName.EXECUTION_ID.name, "1")

save-backend/backend-api-docs.json

Lines changed: 144 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,74 @@
21642164
]
21652165
}
21662166
},
2167+
"/api/v1/demo/{organizationName}/{projectName}/start": {
2168+
"post": {
2169+
"description": "Start demo container if possible, do nothing otherwise.",
2170+
"operationId": "startDemo",
2171+
"parameters": [
2172+
{
2173+
"description": "name of saveourtool organization",
2174+
"in": "path",
2175+
"name": "organizationName",
2176+
"required": true,
2177+
"schema": {
2178+
"type": "string"
2179+
}
2180+
},
2181+
{
2182+
"description": "name of saveourtool project",
2183+
"in": "path",
2184+
"name": "projectName",
2185+
"required": true,
2186+
"schema": {
2187+
"type": "string"
2188+
}
2189+
},
2190+
{
2191+
"example": "basic",
2192+
"in": "header",
2193+
"name": "X-Authorization-Source",
2194+
"required": true
2195+
}
2196+
],
2197+
"responses": {
2198+
"200": {
2199+
"content": {
2200+
"*/*": {
2201+
"schema": {
2202+
"type": "string"
2203+
}
2204+
}
2205+
},
2206+
"description": "Successfully started demo."
2207+
},
2208+
"403": {
2209+
"content": {
2210+
"*/*": {
2211+
"schema": {
2212+
"type": "string"
2213+
}
2214+
}
2215+
},
2216+
"description": "Not enough permission for demo management."
2217+
},
2218+
"404": {
2219+
"content": {
2220+
"*/*": {
2221+
"schema": {
2222+
"type": "string"
2223+
}
2224+
}
2225+
},
2226+
"description": "Could not find saveourtool project or demo of a project."
2227+
}
2228+
},
2229+
"summary": "Start demo container.",
2230+
"tags": [
2231+
"demo-manager-controller"
2232+
]
2233+
}
2234+
},
21672235
"/api/v1/demo/{organizationName}/{projectName}/status": {
21682236
"get": {
21692237
"description": "Get demo status.",
@@ -2205,7 +2273,8 @@
22052273
"NOT_CREATED",
22062274
"RUNNING",
22072275
"STARTING",
2208-
"STOPPED"
2276+
"STOPPED",
2277+
"STOPPING"
22092278
]
22102279
}
22112280
}
@@ -2222,7 +2291,8 @@
22222291
"NOT_CREATED",
22232292
"RUNNING",
22242293
"STARTING",
2225-
"STOPPED"
2294+
"STOPPED",
2295+
"STOPPING"
22262296
]
22272297
}
22282298
}
@@ -2239,7 +2309,8 @@
22392309
"NOT_CREATED",
22402310
"RUNNING",
22412311
"STARTING",
2242-
"STOPPED"
2312+
"STOPPED",
2313+
"STOPPING"
22432314
]
22442315
}
22452316
}
@@ -2253,6 +2324,74 @@
22532324
]
22542325
}
22552326
},
2327+
"/api/v1/demo/{organizationName}/{projectName}/stop": {
2328+
"post": {
2329+
"description": "Delete demo container if possible, do nothing otherwise.",
2330+
"operationId": "stopDemo",
2331+
"parameters": [
2332+
{
2333+
"description": "name of saveourtool organization",
2334+
"in": "path",
2335+
"name": "organizationName",
2336+
"required": true,
2337+
"schema": {
2338+
"type": "string"
2339+
}
2340+
},
2341+
{
2342+
"description": "name of saveourtool project",
2343+
"in": "path",
2344+
"name": "projectName",
2345+
"required": true,
2346+
"schema": {
2347+
"type": "string"
2348+
}
2349+
},
2350+
{
2351+
"example": "basic",
2352+
"in": "header",
2353+
"name": "X-Authorization-Source",
2354+
"required": true
2355+
}
2356+
],
2357+
"responses": {
2358+
"200": {
2359+
"content": {
2360+
"*/*": {
2361+
"schema": {
2362+
"type": "string"
2363+
}
2364+
}
2365+
},
2366+
"description": "Successfully stopped demo."
2367+
},
2368+
"403": {
2369+
"content": {
2370+
"*/*": {
2371+
"schema": {
2372+
"type": "string"
2373+
}
2374+
}
2375+
},
2376+
"description": "Not enough permission for demo management."
2377+
},
2378+
"404": {
2379+
"content": {
2380+
"*/*": {
2381+
"schema": {
2382+
"type": "string"
2383+
}
2384+
}
2385+
},
2386+
"description": "Could not find saveourtool project or demo of a project."
2387+
}
2388+
},
2389+
"summary": "Stop demo.",
2390+
"tags": [
2391+
"demo-manager-controller"
2392+
]
2393+
}
2394+
},
22562395
"/api/v1/demo/{organizationName}/{projectName}/upload-file": {
22572396
"post": {
22582397
"description": "Attach file to demo.",
@@ -8436,7 +8575,8 @@
84368575
"NOT_CREATED",
84378576
"RUNNING",
84388577
"STARTING",
8439-
"STOPPED"
8578+
"STOPPED",
8579+
"STOPPING"
84408580
]
84418581
}
84428582
}

0 commit comments

Comments
 (0)