Commit 60ecf56f authored by Baptiste Mesta's avatar Baptiste Mesta Committed by abirembaut
Browse files

Try to parallelize using gradle and new node plugin (#26)

* chore(web pages): Parallelize using gradle and new node plugin

covers [RUNTIME-168](https://bonitasoft.atlassian.net/browse/RUNTIME-168)
parent 7bf11a81
......@@ -22,7 +22,9 @@ ansiColor('xterm') {
slackStage('🔧 Build', isBaseBranch) {
wrap([$class: 'Xvfb', autoDisplayName: true, screen: '1920x1280x24', parallelBuild: true]) {
try {
gradle 'clean build runIntegrationTests'
gradle 'buildUIDPage --parallel --max-workers 2'
gradle 'build'
gradle 'runTest --parallel --max-workers 2'
} finally {
junit testResults: '**/build*/tests/results/*.xml', allowEmptyResults: true
archiveArtifacts '**/build*/distributions/*.zip, **/build*/*.zip, uid-pages/**/videos/*'
......
plugins {
id 'org.ajoberstar.grgit' version '4.0.1'
id 'com.bonitasoft.gradle.bonita-release' version '0.1.53'
id 'com.bonitasoft.gradle.bonita-release' version '0.1.54'
id 'com.bonitasoft.gradle.maven-settings' version '0.7.3'
// plugin only available internally, used for quickly deploying into a runtime environment
......@@ -39,18 +39,3 @@ allprojects {
}
}
configure(subprojects.findAll { it.name.contains('page-process-list') }) {
apply plugin: BonitaPagePlugin
bonitaPage {
nodeVersion = '8.9.4'
npmVersion = '6.2.0'
frontendBuildDir = 'dist'
}
publishing {
publications {
distributionZip(MavenPublication) { artifact distZip }
}
}
}
......@@ -4,5 +4,5 @@ repositories {
}
dependencies {
compile 'com.moowork.gradle:gradle-node-plugin:1.2.0'
compile 'com.github.node-gradle:gradle-node-plugin:3.0.1'
}
\ No newline at end of file
......@@ -6,22 +6,14 @@ class BonitaHtmlPagePlugin implements Plugin<Project> {
@Override
void apply(Project project) {
def extension = project.extensions.create('bonitaPage', BonitaPagePluginExtension)
project.plugins.apply('com.moowork.node')
project.plugins.apply('com.github.node-gradle.node')
project.plugins.apply('distribution')
def currentDir = project.rootProject.projectDir
project.beforeEvaluate {
project.node {
version = extension.nodeVersion
npmVersion = extension.npmVersion
}
}
def projectRootDir = project.rootProject.projectDir
project.node {
download = true
workDir = project.file("${currentDir}/.gradle/nodejs")
npmWorkDir = project.file("${currentDir}/.gradle/npm")
version = Versions.nodeVersion
npmVersion = Versions.npmVersion
}
project.tasks.npm_install.configure {
......@@ -30,14 +22,14 @@ class BonitaHtmlPagePlugin implements Plugin<Project> {
inputs.files('package.json')
}
def buildPage = project.task([type: com.moowork.gradle.node.npm.NpmTask, dependsOn: project.tasks.npm_install], 'buildPage') {
def buildPage = project.task([type: com.github.gradle.node.npm.task.NpmTask, dependsOn: project.tasks.npm_install], 'buildPage') {
group 'Bonita'
description 'Build a ZIP which contains an custom-page to be imported in living application'
args = ['run']
inputs.files('package.json')
inputs.dir('src')
inputs.dir('resources')
outputs.dirs({extension.frontendBuildDir})
outputs.dirs({ extension.frontendBuildDir })
}
project.tasks.distZip.dependsOn buildPage
......
......@@ -6,22 +6,15 @@ class BonitaPagePlugin implements Plugin<Project> {
@Override
void apply(Project project) {
def extension = project.extensions.create('bonitaPage', BonitaPagePluginExtension)
project.plugins.apply('com.moowork.node')
project.plugins.apply('com.github.node-gradle.node')
project.plugins.apply('distribution')
def currentDir = project.rootProject.projectDir
project.beforeEvaluate {
project.node {
version = extension.nodeVersion
npmVersion = extension.npmVersion
}
}
project.node {
download = true
workDir = project.file("${currentDir}/.gradle/nodejs")
npmWorkDir = project.file("${currentDir}/.gradle/npm")
version = Versions.nodeVersion
npmVersion = Versions.npmVersion
}
project.tasks.npm_install.configure {
......@@ -31,7 +24,7 @@ class BonitaPagePlugin implements Plugin<Project> {
outputs.dirs('node_modules')
}
def buildPage = project.task([type: com.moowork.gradle.node.npm.NpmTask, dependsOn: project.tasks.npm_install], 'buildPage') {
def buildPage = project.task([type: com.github.gradle.node.npm.task.NpmTask, dependsOn: project.tasks.npm_install], 'buildPage') {
group 'Bonita'
description 'Build a ZIP which contains an custom-page to be imported in living application'
args = ['run', 'build:only']
......@@ -43,19 +36,19 @@ class BonitaPagePlugin implements Plugin<Project> {
project.tasks.distZip.dependsOn buildPage
project.task([type: com.moowork.gradle.node.npm.NpmTask], 'lintFix') {
project.task([type: com.github.gradle.node.npm.task.NpmTask], 'lintFix') {
group 'Bonita'
args = ['run', 'lint:fix']
description 'Format all files in directory /src with prettier'
}
def lintCheck = project.task([type: com.moowork.gradle.node.npm.NpmTask, dependsOn: project.tasks.npm_install], 'lintCheck') {
def lintCheck = project.task([type: com.github.gradle.node.npm.task.NpmTask, dependsOn: project.tasks.npm_install], 'lintCheck') {
group 'Bonita'
args = ['run', 'lint:check']
description 'Check if format issues exist on directory src'
}
def test = project.task([type: com.moowork.gradle.node.npm.NpmTask, dependsOn: project.tasks.npm_install], 'test') {
def test = project.task([type: com.github.gradle.node.npm.task.NpmTask, dependsOn: project.tasks.npm_install], 'test') {
group 'Bonita'
args = ['run', 'test']
description 'Run test of project'
......
class BonitaPagePluginExtension {
String nodeVersion
String npmVersion
String frontendBuildDir
}
\ No newline at end of file
class Versions {
static def nodeVersion = '10.15.3'
static def npmVersion = '6.4.1'
}
apply plugin: 'com.github.node-gradle.node'
node {
download = true
version = Versions.nodeVersion
npmVersion = Versions.npmVersion
}
\ No newline at end of file
......@@ -8,5 +8,4 @@
"bin": {
"bonita-theme": "bin/bonita-theme.js"
}
}
apply plugin: BonitaPagePlugin
bonitaPage { frontendBuildDir = 'build' }
bonitaPage {
frontendBuildDir = 'build'
}
publishing {
publications {
distributionZip(MavenPublication) { artifact distZip }
}
}
// Workaround to manage React-CLI non conventional build directory
project.buildDir = 'build-gradle'
project.tasks.buildPage.configure { inputs.dir('public') }
project.tasks.buildPage.dependsOn(project(':common:bonita-theme').tasks.npm_install)
include 'common:bonita-theme'
include 'other-pages:page-process-list'
include 'uid-pages:form-case-overview'
include 'uid-pages:layout-living-application'
......
plugins { id 'com.moowork.node' }
project.beforeEvaluate {
project.node {
version = '8.9.4'
npmVersion = '6.2.0'
}
}
project.node {
download = true
def currentDir = project.rootProject.projectDir
workDir = project.file("${currentDir}/.gradle/nodejs")
npmWorkDir = project.file("${currentDir}/.gradle/npm")
}
project.tasks.npm_install.configure {
group 'Bonita'
description 'Install node moodule for this project'
inputs.files('package.json', 'package-lock.json')
outputs.dirs('node_modules')
}
def runIntegrationTests = task runIntegrationTests {}
def parentProject = project
subprojects { subProject ->
if (file("cypress.json").exists()){
apply plugin: 'com.moowork.node'
apply plugin: 'com.github.node-gradle.node'
node {
download = true
version = Versions.nodeVersion
npmVersion = Versions.npmVersion
}
task unzip(type: Copy) {
dependsOn('buildUIDPage')
def zipFile = file("${buildDir}/${project.name}-${project.version}.zip")
......@@ -37,17 +18,18 @@ subprojects { subProject ->
into outputDir
}
parentProject.task([dependsOn: [unzip, parentProject.tasks.npm_install], type: NpmTask],"openTest-" + subProject.name) {
subProject.task([dependsOn: [unzip, subProject.tasks.npm_install], type: NpmTask],"openTest") {
workingDir = parentProject.projectDir
args = ['run', 'open', '--', '--project', subProject.name]
group 'ui designer'
}
def subProjectRunTest = parentProject.task([dependsOn: [unzip, parentProject.tasks.npm_install], type: NpmTask],"runTest-" + subProject.name) {
subProject.task([dependsOn: [unzip, subProject.tasks.npm_install], type: NpmTask],"runTest") {
workingDir = parentProject.projectDir
args = ['test', '--', '--project', subProject.name]
environment = [LANG: 'en_EN.UTF-8']
group 'Bonita'
}
runIntegrationTests.dependsOn subProjectRunTest
}
apply plugin: 'com.bonitasoft.gradle.bonita-uid-page'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment