Update timestamps of test report if running on ci

We have to update the timestamps of our test reports on the ci server,
because Jenkins fails it the reports are older than x minutes.
This commit is contained in:
Sebastian Sdorra
2021-01-13 15:37:57 +01:00
committed by René Pfeuffer
parent 22375c8096
commit 4e1bf1d13b
12 changed files with 105 additions and 12 deletions

4
Jenkinsfile vendored
View File

@@ -75,8 +75,8 @@ pipeline {
sh "./gradlew integrationTest" sh "./gradlew integrationTest"
script { script {
withSonarQubeEnv('sonarcloud.io-scm') { withSonarQubeEnv('sonarcloud.io-scm') {
String sonar = "sonarqube -Dsonar.organization=scm-manager -Dsonar.branch.name=${script.env.BRANCH_NAME}" String sonar = "sonarqube -Dsonar.organization=scm-manager -Dsonar.branch.name=${env.BRANCH_NAME}"
if (script.env.BRANCH_NAME != "master") { if (env.BRANCH_NAME != "master") {
sonar += " -Dsonar.branch.target=master" sonar += " -Dsonar.branch.target=master"
} }
// disable until we know how todo sonar analysis with subprojects // disable until we know how todo sonar analysis with subprojects

View File

@@ -70,6 +70,10 @@ gradlePlugin {
id = 'org.scm-manager.packaging' id = 'org.scm-manager.packaging'
implementationClass = 'com.cloudogu.scm.PackagingPlugin' implementationClass = 'com.cloudogu.scm.PackagingPlugin'
} }
ci {
id = 'org.scm-manager.ci'
implementationClass = 'com.cloudogu.scm.CIPlugin'
}
} }
} }

View File

@@ -0,0 +1,11 @@
package com.cloudogu.scm
import org.gradle.api.Plugin
import org.gradle.api.Project
class CIPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.ext.TouchFiles = TouchFilesTask
}
}

View File

@@ -65,6 +65,15 @@ class JavaModulePlugin implements Plugin<Project> {
xml.enabled true xml.enabled true
} }
} }
project.tasks.register("update-test-timestamp", TouchFilesTask) {
directory = new File(project.buildDir, "test-results")
extension = "xml"
}
project.tasks.getByName("test").configure {
dependsOn "update-test-timestamp"
}
} }
project.test { project.test {

View File

@@ -0,0 +1,46 @@
package com.cloudogu.scm
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.TaskAction
import java.time.Instant
class TouchFilesTask extends DefaultTask {
@InputDirectory
File directory
@Input
String extension
@Input
long timestamp
TouchFilesTask() {
timestamp = Instant.now().toEpochMilli()
// this task should run always
outputs.upToDateWhen {
false
}
}
@TaskAction
public void execute() {
if (directory.exists()) {
touch(directory)
}
}
private void touch(File file) {
if (file.isDirectory()) {
for (File child : file.listFiles()) {
touch(child)
}
} else if (file.getName().endsWith(".${extension}")) {
file.setLastModified(timestamp)
}
}
}

View File

@@ -24,6 +24,7 @@
plugins { plugins {
id 'java-library' id 'java-library'
id 'org.scm-manager.ci'
id 'org.scm-manager.java' id 'org.scm-manager.java'
id 'org.scm-manager.core-plugins' id 'org.scm-manager.core-plugins'
id 'org.scm-manager.integration-tests' id 'org.scm-manager.integration-tests'
@@ -90,12 +91,23 @@ node {
} }
task e2eTests(type: YarnTask) { task e2eTests(type: YarnTask) {
inputs.files(fileTree(project.project(":scm-ui").projectDir) {
include 'e2e-*/**'
include 'ui-*/**'
})
outputs.dir(project.project(":scm-ui").file('build/reports/e2e'))
args = ['run', 'e2e-tests'] args = ['run', 'e2e-tests']
ignoreExitValue = project.isCI ignoreExitValue = project.isCI
mustRunAfter 'startScmServer' mustRunAfter 'startScmServer'
dependsOn 'yarn_install', 'startScmServer' dependsOn 'yarn_install', 'startScmServer'
} }
task updateE2eTestTimestamps(type: TouchFiles) {
directory = project.project(":scm-ui").file('build/reports/e2e')
extension = "xml"
}
task integrationTest { task integrationTest {
dependsOn(javaIntegrationTests, e2eTests) dependsOn(javaIntegrationTests, e2eTests)
finalizedBy 'stopScmServer' finalizedBy 'stopScmServer'

View File

@@ -24,7 +24,7 @@
plugins { plugins {
id 'org.scm-manager.smp' version '0.7.0' id 'org.scm-manager.smp' version '0.7.1'
} }
def jgitVersion = '5.6.1.202002131546-r-scm1' def jgitVersion = '5.6.1.202002131546-r-scm1'

View File

@@ -24,7 +24,7 @@
plugins { plugins {
id 'org.scm-manager.smp' version '0.7.0' id 'org.scm-manager.smp' version '0.7.1'
} }
dependencies { dependencies {

View File

@@ -24,7 +24,7 @@
plugins { plugins {
id 'org.scm-manager.smp' version '0.7.0' id 'org.scm-manager.smp' version '0.7.1'
} }
dependencies { dependencies {

View File

@@ -24,7 +24,7 @@
plugins { plugins {
id 'org.scm-manager.smp' version '0.7.0' id 'org.scm-manager.smp' version '0.7.1'
} }
dependencies { dependencies {

View File

@@ -24,7 +24,7 @@
plugins { plugins {
id 'org.scm-manager.smp' version '0.7.0' id 'org.scm-manager.smp' version '0.7.1'
} }
def svnkitVersion = '1.10.1-scm2' def svnkitVersion = '1.10.1-scm2'

View File

@@ -26,6 +26,7 @@
plugins { plugins {
id 'com.github.node-gradle.node' version '2.2.4' id 'com.github.node-gradle.node' version '2.2.4'
id 'com.github.hierynomus.license-base' version '0.15.0' id 'com.github.hierynomus.license-base' version '0.15.0'
id 'org.scm-manager.ci'
} }
node { node {
@@ -66,9 +67,19 @@ task test(type: YarnTask) {
}) })
.withPathSensitivity(PathSensitivity.RELATIVE) .withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir('build/jest-reports') outputs.dir('build/jest-reports')
if (project.isCI) {
ignoreExitValue = project.isCI ignoreExitValue = project.isCI
dependsOn('yarn_install', 'updateUiTestTimestamps')
} else {
dependsOn('yarn_install') dependsOn('yarn_install')
} }
}
task updateUiTestTimestamps(type: TouchFiles) {
directory = project.file('build/jest-reports')
extension = "xml"
}
task check { task check {
dependsOn('typecheck', 'test') dependsOn('typecheck', 'test')