Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
!src/
!dist/
!test-cypress/
!Dockerfile
298 changes: 206 additions & 92 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,113 +1,227 @@
// @Library('ontotext-platform@GDB-11897-Migrate-pipelines-new-Jenkins') _
// pipeline {
// environment {
// CI = "true"
// // Needed for our version of webpack + newer nodejs
// NODE_OPTIONS = "--openssl-legacy-provider"
// // Tells NPM and co. not to use color output (looks like garbage in Jenkins)
// NO_COLOR = "1"
// SONAR_ENVIRONMENT = "SonarCloud"
// LEGACY_JENKINS = "https://jenkins.ontotext.com"
// NEW_JENKINS = "https://new-jenkins.ontotext.com"
// LEGACY_AGENT = 'graphdb-jenkins-node'
// AGENT = 'aws-large'
// }
//
// // TODO fix when migration is complete
// agent {
// label 'aws-large'
// }
//
// tools {
// nodejs 'nodejs-18.9.0'
// }
//
// stages {
// stage('Install') {
// steps {
// sh "npm install"
// }
// }
//
// stage('Validate translations') {
// steps {
// sh 'node scripts/validate-translations.js || exit 1'
// }
// }
//
// stage('Build') {
// steps {
// sh "npm run build"
// }
// }
//
// stage('Sonar') {
// steps {
// withSonarQubeEnv(SONAR_ENVIRONMENT) {
// script {
// if (scmUtil.isMaster()) {
// sh "node sonar-project.js --branch='${scmUtil.getCurrentBranch()}'"
// } else {
// sh "node sonar-project.js --branch='${scmUtil.getSourceBranch()}' --target-branch='${scmUtil.getTargetBranch()}' --pull-request-id='${scmUtil.getMergeRequestId()}'"
// }
// }
// }
// }
// }
//
// stage('Acceptance') {
// steps {
// script {
// if (!scmUtil.isMaster()) {
// withKsm(application: [[
// credentialsId: 'ksm-jenkins',
// secrets: [
// [
// destination: 'file',
// filePath: 'graphdb.license',
// notation: 'keeper://zn9mpFS1tZ0dNcqmsNhsLg/file/graphdb-b64.license'
// ]
// ]
// ]]) {
// sh 'cp graphdb.license ./test-cypress/fixtures/'
// }
// sh "ls ./test-cypress/fixtures/"
// script {
// withEnv(["DOCKER_BUILDKIT=0", "COMPOSE_DOCKER_CLI_BUILD=0"]) {
// dockerCompose.buildCmd(options: ["--force-rm", "--no-cache", "--parallel"])
// dockerCompose.upCmd(options: ["--abort-on-container-exit", "--exit-code-from cypress-tests"])
// }
// }
// }
// }
// }
// }
// }
//
// post {
// always {
// script {
// node(env.AGENT) {
// cleanup()
// }
// }
// }
//
// failure {
// script {
// node(env.AGENT) {
// archiveArtifacts()
// }
// }
// }
// }
// }
//
// def cleanup() {
// // upload failed tests report and artifacts
// junit allowEmptyResults: true, testResults: 'cypress/results/**/*.xml'
// archiveArtifacts allowEmptyArchive: true, artifacts: 'report/screenshots/**/*.png, report/videos/**/*.mp4, cypress/logs/*.log'
//
// script {
// dockerCompose.downCmd(removeVolumes: true, removeOrphans: true, removeImages: 'local', ignoreErrors: true)
// }
// // clean root owned resources from docker volumes, just in case
// sh "sudo rm -rf ./coverage"
// sh "sudo rm -rf ./cypress"
// sh "sudo rm -rf ./report"
// }
//
//
// def archiveArtifacts() {
// archiveArtifacts artifacts: 'translation-validation-result.json', onlyIfSuccessful: false
// }
@Library('ontotext-platform@GDB-11897-Migrate-pipelines-new-Jenkins') _
pipeline {
agent {
label 'aws-large'
}

agent {
label 'graphdb-jenkins-node'
}

tools {
nodejs 'nodejs-20.11.1'
}

environment {
CI = "true"
NEXUS_CREDENTIALS = credentials('nexus-kim-user')
// Needed for our version of webpack + newer nodejs
NODE_OPTIONS = "--openssl-legacy-provider"
// Tells NPM and co. not to use color output (looks like garbage in Jenkins)
NO_COLOR = "1"
}

stages {

stage('Install') {
steps {
sh "npm install"
}
tools {
nodejs 'nodejs-18.9.0'
}

stage('Validate translations') {
steps {
sh 'node scripts/validate-translations.js || exit 1'
}
environment {
CI = "true"
// Needed for our version of webpack + newer nodejs
NODE_OPTIONS = "--openssl-legacy-provider"
// Tells NPM and co. not to use color output (looks like garbage in Jenkins)
NO_COLOR = "1"
SONAR_ENVIRONMENT = "SonarCloud"
}

stage('Print Branch Name') {
steps {
script {
echo "Building branch: ${env.BRANCH_NAME}"
stages {
stage('Install, Validate translations, Build') {
steps {
script {
npm.install(scripts: ['validate-translations', 'build'])
}
}
}
}
}

stage('Build') {
steps {
sh "npm run build"
}
}

stage('Sonar') {
steps {
withSonarQubeEnv('SonarCloud') {
script {
if (env.BRANCH_NAME == 'master') {
sh "node sonar-project.js --branch='${env.BRANCH_NAME}'"
} else {
sh "node sonar-project.js --branch='${env.ghprbSourceBranch}' --target-branch='${env.ghprbTargetBranch}' --pull-request-id='${env.ghprbPullId}'"
// stage('Sonar') {
// steps {
// withSonarQubeEnv(SONAR_ENVIRONMENT) {
// script {
// if (scmUtil.isMaster()) {
// sh "node sonar-project.js --branch='${scmUtil.getCurrentBranch()}'"
// } else {
// sh "node sonar-project.js --branch='${scmUtil.getSourceBranch()}' --target-branch='${scmUtil.getTargetBranch()}' --pull-request-id='${scmUtil.getMergeRequestId()}'"
// }
// }
// }
// }
// }
stage('Acceptance') {
steps {
script {
if (!scmUtil.isMaster()) {
withKsm(application: [[
credentialsId: 'ksm-jenkins',
secrets: [
[
destination: 'file',
filePath: 'graphdb.license',
notation: 'keeper://zn9mpFS1tZ0dNcqmsNhsLg/file/graphdb-b64.license'
]
]
]]) {
sh 'cp graphdb.license ./test-cypress/fixtures/'
}
sh "ls ./test-cypress/fixtures/"
dockerCompose.buildCmd(options: ["--force-rm", "--parallel"])
dockerCompose.upCmd(options: ["--abort-on-container-exit", "--exit-code-from cypress-tests"])
}
}
}
}
}
}
}


stage('Acceptance') {
when {
expression {
return env.BRANCH_NAME != 'master'
}
}
steps {
configFileProvider(
[configFile(fileId: 'ceb7e555-a3d9-47c7-9afe-d008fd9efb14', targetLocation: 'graphdb.license')]) {
sh 'cp graphdb.license ./test-cypress/fixtures/'
post {
always {
script {
node(env.NEW_AGENT) {
cleanup()
}
}
}
sh "ls ./test-cypress/fixtures/"
// --no-ansi suppresses color output that shows as garbage in Jenkins
sh "docker-compose --no-ansi build --force-rm --no-cache --parallel"
sh "docker-compose --no-ansi up --abort-on-container-exit --exit-code-from cypress-tests"

// Fix coverage permissions
sh "sudo chown -R \$(id -u):\$(id -g) coverage/"
sh "sudo chown -R \$(id -u):\$(id -g) cypress/"
sh "sudo chown -R \$(id -u):\$(id -g) report/"

// Move up to be picked by Sonar
// sh "mv test-cypress/coverage/ cypress-coverage/"
// sh "sync"
//
// // Update relative paths to absolute path
// sh "sed -i.backup \"s@^SF:..@SF:\$(pwd)@\" cypress-coverage/lcov.info"
}
failure {
script {
node(env.NEW_AGENT) {
archiveArtifacts()
}
}
}
}
}

post {
always {
// upload failed tests report and artifacts
junit allowEmptyResults: true, testResults: 'cypress/results/**/*.xml'
archiveArtifacts allowEmptyArchive: true, artifacts: 'report/screenshots/**/*.png, report/videos/**/*.mp4, cypress/logs/*.log'
}

// --no-ansi suppresses color output that shows as garbage in Jenkins
sh "docker-compose --no-ansi down -v --remove-orphans --rmi=local || true"
// clean root owned resources from docker volumes, just in case
sh "sudo rm -rf ./coverage"
sh "sudo rm -rf ./cypress"
sh "sudo rm -rf ./report"
}
def cleanup() {
// upload failed tests report and artifacts
junit allowEmptyResults: true, testResults: 'cypress/results/**/*.xml'
archiveArtifacts allowEmptyArchive: true, artifacts: 'report/screenshots/**/*.png, report/videos/**/*.mp4, cypress/logs/*.log'

failure {
archiveArtifacts artifacts: 'translation-validation-result.json', onlyIfSuccessful: false
script {
dockerCompose.downCmd(removeVolumes: true, removeOrphans: true, removeImages: 'local', ignoreErrors: true)
}
}
// clean root owned resources from docker volumes, just in case
sh "sudo rm -rf ./coverage"
sh "sudo rm -rf ./cypress"
sh "sudo rm -rf ./report"
}


def archiveArtifacts() {
archiveArtifacts artifacts: 'translation-validation-result.json', onlyIfSuccessful: false
}
35 changes: 5 additions & 30 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
version: '3.3'

services:

graphdb:
image: docker-registry.ontotext.com/graphdb:${GDB_VERSION}
environment:
GDB_JAVA_OPTS: >-
-Dgraphdb.workbench.importDirectory=/opt/home/import-data/
-Dgraphdb.jsonld.whitelist=https://w3c.github.io/json-ld-api/tests/*
-Dgraphdb.stats.default=disabled
-Dgraphdb.foreground=
-Dgraphdb.logger.root.level=ERROR
expose:
- 7200
volumes:
- ./test-cypress/fixtures/graphdb-import:/opt/home/import-data/

workbench:
build:
context: .
dockerfile: Dockerfile
environment:
GRAPHDB_URL: 'http://graphdb:7200'
ports:
- 80
depends_on:
- graphdb

cypress-tests:
build:
context: test-cypress
depends_on:
- workbench
context: .
dockerfile: test-cypress/Dockerfile
environment:
- CYPRESS_baseUrl=http://workbench
- IS_DOCKER=true
- DOCKER_HOST=unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./coverage:/workbench/tests-cypress/coverage
- ./cypress:/workbench/tests-cypress/cypress
- ./report:/workbench/tests-cypress/report
Loading