From 1e43d71b89b8bc88d048cd5d59a8f01e14080799 Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 12 Nov 2024 18:38:03 +0800 Subject: [PATCH 1/4] test:add docs ci in jenkinsfile2 --- Jenkinsfile2 | 164 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 130 insertions(+), 34 deletions(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index a9c829660a..b615c0205e 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -1,9 +1,11 @@ import hudson.model.Result import hudson.model.*; import jenkins.model.CauseOfInterruption -docs_only=0 node { } +file_zh_changed = '' +file_en_changed = '' +file_no_doc_changed = '' def abortPreviousBuilds() { def currentJobName = env.JOB_NAME def currentBuildNumber = env.BUILD_NUMBER.toInteger() @@ -29,7 +31,7 @@ def abort_previous(){ if (buildNumber > 1) milestone(buildNumber - 1) milestone(buildNumber) } -def check_docs() { +def check_docs(){ if (env.CHANGE_URL =~ /\/TDengine\//) { sh ''' hostname @@ -40,39 +42,91 @@ def check_docs() { cd ${WKC} git reset --hard git clean -f - rm -rf examples/rust/ git remote prune origin git fetch - ''' - script { - sh ''' - cd ${WKC} - git checkout ''' + env.CHANGE_TARGET + ''' - ''' - } - sh ''' - cd ${WKC} - git remote prune origin + git checkout ''' + env.CHANGE_TARGET + ''' git pull >/dev/null git fetch origin +refs/pull/${CHANGE_ID}/merge - git checkout -qf FETCH_HEAD + git checkout -qf FETCH_HEAD ''' - def file_changed = sh ( + + file_zh_changed = sh ( script: ''' cd ${WKC} - git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD ${CHANGE_TARGET}`|grep -v "^docs/en/"|grep -v "^docs/zh/" || : + git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD ${CHANGE_TARGET}`|grep "^docs/zh/" || : + ''', + returnStdout: true + ) + + file_en_changed = sh ( + script: ''' + cd ${WKC} + git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD ${CHANGE_TARGET}`|grep "^docs/en/" || : + ''', + returnStdout: true + ) + + file_no_doc_changed = sh ( + script: ''' + cd ${WKC} + git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD ${CHANGE_TARGET}`|grep -v "^docs/en/"|grep -v "^docs/zh/"|grep -v "*.md" || : ''', returnStdout: true ).trim() - if (file_changed == '') { - echo "docs PR" - docs_only=1 - } else { - echo file_changed - } - env.FILE_CHANGED = file_changed } } + +def build_pre_docs(){ + if (env.CHANGE_URL =~ /\/TDengine\//) { + sh ''' + hostname + date + env + ''' + + sh ''' + cd ${DOC_WKC}/${td_repo} + git reset --hard + git clean -f + git remote prune origin + git fetch + git checkout ''' + env.CHANGE_TARGET + ''' + git pull >/dev/null + git fetch origin +refs/pull/${CHANGE_ID}/merge + git checkout -qf FETCH_HEAD + ''' + + sh ''' + cd ${DOC_WKC}/${tools_repo} + git reset --hard + git clean -f + git fetch + git remote prune origin + git checkout ''' + env.CHANGE_TARGET + ''' + git pull >/dev/null + ''' + } +} + +def build_zh_docs(){ + sh ''' + cd ${DOC_WKC}/${zh_doc_repo} + # git pull + yarn ass local + yarn build + ''' +} + +def build_en_docs(){ + sh ''' + cd ${DOC_WKC}/${en_doc_repo} + # git pull + yarn ass local + yarn build + ''' +} + + def pre_test(){ sh ''' hostname @@ -153,6 +207,7 @@ def pre_test(){ ''' return 1 } + def pre_test_build_mac() { sh ''' hostname @@ -173,6 +228,7 @@ def pre_test_build_mac() { date ''' } + def pre_test_win(){ bat ''' hostname @@ -284,6 +340,7 @@ def pre_test_win(){ git log -5 ''' } + def pre_test_build_win() { bat ''' echo "building ..." @@ -313,6 +370,7 @@ def pre_test_build_win() { ''' return 1 } + def run_win_ctest() { bat ''' echo "windows ctest ..." @@ -322,6 +380,7 @@ def run_win_ctest() { time /t ''' } + def run_win_test() { bat ''' echo "windows test ..." @@ -344,28 +403,65 @@ pipeline { WK = '/var/lib/jenkins/workspace/TDinternal' WKC = '/var/lib/jenkins/workspace/TDinternal/community' WKPY = '/var/lib/jenkins/workspace/taos-connector-python' + DOC_WKC = '/root/doc_ci_work' + td_repo = 'TDengine' + zh_doc_repo = 'docs.taosdata.com' + en_doc_repo = 'docs.tdengine.com' + tools_repo = 'taos-tools' } stages { - stage('check') { + stage ('check doc file changed') { + agent{label " slave1_47 || slave1_48 || slave1_49 || slave1_50 || slave1_52 || slave1_59 || slave1_63 || worker03 || slave215 || slave217 || slave219 || Mac_catalina "} + steps { + check_docs() + } + } + + stage ('pre for build docs') { + agent{label "doc_build_0_30"} when { - allOf { - not { expression { env.CHANGE_BRANCH =~ /docs\// }} - } + expression { env.CHANGE_BRANCH =~ /(?i)doc.*/ || file_zh_changed != '' || file_en_changed != '' } + } + steps { + build_pre_docs() + } + } + + stage('build Docs') { + when { + expression { env.CHANGE_BRANCH =~ /(?i)doc.*/ || file_zh_changed != '' || file_en_changed != '' } } parallel { - stage('check docs') { - agent{label " slave1_47 || slave1_48 || slave1_49 || slave1_50 || slave1_52 || slave1_59 || slave1_63 || worker03 || slave215 || slave217 || slave219 || Mac_catalina "} + stage('Build zh Docs') { + agent{label "doc_build_0_30"} + when { + expression { file_zh_changed != '' } + } steps { - check_docs() + build_zh_docs() + } + } + stage('Build en Docs') { + agent{label "doc_build_0_30"} + when { + expression { file_en_changed != '' } + } + steps { + build_en_docs() } } } + post { + unsuccessful { + error('build docs stage failed, terminating pipeline.') + } + } } + stage('run test') { when { allOf { - not { expression { env.CHANGE_BRANCH =~ /docs\// }} - expression { docs_only == 0 } + not { expression { file_no_doc_changed == '' }} } } parallel { @@ -420,7 +516,7 @@ pipeline { script { sh ''' mkdir -p ${WKDIR}/tmp/${BRANCH_NAME}_${BUILD_ID} - echo "''' + env.FILE_CHANGED + '''" > ${WKDIR}/tmp/${BRANCH_NAME}_${BUILD_ID}/docs_changed.txt + echo "''' + file_no_doc_changed + '''" > ${WKDIR}/tmp/${BRANCH_NAME}_${BUILD_ID}/docs_changed.txt ''' sh ''' cd ${WKC}/tests/parallel_test @@ -570,4 +666,4 @@ pipeline { ) } } -} +} \ No newline at end of file From bfd8410047792e241e2bb421c2deca2ab953b9e8 Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 12 Nov 2024 20:08:02 +0800 Subject: [PATCH 2/4] test:add docs ci in jenkinsfile2 --- Jenkinsfile2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index b615c0205e..e5fe0ba60a 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -418,10 +418,11 @@ pipeline { } stage ('pre for build docs') { - agent{label "doc_build_0_30"} when { + beforeAgent true expression { env.CHANGE_BRANCH =~ /(?i)doc.*/ || file_zh_changed != '' || file_en_changed != '' } } + agent{label "doc_build_0_30"} steps { build_pre_docs() } @@ -429,6 +430,7 @@ pipeline { stage('build Docs') { when { + beforeAgent true expression { env.CHANGE_BRANCH =~ /(?i)doc.*/ || file_zh_changed != '' || file_en_changed != '' } } parallel { From ef367c8f8fd117f468296569c19f8fe023883503 Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 12 Nov 2024 20:11:57 +0800 Subject: [PATCH 3/4] test:add error md --- docs/zh/04-get-started/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/04-get-started/index.md b/docs/zh/04-get-started/index.md index 4d9f7ceae5..2cc3d8cc5e 100644 --- a/docs/zh/04-get-started/index.md +++ b/docs/zh/04-get-started/index.md @@ -25,7 +25,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common'; - + From dcdf098878c2280266f6e4e38062d0b14bea8121 Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 12 Nov 2024 21:47:07 +0800 Subject: [PATCH 4/4] test:add docs ci in jenkinsfile2 --- Jenkinsfile2 | 7 +++++-- docs/zh/04-get-started/index.md | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index e5fe0ba60a..80bc39d938 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -73,6 +73,9 @@ def check_docs(){ ''', returnStdout: true ).trim() + echo "file_zh_changed: ${file_zh_changed}" + echo "file_en_changed: ${file_en_changed}" + echo "file_no_doc_changed: ${file_no_doc_changed}" } } @@ -434,7 +437,7 @@ pipeline { expression { env.CHANGE_BRANCH =~ /(?i)doc.*/ || file_zh_changed != '' || file_en_changed != '' } } parallel { - stage('Build zh Docs') { + stage('build zh docs') { agent{label "doc_build_0_30"} when { expression { file_zh_changed != '' } @@ -443,7 +446,7 @@ pipeline { build_zh_docs() } } - stage('Build en Docs') { + stage('build en docs') { agent{label "doc_build_0_30"} when { expression { file_en_changed != '' } diff --git a/docs/zh/04-get-started/index.md b/docs/zh/04-get-started/index.md index 2cc3d8cc5e..4d9f7ceae5 100644 --- a/docs/zh/04-get-started/index.md +++ b/docs/zh/04-get-started/index.md @@ -25,7 +25,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
小 T 的二维码小 T 的二维码 width= TDengine 微信视频号 TDengine 微信公众号
- +
小 T 的二维码 width=小 T 的二维码 TDengine 微信视频号 TDengine 微信公众号