-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #964 from Vacxe/ci-integrations
feat(core): basic ci integration
- Loading branch information
Showing
7 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
configuration/src/main/kotlin/com/malinskiy/marathon/config/CIConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.malinskiy.marathon.config | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.PROPERTY, | ||
property = "type" | ||
) | ||
@JsonSubTypes( | ||
JsonSubTypes.Type(value = CIConfiguration.Auto::class, name = "auto"), | ||
JsonSubTypes.Type(value = CIConfiguration.None::class, name = "none"), | ||
JsonSubTypes.Type(value = CIConfiguration.Teamcity::class, name = "teamcity"), | ||
) | ||
sealed class CIConfiguration { | ||
object Auto : CIConfiguration() | ||
object None : CIConfiguration() | ||
object Teamcity : CIConfiguration() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
core/src/main/kotlin/com/malinskiy/marathon/integrations/ci/CI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.malinskiy.marathon.integrations.ci | ||
|
||
interface CI { | ||
fun setBuildProgress(int: Int) | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/main/kotlin/com/malinskiy/marathon/integrations/ci/CIIntegrationFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.malinskiy.marathon.integrations.ci | ||
|
||
import com.malinskiy.marathon.config.CIConfiguration | ||
import com.malinskiy.marathon.config.Configuration | ||
|
||
object CIIntegrationFactory { | ||
fun get(configuration: Configuration) = when (configuration.ciConfiguration) { | ||
CIConfiguration.Auto -> auto() | ||
CIConfiguration.None -> None | ||
CIConfiguration.Teamcity -> Teamcity | ||
} | ||
|
||
private fun auto() = when { | ||
// Teamcity predefined variables: https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#84e0b866 | ||
System.getenv().containsValue("TEAMCITY_VERSION") -> Teamcity | ||
else -> None | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
core/src/main/kotlin/com/malinskiy/marathon/integrations/ci/None.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.malinskiy.marathon.integrations.ci | ||
|
||
object None: CI { | ||
override fun setBuildProgress(int: Int) = Unit | ||
} |
9 changes: 9 additions & 0 deletions
9
core/src/main/kotlin/com/malinskiy/marathon/integrations/ci/Teamcity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.malinskiy.marathon.integrations.ci | ||
|
||
object Teamcity: CI { | ||
private fun setBuildMessage(message: String) = println("##teamcity[buildStatus text='$message']") | ||
|
||
private fun setKeyValue(key: String, value: String) = println("##teamcity[buildStatisticValue key='$key' value='$value']") | ||
|
||
override fun setBuildProgress(int: Int) = setBuildMessage("Marathon run: $int %") | ||
} |