Skip to content

Commit

Permalink
Merge branch 'master' into feature/test-suite-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6675636b796f75676974687562 authored Mar 3, 2023
2 parents 4eeca04 + 817fbcd commit b05bc72
Show file tree
Hide file tree
Showing 30 changed files with 497 additions and 263 deletions.
37 changes: 20 additions & 17 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
java-version: 11
distribution: temurin
- name: Install system packages
# libcurl is needed for ktor-client-curl, libc-bin for orchestrator
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev libc-bin
# libcurl is needed for ktor-client-curl
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: Retrieve Kotlin version
run: |
kv=$(cat gradle/libs.versions.toml | grep '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
Expand All @@ -40,21 +40,8 @@ jobs:
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
# https://gvisor.dev/docs/user_guide/install/
- name: Install gvisor runsc runtime
run: |
ARCH=$(uname -m)
URL=https://storage.googleapis.com/gvisor/releases/release/latest/${ARCH}
wget -nv ${URL}/runsc ${URL}/runsc.sha512 \
${URL}/containerd-shim-runsc-v1 ${URL}/containerd-shim-runsc-v1.sha512
sha512sum -c runsc.sha512 \
-c containerd-shim-runsc-v1.sha512
rm -f *.sha512
chmod a+rx runsc containerd-shim-runsc-v1
sudo mv runsc containerd-shim-runsc-v1 /usr/local/bin
sudo /usr/local/bin/runsc install
sudo systemctl reload docker
- uses: gradle/gradle-build-action@v2
- name: Build all (excluding tests for save-orchestrator-common)
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
gradle-home-cache-cleanup: true
Expand All @@ -63,6 +50,22 @@ jobs:
-x detekt
-x spotlessCheck
-x :save-agent:linkDebugExecutableLinuxX64
-x :save-orchestrator-common:check
-Pdetekt.multiplatform.disabled=true
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
--scan
--build-cache
- name: Check save-orchestrator-common
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
gradle-home-cache-cleanup: true
arguments: |
:save-orchestrator-common:check
-x detekt
-x spotlessCheck
-x :save-agent:linkDebugExecutableLinuxX64
-Pdetekt.multiplatform.disabled=true
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ dependencies {
)
}

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

dependsOn(rootProject.tasks.named("getSaveCliVersion"))
inputs.file(pathToSaveCliVersion)
inputs.property("project version", version.toString())
outputs.file(versionsFile)

