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
32 changes: 25 additions & 7 deletions pipelines/pingcap-qe/tidb-test/latest/ghpr_build/pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ final POD_TEMPLATE_FILE = "pipelines/${GIT_FULL_REPO_NAME}/${BRANCH_ALIAS}/${JOB
final REFS = readJSON(text: params.JOB_SPEC).refs

pipeline {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
defaultContainer 'golang'
}
}
agent none
options {
timeout(time: 30, unit: 'MINUTES')
}
stages {
stage('Checkout') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
options { timeout(time: 5, unit: 'MINUTES') }
steps {
dir("tidb") {
Expand All @@ -45,8 +47,24 @@ pipeline {
}
}
stage("Build"){
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
steps {
dir("tidb") {
cache(path: "./", includes: '**/*', key: "git/pingcap/tidb/rev-${REFS.pulls[0].sha}}", restoreKeys: ['git/pingcap/tidb/rev-']) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the cache key: an extra closing brace } at the end of the string interpolation ${REFS.pulls[0].sha}}. For better consistency and robustness, it is recommended to use prow.getCacheKey('git', REFS) instead of hardcoding the key. Please also check and fix the same typo in the Checkout stage (line 30).

                    cache(path: "./", includes: '**/*', key: prow.getCacheKey('git', REFS), restoreKeys: prow.getRestoreKeys('git', REFS)) {
References
  1. In Groovy pipeline scripts for this repository, the REFS.repo variable evaluates to the string 'tidb', making it interchangeable with the hardcoded value.

sh label: 'restore tidb', script: 'git rev-parse HEAD'
}
}
dir("tidb-test") {
cache(path: "./", includes: '**/*', key: "git/PingCAP-QE/tidb-test/rev-${REFS.pulls[0].sha}}", restoreKeys: ['git/PingCAP-QE/tidb-test/rev-']) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the cache key: an extra closing brace } at the end of the string interpolation ${REFS.pulls[0].sha}}. For better consistency and robustness (especially for batch builds), it is recommended to use prow.getCacheKey('git', REFS) instead of hardcoding the key. Please also check and fix the same typo in the Checkout stage (line 39).

                    cache(path: "./", includes: '**/*', key: prow.getCacheKey('git', REFS), restoreKeys: prow.getRestoreKeys('git', REFS)) {
References
  1. In Groovy pipeline scripts for this repository, the REFS.repo variable evaluates to the string 'tidb', making it interchangeable with the hardcoded value.

sh label: 'restore tidb-test', script: 'git rev-parse HEAD'
}
sh """
TIDB_SRC_PATH=${WORKSPACE}/tidb make check
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ final OCI_TAG_PD = component.computeArtifactOciTagFromPR('pd', REFS.base_ref, RE
final OCI_TAG_TIKV = component.computeArtifactOciTagFromPR('tikv', REFS.base_ref, REFS.pulls[0].title, 'master')

pipeline {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
defaultContainer 'golang'
}
}
agent none
options {
timeout(time: 60, unit: 'MINUTES')
parallelsAlwaysFailFast()
}
stages {
stage('Checkout') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
options { timeout(time: 5, unit: 'MINUTES') }
steps {
dir("tidb") {
Expand All @@ -48,8 +50,19 @@ pipeline {
}
}
stage('Prepare') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
steps {
dir('tidb') {
cache(path: "./", includes: '**/*', key: "git/pingcap/tidb/rev-${REFS.pulls[0].sha}", restoreKeys: ['git/pingcap/tidb/rev-']) {
sh label: 'restore tidb', script: 'git rev-parse HEAD'
}
cache(path: "./bin", includes: '**/*', key: "ws/${BUILD_TAG}/dependencies") {
sh label: 'tidb-server', script: 'make'
container("utils") {
Expand Down Expand Up @@ -86,6 +99,7 @@ pipeline {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'java'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ final OCI_TAG_PD = component.computeArtifactOciTagFromPR('pd', REFS.base_ref, RE
final OCI_TAG_TIKV = component.computeArtifactOciTagFromPR('tikv', REFS.base_ref, REFS.pulls[0].title, 'master')

pipeline {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
defaultContainer 'golang'
}
}
agent none
options {
timeout(time: 60, unit: 'MINUTES')
parallelsAlwaysFailFast()
}
stages {
stage('Checkout') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
options { timeout(time: 5, unit: 'MINUTES') }
steps {
dir("tidb") {
Expand All @@ -48,8 +50,19 @@ pipeline {
}
}
stage('Prepare') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
steps {
dir('tidb') {
cache(path: "./", includes: '**/*', key: "git/pingcap/tidb/rev-${REFS.pulls[0].sha}", restoreKeys: ['git/pingcap/tidb/rev-']) {
sh label: 'restore tidb', script: 'git rev-parse HEAD'
}
cache(path: "./bin", includes: '**/*', key: "ws/${BUILD_TAG}/dependencies") {
sh label: 'tidb-server', script: 'make'
container("utils") {
Expand Down Expand Up @@ -87,6 +100,7 @@ pipeline {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ final OCI_TAG_PD = component.computeArtifactOciTagFromPR('pd', REFS.base_ref, RE
final OCI_TAG_TIKV = component.computeArtifactOciTagFromPR('tikv', REFS.base_ref, REFS.pulls[0].title, 'master')

pipeline {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
defaultContainer 'golang'
}
}
agent none
options {
timeout(time: 60, unit: 'MINUTES')
parallelsAlwaysFailFast()
}
stages {
stage('Checkout') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
options { timeout(time: 5, unit: 'MINUTES') }
steps {
dir("tidb") {
Expand All @@ -48,8 +50,19 @@ pipeline {
}
}
stage('Prepare') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
steps {
dir('tidb') {
cache(path: "./", includes: '**/*', key: "git/pingcap/tidb/rev-${REFS.pulls[0].sha}", restoreKeys: ['git/pingcap/tidb/rev-']) {
sh label: 'restore tidb', script: 'git rev-parse HEAD'
}
cache(path: "./bin", includes: '**/*', key: "ws/${BUILD_TAG}/dependencies") {
sh label: 'tidb-server', script: 'make'
container("utils") {
Expand Down Expand Up @@ -91,6 +104,7 @@ pipeline {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'java'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ final OCI_TAG_PD = component.computeArtifactOciTagFromPR('pd', REFS.base_ref, RE
final OCI_TAG_TIKV = component.computeArtifactOciTagFromPR('tikv', REFS.base_ref, REFS.pulls[0].title, 'master')

pipeline {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
defaultContainer 'golang'
}
}
agent none
options {
timeout(time: 45, unit: 'MINUTES')
}
stages {
stage('Checkout') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
options { timeout(time: 5, unit: 'MINUTES') }
steps {
dir("tidb") {
Expand All @@ -47,8 +49,19 @@ pipeline {
}
}
stage('Prepare') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'golang'
}
}
steps {
dir('tidb') {
cache(path: "./", includes: '**/*', key: "git/pingcap/tidb/rev-${REFS.pulls[0].sha}", restoreKeys: ['git/pingcap/tidb/rev-']) {
sh label: 'restore tidb', script: 'git rev-parse HEAD'
}
cache(path: "./bin", includes: '**/*', key: "ws/${BUILD_TAG}/dependencies") {
sh label: 'tidb-server', script: 'make'
container("utils") {
Expand All @@ -69,6 +82,9 @@ pipeline {
}
}
dir('tidb-test') {
cache(path: "./", includes: '**/*', key: prow.getCacheKey('git', REFS), restoreKeys: prow.getRestoreKeys('git', REFS)) {
sh label: 'restore tidb-test', script: 'git rev-parse HEAD'
}
cache(path: "./mysql_test", includes: '**/*', key: "ws/${BUILD_TAG}/mysql-test") {
sh "touch ws-${BUILD_TAG}"
}
Expand All @@ -88,6 +104,7 @@ pipeline {
namespace K8S_NAMESPACE
defaultContainer 'golang'
yamlFile POD_TEMPLATE_FILE
retries 2
}
}
stages {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ final REFS = readJSON(text: params.JOB_SPEC).refs
final OCI_TAG_PD = component.computeArtifactOciTagFromPR('pd', REFS.base_ref, REFS.pulls[0].title, 'master')
final OCI_TAG_TIKV = component.computeArtifactOciTagFromPR('tikv', REFS.base_ref, REFS.pulls[0].title, 'master')
pipeline {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
}
}
agent none
options {
timeout(time: 60, unit: 'MINUTES')
parallelsAlwaysFailFast()
}
stages {
stage('Checkout') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
}
}
options { timeout(time: 5, unit: 'MINUTES') }
steps {
dir("tidb") {
Expand All @@ -46,8 +48,18 @@ pipeline {
}
}
stage('Prepare') {
agent {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
}
}
steps {
dir('tidb') {
cache(path: "./", includes: '**/*', key: "git/pingcap/tidb/rev-${REFS.pulls[0].sha}", restoreKeys: ['git/pingcap/tidb/rev-']) {
sh label: 'restore tidb', script: 'git rev-parse HEAD'
}
container('nodejs') {
cache(path: "./bin", includes: '**/*', key: "ws/${BUILD_TAG}/dependencies") {
sh label: 'tidb-server', script: 'make'
Expand Down Expand Up @@ -86,6 +98,7 @@ pipeline {
kubernetes {
namespace K8S_NAMESPACE
yamlFile POD_TEMPLATE_FILE
retries 2
defaultContainer 'nodejs'
}
}
Expand Down
Loading