From 8545ff355149ce7523a54c562590fdeb37438ec0 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 13:53:52 +0200 Subject: [PATCH 1/9] refactor: break it on purpose --- packages/concordia-app/src/views/Topic/TopicView/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/concordia-app/src/views/Topic/TopicView/index.jsx b/packages/concordia-app/src/views/Topic/TopicView/index.jsx index f77715a..9597984 100644 --- a/packages/concordia-app/src/views/Topic/TopicView/index.jsx +++ b/packages/concordia-app/src/views/Topic/TopicView/index.jsx @@ -111,7 +111,7 @@ const TopicView = (props) => { if (topicFound) { setTopicSubject(topicFound[TOPIC_SUBJECT]); } - }, [topicId, topics]); + }, [topicId]); const stopClickPropagation = (event) => { event.stopPropagation(); From 0752bca9c9d0a4a21e153d2a3a24e3a67a86b087 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 14:06:20 +0200 Subject: [PATCH 2/9] refactor: change test image tag based on branch name --- jenkins/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index f7a8f1d..c39e287 100755 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -128,7 +128,7 @@ pipeline { --net=concordia_ganache_test_network""") { concordiaGanacheTest -> contractsTestsImage = docker.build( - "ecentrics/concordia-contracts-tests:v${contractsPackageVersion}-b${BUILD_NUMBER}-tests", + "ecentrics/concordia-contracts-tests:${BRANCH_NAME}-v${contractsPackageVersion}-b${BUILD_NUMBER}-tests", "-f docker/concordia-contracts/Dockerfile \ ./ \ --target test \ @@ -158,7 +158,7 @@ pipeline { steps { script { appTestsImage = docker.build( - "ecentrics/concordia-app:v${appPackageVersion}-b${BUILD_NUMBER}-tests", + "ecentrics/concordia-app:${BRANCH_NAME}-v${appPackageVersion}-b${BUILD_NUMBER}-tests", "-f docker/concordia-app/Dockerfile \ ./ \ --target test \ From 229a1a5ecb0f864cb2fde1ade33ea85f541e8775 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 14:11:48 +0200 Subject: [PATCH 3/9] fix: sanitize branch name --- jenkins/Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index c39e287..7fc1e3c 100755 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -1,6 +1,7 @@ #!groovy def cleanSlateEnabled +def sanitizedBranchName // Package change state def appPackageChanged @@ -84,6 +85,7 @@ pipeline { steps { script { cleanSlateEnabled = sh (script: "git log -1 | grep -qE 'ci: force'", returnStatus: true) + sanitizedBranchName = "${BRANCH_NAME#*/}" appPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh app "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() contractsPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh contracts "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() @@ -128,7 +130,7 @@ pipeline { --net=concordia_ganache_test_network""") { concordiaGanacheTest -> contractsTestsImage = docker.build( - "ecentrics/concordia-contracts-tests:${BRANCH_NAME}-v${contractsPackageVersion}-b${BUILD_NUMBER}-tests", + "ecentrics/concordia-contracts-tests:${sanitizedBranchName}-v${contractsPackageVersion}-b${BUILD_NUMBER}-tests", "-f docker/concordia-contracts/Dockerfile \ ./ \ --target test \ @@ -158,7 +160,7 @@ pipeline { steps { script { appTestsImage = docker.build( - "ecentrics/concordia-app:${BRANCH_NAME}-v${appPackageVersion}-b${BUILD_NUMBER}-tests", + "ecentrics/concordia-app:${sanitizedBranchName}-v${appPackageVersion}-b${BUILD_NUMBER}-tests", "-f docker/concordia-app/Dockerfile \ ./ \ --target test \ From 7c3a4bf1b1f3d176fb637be72b686ffa78130557 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 14:18:59 +0200 Subject: [PATCH 4/9] fix: fix sanitization --- jenkins/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 7fc1e3c..7233768 100755 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -85,7 +85,7 @@ pipeline { steps { script { cleanSlateEnabled = sh (script: "git log -1 | grep -qE 'ci: force'", returnStatus: true) - sanitizedBranchName = "${BRANCH_NAME#*/}" + sanitizedBranchName = sh(script: 'echo $GIT_BRANCH | sed -e "s:.*/::g"', returnStdout: true).trim() appPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh app "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() contractsPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh contracts "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() From 589a062d91502dfdd652eb8f628ab50644946b65 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 14:29:39 +0200 Subject: [PATCH 5/9] fix: use sh instead of docker plugin --- jenkins/Jenkinsfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 7233768..0645695 100755 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -143,14 +143,14 @@ pipeline { -e WEB3_HOST=concordia-ganache-test-6${ganacheTestPort} \ -e WEB3_PORT=6${ganacheTestPort} \ --net=concordia_ganache_test_network""") - - sh 'mkdir -p ./reports/${BUILD_NUMBER}/contracts' - sh 'find /mnt/janus/common/ -name "concordia-contracts-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/contracts/ \\;' } } catch (e) { error('Some tests failed!') error('Aborting the build.') throw e + } finally { + sh 'mkdir -p ./reports/${BUILD_NUMBER}/contracts' + sh 'find /mnt/janus/common/ -name "concordia-contracts-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/contracts/ \\;' } } } @@ -159,7 +159,7 @@ pipeline { stage('TEST APP') { steps { script { - appTestsImage = docker.build( + docker.build( "ecentrics/concordia-app:${sanitizedBranchName}-v${appPackageVersion}-b${BUILD_NUMBER}-tests", "-f docker/concordia-app/Dockerfile \ ./ \ @@ -168,15 +168,17 @@ pipeline { ) try { - appTestsImage.run('--rm \ - -v ecentrics_janus_common:/mnt/concordia/test-reports/') - - sh 'mkdir -p ./reports/${BUILD_NUMBER}/app' - sh 'find /mnt/janus/common/ -name "concordia-app-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/app/ \\;' + sh """docker run \ + --rm \ + -v ecentrics_janus_common:/mnt/concordia/test-reports/ + ecentrics/concordia-app:${sanitizedBranchName}-v${appPackageVersion}-b${BUILD_NUMBER}-tests""" } catch (e) { error('Some tests failed!') error('Aborting the build.') throw e + } finally { + sh 'mkdir -p ./reports/${BUILD_NUMBER}/app' + sh 'find /mnt/janus/common/ -name "concordia-app-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/app/ \\;' } } } From ec0919b95b60e3476661dc15d04c4bfa14e5056c Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 14:32:49 +0200 Subject: [PATCH 6/9] fix: add missing back slash --- jenkins/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 0645695..7d3ba88 100755 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -170,7 +170,7 @@ pipeline { try { sh """docker run \ --rm \ - -v ecentrics_janus_common:/mnt/concordia/test-reports/ + -v ecentrics_janus_common:/mnt/concordia/test-reports/ \ ecentrics/concordia-app:${sanitizedBranchName}-v${appPackageVersion}-b${BUILD_NUMBER}-tests""" } catch (e) { error('Some tests failed!') From dcb4392c877ff542d5b2a5f4b7f5067db05e05c3 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 14:37:32 +0200 Subject: [PATCH 7/9] fix: revert intentional break --- packages/concordia-app/src/views/Topic/TopicView/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/concordia-app/src/views/Topic/TopicView/index.jsx b/packages/concordia-app/src/views/Topic/TopicView/index.jsx index 9597984..f77715a 100644 --- a/packages/concordia-app/src/views/Topic/TopicView/index.jsx +++ b/packages/concordia-app/src/views/Topic/TopicView/index.jsx @@ -111,7 +111,7 @@ const TopicView = (props) => { if (topicFound) { setTopicSubject(topicFound[TOPIC_SUBJECT]); } - }, [topicId]); + }, [topicId, topics]); const stopClickPropagation = (event) => { event.stopPropagation(); From f3c009a6f3c8970da72c867492806d037e1569b3 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 15:42:17 +0200 Subject: [PATCH 8/9] fix: fix docker contracts test script --- docker/concordia-contracts/test-contracts.sh | 14 ++++++++++---- docker/env/ganache.test.env | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docker/concordia-contracts/test-contracts.sh b/docker/concordia-contracts/test-contracts.sh index c8ac042..f441048 100644 --- a/docker/concordia-contracts/test-contracts.sh +++ b/docker/concordia-contracts/test-contracts.sh @@ -3,11 +3,17 @@ export CHAIN_HOST="$TEST_CHAIN_HOST" export CHAIN_PORT="$TEST_CHAIN_PORT" -yarn _eslint -f html -o /mnt/concordia/test-reports/concordia-contracts-eslint.html --no-color && - (yarn _solhint >/mnt/concordia/test-reports/concordia-contracts-solhint.report) && - (yarn test --network env >/mnt/concordia/test-reports/concordia-contracts-truffle-tests.report) +yarn _eslint -f html -o /mnt/concordia/test-reports/concordia-contracts-eslint.html --no-color +ESLINT_EXIT_STATUS=$? -if [ $? -eq 0 ]; then +yarn _solhint >/mnt/concordia/test-reports/concordia-contracts-solhint.report +SOLHINT_EXIT_STATUS=$? + +yarn test --network env >/mnt/concordia/test-reports/concordia-contracts-truffle-tests.report +grep -qE failing /mnt/concordia/test-reports/concordia-contracts-truffle-tests.report +TRUFFLE_TEST_FAILING=$? + +if [ $ESLINT_EXIT_STATUS -eq 0 ] && [ "$SOLHINT_EXIT_STATUS" -eq 0 ] && [ "$TRUFFLE_TEST_FAILING" -eq 1 ]; then echo "TESTS RAN SUCCESSFULLY!" exit 0 else diff --git a/docker/env/ganache.test.env b/docker/env/ganache.test.env index 479da1f..b81f7a7 100755 --- a/docker/env/ganache.test.env +++ b/docker/env/ganache.test.env @@ -1,5 +1,5 @@ ACCOUNTS_NUMBER=5 -ACCOUNTS_ETHER=1 +ACCOUNTS_ETHER=100 MNEMONIC="myth like bonus scare over problem client lizard pioneer submit female collect" HOST=0.0.0.0 PORT=8546 From 19e3fb1f0a6eccde718d7e164f9cb1472cb19d00 Mon Sep 17 00:00:00 2001 From: apostolof Date: Sun, 28 Feb 2021 15:43:01 +0200 Subject: [PATCH 9/9] fix: use sh instead of docker plugin --- jenkins/Jenkinsfile | 64 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile index 7d3ba88..159c1a1 100755 --- a/jenkins/Jenkinsfile +++ b/jenkins/Jenkinsfile @@ -19,9 +19,7 @@ def sharedPackageVersion // Docker images def appImage -def appTestsImage def contractsImage -def contractsTestsImage def contractsProviderImage def pinnerImage @@ -113,44 +111,46 @@ pipeline { stage('TEST CONTRACTS') { steps { script { - try { - def ganacheTestPort = sh(script: "bash ./jenkins/hash_build_properties.sh ${BRANCH_NAME} ${BUILD_NUMBER} | xargs bash ./jenkins/map_to_thousand.sh", returnStdout: true).trim() + def ganacheTestPort = sh(script: "bash ./jenkins/hash_build_properties.sh ${BRANCH_NAME} ${BUILD_NUMBER} | xargs bash ./jenkins/map_to_thousand.sh", returnStdout: true).trim() + + def ganacheTestImage = docker.build( + "ecentrics/concordia-ganache", + "-f docker/ganache/Dockerfile \ + ./" + ) - def ganacheTestImage = docker.build( - "ecentrics/concordia-ganache", - "-f docker/ganache/Dockerfile \ - ./" - ) + docker.build( + "ecentrics/concordia-contracts-tests:${sanitizedBranchName}-v${contractsPackageVersion}-b${BUILD_NUMBER}-tests", + "-f docker/concordia-contracts/Dockerfile \ + ./ \ + --target test \ + --build-arg TZ=Europe/Athens" + ) - sh 'docker network create --driver bridge concordia_ganache_test_network || true' + sh 'docker network create --driver bridge concordia_ganache_test_network || true' - ganacheTestImage.withRun("""-d -p 6${ganacheTestPort}:8546 \ + ganacheTestImage.withRun("""-d -p 6${ganacheTestPort}:8546 \ --env-file=./jenkins/env/ganache.test.jenkins.env \ --name concordia-ganache-test-6${ganacheTestPort} \ --net=concordia_ganache_test_network""") { concordiaGanacheTest -> - contractsTestsImage = docker.build( - "ecentrics/concordia-contracts-tests:${sanitizedBranchName}-v${contractsPackageVersion}-b${BUILD_NUMBER}-tests", - "-f docker/concordia-contracts/Dockerfile \ - ./ \ - --target test \ - --build-arg TZ=Europe/Athens" - ) - - contractsTestsImage.run("""--rm \ - -v ecentrics_janus_common:/mnt/concordia/test-reports/ \ - --env-file=./jenkins/env/contracts.test.jenkins.env \ - -e WEB3_HOST=concordia-ganache-test-6${ganacheTestPort} \ - -e WEB3_PORT=6${ganacheTestPort} \ - --net=concordia_ganache_test_network""") + try { + sh """docker run \ + --rm \ + -v ecentrics_janus_common:/mnt/concordia/test-reports/ \ + --env-file=./jenkins/env/contracts.test.jenkins.env \ + -e WEB3_HOST=concordia-ganache-test-6${ganacheTestPort} \ + -e WEB3_PORT=6${ganacheTestPort} \ + --net=concordia_ganache_test_network \ + ecentrics/concordia-contracts-tests:${sanitizedBranchName}-v${contractsPackageVersion}-b${BUILD_NUMBER}-tests""" + } catch (e) { + error('Some tests failed!') + error('Aborting the build.') + throw e + } finally { + sh 'mkdir -p ./reports/${BUILD_NUMBER}/contracts' + sh 'find /mnt/janus/common/ -name "concordia-contracts-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/contracts/ \\;' } - } catch (e) { - error('Some tests failed!') - error('Aborting the build.') - throw e - } finally { - sh 'mkdir -p ./reports/${BUILD_NUMBER}/contracts' - sh 'find /mnt/janus/common/ -name "concordia-contracts-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/contracts/ \\;' } } }