Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee committed Jul 8, 2017
2 parents 0f0c51a + 0ff5196 commit 39210fd
Show file tree
Hide file tree
Showing 141 changed files with 2,491 additions and 804 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
## [0.9.0]
### Added
- ...
- Adds a bot to allow simple borrow/return of items.
- Adds a new 'items' backend.
- Makes join message conditional.
- Adds MySQL store.
- Now supports multiple templates.

### Changed
- Internal structural improvements to support multiple back-end or front-end implementations.
- Improved specification coverage.
- Externalised templates to allow messages to be changed.

## [0.8.1] - 2017-06-11
### Added
Expand Down
4 changes: 2 additions & 2 deletions backends/deployment/jenkins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ apply plugin: 'kotlin'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$version_kotlin"

compile project(':backends:deployment:jobs')
compile project(':core:rest')
compile project(':backends:deployment:backends-deployment-jobs')
compile project(':core:core-rest')
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.gatehill.corebot.driver.jenkins.action

import com.gatehill.corebot.action.LockService
import com.gatehill.corebot.action.driver.ActionDriver
import com.gatehill.corebot.action.driver.JobBaseActionDriver
import com.gatehill.corebot.driver.ActionDriver
import com.gatehill.corebot.driver.base.action.ApiClientBuilder
import com.gatehill.corebot.driver.jenkins.config.DriverSettings
import com.gatehill.corebot.driver.jobs.action.JobBaseActionDriver
import okhttp3.Credentials
import java.util.*
import java.util.HashMap
import javax.inject.Inject

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import com.gatehill.corebot.driver.jenkins.model.BuildDetails
import com.gatehill.corebot.driver.jenkins.model.QueuedItem
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.*
import retrofit2.http.Field
import retrofit2.http.FieldMap
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