doFirst {
Expand All @@ -68,7 +66,6 @@ val generateVersionFileTaskProvider = tasks.register("generateVersionFile") {
package generated
internal const val SAVE_CORE_VERSION = "$saveCliVersion"
internal const val SAVE_CLOUD_VERSION = "$version"
""".trimIndent()
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Configuration utilities for projects which needs a generated file with SAVE_CLOUD_VERSION
*/

package com.saveourtool.save.buildutils

import java.io.File

tasks.register("generateSaveCloudVersionFile") {
val outputDir = File("$buildDir/generated/src")
val versionsFile = outputDir.resolve("generated/SaveCloudVersion.kt")
inputs.property("project version", version.toString())
outputs.dir("$buildDir/generated/src")

doFirst {
versionsFile.parentFile.mkdirs()
versionsFile.writeText(
"""
package generated
internal const val SAVE_CLOUD_VERSION = "$version"
""".trimIndent()
)
}
}
8 changes: 8 additions & 0 deletions save-agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
kotlin("multiplatform")
alias(libs.plugins.kotlin.plugin.serialization)
id("com.saveourtool.save.buildutils.code-quality-convention")
id("com.saveourtool.save.buildutils.save-cloud-version-file-configuration")
}

kotlin {
Expand Down Expand Up @@ -37,6 +38,13 @@ kotlin {
}

commonMain {
kotlin {
srcDir(
tasks.named("generateSaveCloudVersionFile").map {
it.outputs.files.singleFile
}
)
}
dependencies {
implementation(libs.save.common)
implementation(projects.saveCloudCommon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.saveourtool.save.agent.utils.requiredEnv
import com.saveourtool.save.core.config.LogType
import com.saveourtool.save.core.config.OutputStreamType
import com.saveourtool.save.core.config.ReportType
import generated.SAVE_CLOUD_VERSION

import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -46,7 +47,7 @@ data class AgentConfiguration(
info = AgentInfo(
containerId = requiredEnv(AgentEnvName.CONTAINER_ID),
containerName = requiredEnv(AgentEnvName.CONTAINER_NAME),
version = requiredEnv(AgentEnvName.AGENT_VERSION),
version = SAVE_CLOUD_VERSION,
),
heartbeat = HeartbeatConfig(
url = requiredEnv(AgentEnvName.HEARTBEAT_URL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ internal fun AgentConfiguration.updateFromEnv(): AgentConfiguration {
info = info.copy(
containerId = optionalEnv(AgentEnvName.CONTAINER_ID) ?: info.containerId,
containerName = optionalEnv(AgentEnvName.CONTAINER_NAME) ?: info.containerName,
version = optionalEnv(AgentEnvName.AGENT_VERSION) ?: info.version,
),
heartbeat = heartbeat.copy(
url = optionalEnv(AgentEnvName.HEARTBEAT_URL) ?: heartbeat.url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ open class SaveAgentTest {
init {
setenv(AgentEnvName.CONTAINER_ID.name, "agent-for-test")
setenv(AgentEnvName.CONTAINER_NAME.name, "save-agent-for-test")
setenv(AgentEnvName.AGENT_VERSION.name, "save-agent-version")
setenv(AgentEnvName.HEARTBEAT_URL.name, HEARTBEAT_ENDPOINT.toLocalhostUrl())
setenv(AgentEnvName.CLI_COMMAND.name, "echo Doing nothing it test mode")
setenv(AgentEnvName.EXECUTION_ID.name, "1")
Expand Down
148 changes: 144 additions & 4 deletions save-backend/backend-api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,74 @@
]
}
},
"/api/v1/demo/{organizationName}/{projectName}/start": {
"post": {
"description": "Start demo container if possible, do nothing otherwise.",
"operationId": "startDemo",
"parameters": [
{
"description": "name of saveourtool organization",
"in": "path",
"name": "organizationName",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "name of saveourtool project",
"in": "path",
"name": "projectName",
"required": true,
"schema": {
"type": "string"
}
},
{
"example": "basic",
"in": "header",
"name": "X-Authorization-Source",
"required": true
}
],
"responses": {
"200": {
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
},
"description": "Successfully started demo."
},
"403": {
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
},
"description": "Not enough permission for demo management."
},
"404": {
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
},
"description": "Could not find saveourtool project or demo of a project."
}
},
"summary": "Start demo container.",
"tags": [
"demo-manager-controller"
]
}
},
"/api/v1/demo/{organizationName}/{projectName}/status": {
"get": {
"description": "Get demo status.",
Expand Down Expand Up @@ -2205,7 +2273,8 @@
"NOT_CREATED",
"RUNNING",
"STARTING",
"STOPPED"
"STOPPED",
"STOPPING"
]
}
}
Expand All @@ -2222,7 +2291,8 @@
"NOT_CREATED",
"RUNNING",
"STARTING",
"STOPPED"
"STOPPED",
"STOPPING"
]
}
}
Expand All @@ -2239,7 +2309,8 @@
"NOT_CREATED",
"RUNNING",
"STARTING",
"STOPPED"
"STOPPED",
"STOPPING"
]
}
}
Expand All @@ -2253,6 +2324,74 @@
]
}
},
"/api/v1/demo/{organizationName}/{projectName}/stop": {
"post": {
"description": "Delete demo container if possible, do nothing otherwise.",
"operationId": "stopDemo",
"parameters": [
{
"description": "name of saveourtool organization",
"in": "path",
"name": "organizationName",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "name of saveourtool project",
"in": "path",
"name": "projectName",
"required": true,
"schema": {
"type": "string"
}
},
{
"example": "basic",
"in": "header",
"name": "X-Authorization-Source",
"required": true
}
],
"responses": {
"200": {
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
},
"description": "Successfully stopped demo."
},
"403": {
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
},
"description": "Not enough permission for demo management."
},
"404": {
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
},
"description": "Could not find saveourtool project or demo of a project."
}
},
"summary": "Stop demo.",
"tags": [
"demo-manager-controller"
]
}
},
"/api/v1/demo/{organizationName}/{projectName}/upload-file": {
"post": {
"description": "Attach file to demo.",
Expand Down Expand Up @@ -8436,7 +8575,8 @@
"NOT_CREATED",
"RUNNING",
"STARTING",
"STOPPED"
"STOPPED",
"STOPPING"
]
}
}
Expand Down
Loading

0 comments on commit b05bc72

Please sign in to comment.