-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Публикация результатов синтаксического контроля в Allure #148
Merged
nixel2007
merged 5 commits into
firstBitMarksistskaya:develop
from
ovcharenko-di:feature/allure-syntax-check
Jan 17, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
161a4f5
mv syntaxCheck to separate class, add publish to allure
ovcharenko-di dc6a160
add unstash
ovcharenko-di 17020ef
bump deps, add defaults, fix schema
ovcharenko-di b2347a3
Apply suggestions from code review
nixel2007 2cb2dc6
Update resources/schema.json
nixel2007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package ru.pulsar.jenkins.library.steps | ||
|
||
import hudson.FilePath | ||
import ru.pulsar.jenkins.library.IStepExecutor | ||
import ru.pulsar.jenkins.library.configuration.JobConfiguration | ||
import ru.pulsar.jenkins.library.ioc.ContextRegistry | ||
import ru.pulsar.jenkins.library.utils.FileUtils | ||
import ru.pulsar.jenkins.library.utils.Logger | ||
import ru.pulsar.jenkins.library.utils.VRunner | ||
|
||
class SyntaxCheck { | ||
|
||
public static final String ALLURE_STASH = 'syntax-check-allure' | ||
|
||
private final JobConfiguration config | ||
|
||
SyntaxCheck(JobConfiguration config) { | ||
this.config = config | ||
} | ||
|
||
def run() { | ||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor() | ||
|
||
Logger.printLocation() | ||
|
||
if (!config.stageFlags.syntaxCheck) { | ||
Logger.println("Syntax-check step is disabled") | ||
return | ||
} | ||
|
||
def env = steps.env() | ||
|
||
def options = config.syntaxCheckOptions | ||
|
||
List<String> logosConfig = ["LOGOS_CONFIG=$config.logosConfig"] | ||
steps.withEnv(logosConfig) { | ||
steps.installLocalDependencies() | ||
|
||
String junitReport = "build/out/jUnit/syntax-check/syntax-check.xml" | ||
FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$junitReport") | ||
String junitReportDir = FileUtils.getLocalPath(pathToJUnitReport.getParent()) | ||
|
||
String allureReport = "build/out/allure/syntax-check/allure.xml" | ||
FilePath pathToAllureReport = FileUtils.getFilePath("$env.WORKSPACE/$allureReport") | ||
String allureReportDir = FileUtils.getLocalPath(pathToAllureReport.getParent()) | ||
|
||
String vrunnerPath = VRunner.getVRunnerPath() | ||
String command = "$vrunnerPath syntax-check --ibconnection \"/F./build/ib\"" | ||
|
||
// Временно убрал передачу параметра. | ||
// См. https://github.com/vanessa-opensource/vanessa-runner/issues/361 | ||
// command += " --workspace $env.WORKSPACE" | ||
|
||
if (options.groupErrorsByMetadata) { | ||
command += ' --groupbymetadata' | ||
} | ||
|
||
if (options.publishToJUnitReport) { | ||
steps.createDir(junitReportDir) | ||
command += " --junitpath $pathToJUnitReport" | ||
} | ||
|
||
if (options.publishToAllureReport) { | ||
steps.createDir(allureReportDir) | ||
command += " --allure-results2 $allureReportDir" | ||
} | ||
|
||
FilePath vrunnerSettings = FileUtils.getFilePath("$env.WORKSPACE/$options.vrunnerSettings") | ||
if (vrunnerSettings.exists()) { | ||
command += " --settings $vrunnerSettings" | ||
} | ||
|
||
if (!options.exceptionFile.empty && steps.fileExists(options.exceptionFile)) { | ||
command += " --exception-file $options.exceptionFile" | ||
} | ||
|
||
if (options.checkModes.length > 0) { | ||
def checkModes = options.checkModes.join(" ") | ||
command += " --mode $checkModes" | ||
} | ||
|
||
// Запуск синтакс-проверки | ||
VRunner.exec(command, true) | ||
|
||
if (options.publishToAllureReport) { | ||
steps.stash(ALLURE_STASH, "$allureReportDir/**", true) | ||
steps.archiveArtifacts("$allureReportDir/**") | ||
} | ||
|
||
if (options.publishToJUnitReport) { | ||
steps.junit("$junitReportDir/*.xml", true) | ||
steps.archiveArtifacts("$junitReportDir/**") | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,12 @@ | ||
import hudson.FilePath | ||
import ru.pulsar.jenkins.library.configuration.JobConfiguration | ||
import ru.pulsar.jenkins.library.ioc.ContextRegistry | ||
import ru.pulsar.jenkins.library.utils.FileUtils | ||
import ru.pulsar.jenkins.library.utils.VRunner | ||
import ru.pulsar.jenkins.library.steps.SyntaxCheck | ||
|
||
def call(JobConfiguration config) { | ||
|
||
ContextRegistry.registerDefaultContext(this) | ||
|
||
// TODO: Вынести в отдельный класс по аналогии с SonarScanner | ||
def syntaxCheck = new SyntaxCheck(config) | ||
syntaxCheck.run() | ||
|
||
printLocation() | ||
|
||
if (!config.stageFlags.syntaxCheck) { | ||
echo("Syntax-check step is disabled") | ||
return | ||
} | ||
|
||
def options = config.syntaxCheckOptions | ||
|
||
installLocalDependencies() | ||
|
||
unzipInfobase() | ||
|
||
FilePath pathToJUnitReport = FileUtils.getFilePath("$env.WORKSPACE/$options.pathToJUnitReport") | ||
|
||
String outPath = pathToJUnitReport.getParent() | ||
createDir(outPath) | ||
|
||
String vrunnerPath = VRunner.getVRunnerPath(); | ||
String command = "$vrunnerPath syntax-check --ibconnection \"/F./build/ib\"" | ||
|
||
// Временно убрал передачу параметра. | ||
// См. https://github.com/vanessa-opensource/vanessa-runner/issues/361 | ||
// command += " --workspace $env.WORKSPACE" | ||
|
||
if (options.groupErrorsByMetadata) { | ||
command += ' --groupbymetadata' | ||
} | ||
|
||
command += " --junitpath $pathToJUnitReport"; | ||
|
||
FilePath vrunnerSettings = FileUtils.getFilePath("$env.WORKSPACE/$options.vrunnerSettings") | ||
if (vrunnerSettings.exists()) { | ||
command += " --settings $vrunnerSettings"; | ||
} | ||
|
||
if (!options.exceptionFile.empty && fileExists(options.exceptionFile)) { | ||
command += " --exception-file $options.exceptionFile" | ||
} | ||
|
||
if (options.checkModes.length > 0) { | ||
def checkModes = options.checkModes.join(" ") | ||
command += " --mode $checkModes" | ||
} | ||
|
||
// Запуск синтакс-проверки | ||
VRunner.exec(command, true) | ||
|
||
junit allowEmptyResults: true, testResults: FileUtils.getLocalPath(pathToJUnitReport) | ||
|
||
archiveArtifacts FileUtils.getLocalPath(pathToJUnitReport) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Рекомендуется улучшить обработку ошибок
При выполнении команды и архивации отчетов отсутствует явная обработка исключений, что может затруднить диагностику проблем.
Предлагаемый рефакторинг:
📝 Committable suggestion