/**
* Models the Jenkins API.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.gatehill.corebot.driver.jenkins.action

import com.gatehill.corebot.action.ActionOutcomeService
import com.gatehill.corebot.action.BaseJobTriggerService
import com.gatehill.corebot.action.LockService
import com.gatehill.corebot.action.model.ActionStatus
import com.gatehill.corebot.action.model.PerformActionResult
import com.gatehill.corebot.action.model.TriggerContext
import com.gatehill.corebot.action.model.TriggeredAction
import com.gatehill.corebot.config.model.ActionConfig
import com.gatehill.corebot.driver.jenkins.config.DriverSettings
import com.gatehill.corebot.driver.jenkins.model.BuildDetails
import com.gatehill.corebot.driver.jobs.service.BaseJobTriggerService
import com.gatehill.corebot.driver.model.ActionStatus
import com.gatehill.corebot.driver.model.TriggeredAction
import com.gatehill.corebot.util.onException
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
Expand Down Expand Up @@ -46,7 +46,7 @@ class JenkinsJobTriggerService @Inject constructor(private val actionDriver: Jen
parameters = args
)

} catch(e: Exception) {
} catch (e: Exception) {
future.completeExceptionally(RuntimeException("Error building API client or obtaining CSRF token", e))
return
}
Expand Down
23 changes: 22 additions & 1 deletion backends/deployment/jobs/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin"
classpath "org.junit.platform:junit-platform-gradle-plugin:$version_junit_platform_gradle"
}
}

apply plugin: 'kotlin'
apply plugin: 'org.junit.platform.gradle.plugin'

junitPlatform {
platformVersion version_junit_platform_gradle
filters {
engines {
include 'spek'
}
}
}

repositories {
maven { url 'http://dl.bintray.com/jetbrains/spek' }
}

dependencies {
compile project(':core:engine')
compile project(':core:core-engine')

testCompile "org.amshove.kluent:kluent:$version_kluent"
testCompile "org.jetbrains.spek:spek-api:$version_spek"
testRuntime "org.jetbrains.spek:spek-junit-platform-engine:$version_spek"
testRuntime "org.junit.platform:junit-platform-launcher:$version_junit_platform_gradle"
testCompile "com.nhaarman:mockito-kotlin-kt1.1:$version_mockito_kotlin"
}

publishing {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.gatehill.corebot.action.driver
package com.gatehill.corebot.driver.jobs.action

import com.gatehill.corebot.action.JobTriggerService
import com.gatehill.corebot.action.LockService
import com.gatehill.corebot.action.model.ActionType
import com.gatehill.corebot.action.model.PerformActionResult
import com.gatehill.corebot.action.model.TriggerContext
import com.gatehill.corebot.chat.model.action.ActionType
import com.gatehill.corebot.chat.model.template.JobActionType
import com.gatehill.corebot.config.model.ActionConfig
import com.gatehill.corebot.driver.BaseActionDriver
import com.gatehill.corebot.driver.jobs.action.factory.JobActionType
import com.gatehill.corebot.driver.jobs.service.JobTriggerService
import java.util.concurrent.CompletableFuture
import javax.inject.Inject

Expand All @@ -26,7 +27,7 @@ abstract class JobBaseActionDriver @Inject constructor(private val jobTriggerSer
}
return true

} catch(e: Exception) {
} catch (e: Exception) {
future.completeExceptionally(e)
return false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.gatehill.corebot.driver.jobs.action

import com.gatehill.corebot.action.ActionFactoryConverter
import com.gatehill.corebot.action.factory.ActionFactory
import com.gatehill.corebot.chat.ChatGenerator
import com.gatehill.corebot.config.model.ActionConfig
import com.gatehill.corebot.driver.jobs.action.factory.TriggerJobFactory
import javax.inject.Inject

/**
* @author Pete Cornish {@literal <[email protected]>}
*/
class TriggerActionFactoryConverter @Inject constructor(private val chatGenerator: ChatGenerator) : ActionFactoryConverter {
override fun convertConfigToFactory(configs: Iterable<ActionConfig>): Collection<ActionFactory> =
configs.map { TriggerJobFactory(it, chatGenerator) }.toList()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.gatehill.corebot.driver.jobs.action.factory

import com.gatehill.corebot.action.factory.ActionMessageMode
import com.gatehill.corebot.action.factory.NamedActionFactory
import com.gatehill.corebot.action.factory.Template
import com.gatehill.corebot.action.model.ActionType
import com.gatehill.corebot.config.ConfigService
import javax.inject.Inject

/**
* Disables a job.
*/
@Template("disableJob", builtIn = true, showInUsage = true, actionMessageMode = ActionMessageMode.INDIVIDUAL)
class DisableJobFactory @Inject constructor(configService: ConfigService) : NamedActionFactory(configService) {
override val actionType: ActionType = JobActionType.DISABLE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.gatehill.corebot.driver.jobs.action.factory

import com.gatehill.corebot.action.factory.ActionMessageMode
import com.gatehill.corebot.action.factory.NamedActionFactory
import com.gatehill.corebot.action.factory.Template
import com.gatehill.corebot.action.model.ActionType
import com.gatehill.corebot.config.ConfigService
import javax.inject.Inject

/**
* Enables a job.
*/
@Template("enableJob", builtIn = true, showInUsage = true, actionMessageMode = ActionMessageMode.INDIVIDUAL)
class EnableJobFactory @Inject constructor(configService: ConfigService) : NamedActionFactory(configService) {
override val actionType: ActionType = JobActionType.ENABLE
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.gatehill.corebot.chat.model.template
package com.gatehill.corebot.driver.jobs.action.factory

import com.gatehill.corebot.chat.model.action.ActionType
import com.gatehill.corebot.chat.model.action.CoreActionType
import com.gatehill.corebot.action.model.ActionType
import com.gatehill.corebot.action.model.CoreActionType

/**
* Extends the action types with job specific actions.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.gatehill.corebot.driver.jobs.action.factory

import com.gatehill.corebot.action.factory.ActionMessageMode
import com.gatehill.corebot.action.factory.CustomActionFactory
import com.gatehill.corebot.action.factory.Template
import com.gatehill.corebot.action.model.ActionType
import com.gatehill.corebot.action.model.TriggerContext
import com.gatehill.corebot.chat.ChatGenerator
import com.gatehill.corebot.chat.filter.StringFilter
import com.gatehill.corebot.config.model.ActionConfig

/**
* Triggers job execution.
*/
@Template("triggerJob", builtIn = false, showInUsage = true, actionMessageMode = ActionMessageMode.INDIVIDUAL)
class TriggerJobFactory(action: ActionConfig,
private val chatGenerator: ChatGenerator) : CustomActionFactory() {

override val actionType: ActionType = JobActionType.TRIGGER
override val actionConfigs: List<ActionConfig>

init {
this.actionConfigs = mutableListOf(action)
parsers += StringFilter.StringFilterConfig(action.template, action.template)
}

override fun buildStartMessage(trigger: TriggerContext, options: Map<String, String>, actionConfig: ActionConfig?): String {
actionConfig ?: throw IllegalArgumentException("Empty actionConfig")

val msg = StringBuilder()
msg.append("${chatGenerator.pleaseWait()}, I'm running *${actionConfig.name}*")

if (options.isNotEmpty()) {
msg.append(" with these options:")
options.forEach { arg -> msg.append("\r\n- ${arg.key}: _${arg.value}_") }
} else {
msg.append(".")
}

return msg.toString()
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.gatehill.corebot.action
package com.gatehill.corebot.driver.jobs.service

import com.gatehill.corebot.action.model.ActionStatus
import com.gatehill.corebot.action.ActionOutcomeService
import com.gatehill.corebot.action.LockService
import com.gatehill.corebot.action.model.PerformActionResult
import com.gatehill.corebot.action.model.TriggerContext
import com.gatehill.corebot.action.model.TriggeredAction
import com.gatehill.corebot.config.Settings
import com.gatehill.corebot.config.model.ActionConfig
import com.gatehill.corebot.driver.model.ActionStatus
import com.gatehill.corebot.driver.model.TriggeredAction
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import java.util.*
import java.util.Timer
import java.util.TimerTask
import java.util.concurrent.CompletableFuture

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gatehill.corebot.action
package com.gatehill.corebot.driver.jobs.service

import com.gatehill.corebot.action.model.PerformActionResult
import com.gatehill.corebot.action.model.TriggerContext
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Templates for jobs backend.
---
disableJob:
- template: disable {action or tag name}

enableJob:
- template: enable {action or tag name}
Loading

0 comments on commit 39210fd

Please sign in to comment.