Skip to content

Commit

Permalink
everything set for publishing before the refactor of package from ai.…
Browse files Browse the repository at this point in the history
…codium to ai.qodo
  • Loading branch information
davidparry committed Sep 27, 2024
1 parent 0de5dd4 commit 80c4b77
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
/.gradle/
/cover-agent-plugin/reports/
/reports/
.codiumai
.codiumai
/test-project/build/
/test-project/run.log
/test-project/test_results.html
17 changes: 15 additions & 2 deletions cover-agent-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.Confidence
import org.gradle.api.tasks.Delete
plugins {
id 'groovy'
id 'java-gradle-plugin'
id 'maven-publish'
id 'jacoco'
id 'checkstyle'
id 'pmd'
id "com.github.spotbugs" version "6.0.21"
id "com.gradle.plugin-publish" version "1.3.0"
id 'signing'
id 'com.gradleup.shadow' version '8.3.2'
}

group = 'ai.codium'
version = '1.0-SNAPSHOT'

repositories {
gradlePluginPortal()
mavenCentral()
}

Expand Down Expand Up @@ -42,12 +44,23 @@ dependencies {

gradlePlugin {
plugins {
website = 'https://github.com/Codium-ai/gradle-cover-agent'
vcsUrl = '[email protected]:Codium-ai/gradle-cover-agent.git'
coverAgent {
id = 'ai.codium.plugin.cover-agent'
implementationClass = 'ai.codium.cover.plugin.CoverAgentPlugin'
displayName = 'Cover Agent Plugin'
description = 'A plugin to cover agent functionality.'
tags = ['cover', 'agent', 'plugin']

}
}
}
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
archiveBaseName.set('shadow')
archiveClassifier.set('')
archiveVersion.set('')
}

tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
reports {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package ai.codium.cover.plugin

import dev.langchain4j.model.openai.OpenAiChatModel
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import spock.lang.Specification

class CoverAgentTaskSpec extends Specification {

Project project = ProjectBuilder.builder().build()
CoverAgentTask task = project.tasks.create('coverAgentTask', CoverAgentTask)

def "test default properties"() {
expect:
!task.apiKey.isPresent()
!task.wanDBApiKey.isPresent()
!task.iterations.isPresent()
!task.coverAgentBinaryPath.isPresent()
!task.coverage.isPresent()
}

def "test setting properties"() {
given:
task.apiKey.set("test-api-key")
task.wanDBApiKey.set("test-wandb-api-key")
task.iterations.set(10)
task.coverAgentBinaryPath.set("/path/to/binary")
task.coverage.set(80)

expect:
task.apiKey.get() == "test-api-key"
task.wanDBApiKey.get() == "test-wandb-api-key"
task.iterations.get() == 10
task.coverAgentBinaryPath.get() == "/path/to/binary"
task.coverage.get() == 80
}

def "test performTask"() {
given:
task.apiKey.set("test-api-key")
task.wanDBApiKey.set("test-wandb-api-key")
task.iterations.set(10)
task.coverAgentBinaryPath.set("/path/to/binary")
task.coverage.set(80)

and:
CoverAgentBuilder builderMock = Mock(CoverAgentBuilder)
CoverAgent coverAgentMock = Mock(CoverAgent)
OpenAiChatModel.OpenAiChatModelBuilder chatModelBuilderMock = Mock(OpenAiChatModel.OpenAiChatModelBuilder)

when:

CoverAgentBuilder.builder() >> builderMock
builderMock.project(_) >> builderMock
builderMock.apiKey(_) >> builderMock
builderMock.wanDBApiKey(_) >> builderMock
builderMock.iterations(_) >> builderMock
builderMock.coverAgentBinaryPath(_) >> builderMock
builderMock.coverage(_) >> builderMock
builderMock.openAiChatModelBuilder(_) >> builderMock
builderMock.build() >> coverAgentMock
OpenAiChatModel.builder() >> chatModelBuilderMock

task.performTask()

then:
0 * builderMock.project(project)
0 * builderMock.apiKey("test-api-key")
0 * builderMock.wanDBApiKey("test-wandb-api-key")
0 * builderMock.iterations(10)
0 * builderMock.coverAgentBinaryPath("/path/to/binary")
0 * builderMock.coverage(80)
0 * builderMock.openAiChatModelBuilder(chatModelBuilderMock)

}
}
Binary file added test-project/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.

0 comments on commit 80c4b77

Please sign in to comment.