Skip to content

Commit

Permalink
Merge pull request #98 from ovcharenko-di/feature/coverage
Browse files Browse the repository at this point in the history
Замер покрытия
  • Loading branch information
nixel2007 authored Dec 19, 2024
2 parents 7248c85 + 42bbfc7 commit 4f98e66
Show file tree
Hide file tree
Showing 34 changed files with 1,979 additions and 1,012 deletions.
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*.groovy eol=lf
*.groovy eol=lf
*.json eol=lf
*.md eol=lf
*.os eol=lf
560 changes: 314 additions & 246 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions resources/dbgs.os
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Использовать v8find

Сообщить(Платформа1С.ПутьКDBGS(АргументыКоманднойСтроки[0]));
16 changes: 13 additions & 3 deletions resources/globalConfiguration.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"bdd": {
"vrunnerSteps": [
"vanessa --settings ./tools/vrunner.json"
]
],
"coverage": false,
"dbgsPort": 1550
},
"sonarqube": {
"sonarQubeInstallation": "",
Expand Down Expand Up @@ -83,13 +85,21 @@
"vrunnerSettings": "./tools/vrunner.json",
"xddConfigPath": "./tools/xUnitParams.json",
"publishToAllureReport": false,
"publishToJUnitReport": true
"publishToJUnitReport": true,
"coverage": false,
"dbgsPort": 1550
},
"coverage": {
"dbgsPath": "",
"coverage41CPath": "Coverage41C"
},
"yaxunit": {
"vrunnerSettings": "./tools/vrunner.json",
"configPath": "./tools/yaxunit.json",
"publishToAllureReport": false,
"publishToJUnitReport": true
"publishToJUnitReport": true,
"coverage": false,
"dbgsPort": 1550
},
"resultsTransform": {
"transformer": "stebi",
Expand Down
944 changes: 494 additions & 450 deletions resources/schema.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions resources/yaxunit.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"reportFormat": "jUnit",
"showReport": false,
"logging": {
"file": "./build/out/yaxunit/log.txt",
"enable": false,
"level": "debug"
"enable": true,
"console": true,
"level": "info"
},
"exitCode": "./build/out/yaxunit/result.txt"
}
2 changes: 1 addition & 1 deletion src/JobConfigurationSchemaGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class JobConfigurationSchemaGenerator {

public static void main(String[] args) throws Exception {
public static void main(String[] args) {

SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_7, OptionPreset.PLAIN_JSON)
.with(new JacksonModule(JacksonOption.FLATTENED_ENUMS_FROM_JSONVALUE, JacksonOption.FLATTENED_ENUMS_FROM_JSONPROPERTY));
Expand Down
629 changes: 474 additions & 155 deletions src/idea.gdsl

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/ru/pulsar/jenkins/library/IStepExecutor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import jenkins.plugins.http_request.ResponseContentSupplier
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
import ru.pulsar.jenkins.library.configuration.JobConfiguration
import ru.pulsar.jenkins.library.configuration.StepCoverageOptions
import ru.pulsar.jenkins.library.steps.Coverable

interface IStepExecutor {

Expand All @@ -20,6 +23,7 @@ interface IStepExecutor {

FileWrapper[] findFiles(String glob)

@SuppressWarnings('unused')
FileWrapper[] findFiles(String glob, String excludes)

String readFile(String file)
Expand All @@ -40,6 +44,8 @@ interface IStepExecutor {

def ringCommand(String script)

void start(String executable, String params)

void tool(String toolName)

def withCredentials(List bindings, Closure body)
Expand All @@ -64,6 +70,10 @@ interface IStepExecutor {

def withEnv(List<String> strings, Closure body)

def withCoverage(JobConfiguration config, Coverable stage, StepCoverageOptions options, Closure body)

def lock(String resource, Closure<Object> body)

def archiveArtifacts(String path)

def stash(String name, String includes)
Expand All @@ -76,14 +86,17 @@ interface IStepExecutor {

def zip(String dir, String zipFile)

@SuppressWarnings('unused')
def zip(String dir, String zipFile, String glob)

def unzip(String dir, String zipFile)

@SuppressWarnings('unused')
def unzip(String dir, String zipFile, quiet)

def catchError(Closure body)

@SuppressWarnings('unused')
ResponseContentSupplier httpRequest(String url, String outputFile, String responseHandle, boolean wrapAsMultipart)

ResponseContentSupplier httpRequest(String url, HttpMode httpMode, MimeType contentType, String requestBody, String validResponseCodes, boolean consoleLogResponseBody)
Expand Down
27 changes: 27 additions & 0 deletions src/ru/pulsar/jenkins/library/StepExecutor.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import jenkins.plugins.http_request.ResponseContentSupplier
import org.jenkinsci.plugins.pipeline.utility.steps.fs.FileWrapper
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
import ru.pulsar.jenkins.library.configuration.JobConfiguration
import ru.pulsar.jenkins.library.configuration.StepCoverageOptions
import ru.pulsar.jenkins.library.steps.Coverable
import ru.yandex.qatools.allure.jenkins.config.ResultsConfig

class StepExecutor implements IStepExecutor {
Expand Down Expand Up @@ -72,6 +75,18 @@ class StepExecutor implements IStepExecutor {
return steps.ringCommand(script)
}

@Override
void start(String executable, String params) {
if (executable == null || executable.trim().isEmpty()) {
throw new IllegalArgumentException("executable не может быть пустым")
}
try {
steps.start(executable, params)
} catch (Exception e) {
throw new RuntimeException("Ошибка при запуске процесса: ${e.message}", e)
}
}

@Override
void tool(String toolName) {
steps.tool toolName
Expand Down Expand Up @@ -144,6 +159,18 @@ class StepExecutor implements IStepExecutor {
}
}

@Override
def withCoverage(JobConfiguration config, Coverable stage, StepCoverageOptions options, Closure body) {
steps.withCoverage(config, stage, options, body)
}

@Override
def lock(String resource, Closure body) {
steps.lock(resource: resource) {
body()
}
}

@Override
def archiveArtifacts(String path) {
steps.archiveArtifacts path
Expand Down
6 changes: 4 additions & 2 deletions src/ru/pulsar/jenkins/library/configuration/BddOptions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonPropertyDescription

@JsonIgnoreProperties(ignoreUnknown = true)
class BddOptions implements Serializable {
class BddOptions extends StepCoverageOptions implements Serializable {

@JsonPropertyDescription("""Шаги, запускаемые через vrunner.
В каждой строке передается отдельная команда
Expand All @@ -21,6 +21,8 @@ class BddOptions implements Serializable {
String toString() {
return "BddOptions{" +
"vrunnerSteps=" + vrunnerSteps +
'}';
"coverage=" + coverage +
"dbgsPort=" + dbgsPort +
'}'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ import static java.util.Collections.emptySet
class ConfigurationReader implements Serializable {

private static ObjectMapper mapper
private static BeanUtilsBean beanUtilsBean;
private static BeanUtilsBean beanUtilsBean

static {
mapper = new ObjectMapper()
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)

beanUtilsBean = new BeanUtilsBean(new ConvertUtilsBean() {
@Override
@NonCPS
Object convert(String value, Class clazz) {
if (clazz.isEnum()) {
return Enum.valueOf(clazz, value);
return Enum.valueOf(clazz, value)
} else {
return super.convert(value, clazz);
return super.convert(value, clazz)
}
}
});
})
}

private static final String DEFAULT_CONFIGURATION_RESOURCE = 'globalConfiguration.json'
Expand All @@ -49,7 +49,7 @@ class ConfigurationReader implements Serializable {
def globalConfiguration = create()
def jobConfiguration = mapper.readValue(config, JobConfiguration.class)

return mergeConfigurations(globalConfiguration, jobConfiguration);
return mergeConfigurations(globalConfiguration, jobConfiguration)
}

private static JobConfiguration mergeConfigurations(
Expand All @@ -65,6 +65,7 @@ class ConfigurationReader implements Serializable {
"bddOptions",
"sonarQubeOptions",
"smokeTestOptions",
"coverageOptions",
"yaxunitOptions",
"syntaxCheckOptions",
"resultsTransformOptions",
Expand All @@ -84,7 +85,7 @@ class ConfigurationReader implements Serializable {
mergeSyntaxCheckOptions(baseConfiguration.syntaxCheckOptions, configurationToMerge.syntaxCheckOptions)
mergeNotificationsOptions(baseConfiguration.notificationsOptions, configurationToMerge.notificationsOptions)

return baseConfiguration;
return baseConfiguration
}

@NonCPS
Expand All @@ -95,7 +96,7 @@ class ConfigurationReader implements Serializable {
.filter({ e -> e.getKey() != "metaClass" })
.filter({ e -> !nonMergeableSettings.contains(e.getKey()) })
.forEach { e ->
beanUtilsBean.setProperty(baseObject, e.getKey(), e.getValue());
beanUtilsBean.setProperty(baseObject, e.getKey(), e.getValue())
}

nonMergeableSettings.forEach({ key ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ru.pulsar.jenkins.library.configuration

import com.cloudbees.groovy.cps.NonCPS
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonPropertyDescription

@JsonIgnoreProperties(ignoreUnknown = true)
class GlobalCoverageOptions implements Serializable {

@JsonPropertyDescription('''Путь к исполняемому файлу dbgs.
По умолчанию ищется с помощью v8find для указанной версии платформы (v8version).
''')
String dbgsPath

@JsonPropertyDescription('''Путь к исполняемому файлу Coverage41C
По умолчанию ищется в PATH.
''')
String coverage41CPath

@Override
@NonCPS
String toString() {
return "coverageOptions{" +
"dbgsPath=" + dbgsPath +
", coverage41CPath=" + coverage41CPath +
'}'
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class JobConfiguration implements Serializable {
@JsonPropertyDescription("Настройки дымового тестирования")
SmokeTestOptions smokeTestOptions

@JsonProperty("coverage")
@JsonPropertyDescription("Настройки замеров покрытия")
GlobalCoverageOptions coverageOptions

@JsonProperty("yaxunit")
@JsonPropertyDescription("Настройки YAXUnit")
YaxunitOptions yaxunitOptions
Expand Down Expand Up @@ -89,6 +93,7 @@ class JobConfiguration implements Serializable {
", sonarQubeOptions=" + sonarQubeOptions +
", syntaxCheckOptions=" + syntaxCheckOptions +
", smokeTestOptions=" + smokeTestOptions +
", coverageOptions=" + coverageOptions +
", yaxunitOptions=" + yaxunitOptions +
", resultsTransformOptions=" + resultsTransformOptions +
", notificationOptions=" + notificationsOptions +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonPropertyDescription

@JsonIgnoreProperties(ignoreUnknown = true)
class SmokeTestOptions implements Serializable {
class SmokeTestOptions extends StepCoverageOptions implements Serializable {

@JsonPropertyDescription("""Путь к конфигурационному файлу vanessa-runner.
По умолчанию содержит значение "./tools/vrunner.json".
Expand All @@ -15,7 +15,7 @@ class SmokeTestOptions implements Serializable {
@JsonPropertyDescription("""Путь к конфигурационному файлу для xddTestRunner.
По умолчанию содержит значение "./tools/xUnitParams.json".
""")
String xddConfigPath;
String xddConfigPath

@JsonPropertyDescription("""Выполнять публикацию результатов в отчет Allure.
По умолчанию выключено.
Expand All @@ -35,6 +35,8 @@ class SmokeTestOptions implements Serializable {
", xddConfigPath='" + xddConfigPath + '\'' +
", publishToAllureReport=" + publishToAllureReport +
", publishToJUnitReport=" + publishToJUnitReport +
", coverage=" + coverage +
", dbgsPort=" + dbgsPort +
'}'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ru.pulsar.jenkins.library.configuration

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonPropertyDescription

class StepCoverageOptions implements Serializable {

@JsonPropertyDescription("Выполнять замер покрытия")
@JsonProperty(defaultValue = "false")
Boolean coverage = false

@JsonPropertyDescription("Порт, на котором будет запущен сервер отладки для замера покрытия")
@JsonProperty(defaultValue = "1550")
Integer dbgsPort = 1550

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonPropertyDescription

@JsonIgnoreProperties(ignoreUnknown = true)
class YaxunitOptions implements Serializable {
class YaxunitOptions extends StepCoverageOptions implements Serializable {

@JsonPropertyDescription("""Путь к конфигурационному файлу vanessa-runner.
По умолчанию содержит значение "./tools/vrunner.json".
Expand Down Expand Up @@ -35,6 +35,8 @@ class YaxunitOptions implements Serializable {
", configPath='" + configPath +
", publishToAllureReport='" + publishToAllureReport +
", publishToJUnitReport='" + publishToJUnitReport +
", coverage='" + coverage +
", dbgsPort='" + dbgsPort +
'}'
}
}
Loading

0 comments on commit 4f98e66

Please sign in to comment.