-
Notifications
You must be signed in to change notification settings - Fork 112
docs/docs-cn: simplify pull_verify pipeline #4521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,82 +10,113 @@ final REFS = readJSON(text: params.JOB_SPEC).refs | |
|
|
||
| prow.setPRDescription(REFS) | ||
| pipeline { | ||
| agent none | ||
| environment { | ||
| FILE_SERVER_URL = 'http://fileserver.pingcap.net' | ||
| agent { | ||
| kubernetes { | ||
| namespace K8S_NAMESPACE | ||
| yamlFile POD_TEMPLATE_FILE | ||
| defaultContainer 'runner' | ||
| } | ||
| } | ||
| options { | ||
| timeout(time: 40, unit: 'MINUTES') | ||
| parallelsAlwaysFailFast() | ||
| } | ||
| stages { | ||
| stage("Tests") { | ||
| matrix { | ||
| axes { | ||
| axis { | ||
| name 'CHECK_CMD' | ||
| values "python3 check-file-encoding.py", "python3 check-conflicts.py", "markdownlint", | ||
| "python3 check-control-char.py", "python3 check-tags.py", "python3 check-manual-line-breaks.py" | ||
| stage('Checkout') { | ||
| steps { | ||
| dir(REFS.repo) { | ||
| sh label: 'set git config', script: """ | ||
| git config --global --add safe.directory '*' | ||
| """ | ||
| script { | ||
| prow.checkoutRefsWithCacheLock(REFS) | ||
| } | ||
| } | ||
| agent{ | ||
| kubernetes { | ||
| namespace K8S_NAMESPACE | ||
| yamlFile POD_TEMPLATE_FILE | ||
| defaultContainer 'runner' | ||
| } | ||
| } | ||
| } | ||
| stage('Prepare') { | ||
| steps { | ||
| dir(REFS.repo) { | ||
| sh label: 'Prepare check scripts', script: """#!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| rm -rf ../check-scripts | ||
| mkdir -p ../check-scripts | ||
|
|
||
| wget -O ../check-scripts/check-file-encoding.py https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-file-encoding.py | ||
| wget -O ../check-scripts/check-conflicts.py https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-conflicts.py | ||
| wget -O ../check-scripts/check-control-char.py https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-control-char.py | ||
| wget -O ../check-scripts/check-tags.py https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-tags.py | ||
| wget -O ../check-scripts/check-manual-line-breaks.py https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-manual-line-breaks.py | ||
|
|
||
| ls -al ../check-scripts | ||
| """ | ||
| } | ||
| stages { | ||
| stage('Checkout') { | ||
| steps { | ||
| dir(REFS.repo) { | ||
| sh label: "set git config", script: """ | ||
| git config --global --add safe.directory '*' | ||
| """ | ||
| script { | ||
| prow.checkoutRefsWithCache(REFS) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('Prepare') { | ||
| steps { | ||
| dir('check-scripts') { | ||
| sh label: 'Prepare', script: """ | ||
| wget https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-file-encoding.py | ||
| wget https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-conflicts.py | ||
| wget https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-control-char.py | ||
| wget https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-tags.py | ||
| wget https://raw.githubusercontent.com/pingcap/docs/master/scripts/check-manual-line-breaks.py | ||
| """ | ||
| } | ||
| } | ||
| } | ||
| stage("Test") { | ||
| steps { | ||
| dir(REFS.repo) { | ||
| sh label: "set git config", script: """ | ||
| git rev-parse --show-toplevel | ||
| git status -s . | ||
| git log --format="%h %B" --oneline -n 3 | ||
| """ | ||
| // TODO: remove this debug lines | ||
| sh """ | ||
| git diff-tree --name-only --no-commit-id -r origin/${REFS.base_ref}..HEAD -- '*.md' ':(exclude).github/*' | ||
| """ | ||
| sh label: "check ${CHECK_CMD}", script: """#!/usr/bin/env bash | ||
| cp -r ../check-scripts/* ./ | ||
| diff_docs_files=\$(git diff-tree --name-only --no-commit-id -r origin/${REFS.base_ref}..HEAD -- '*.md' ':(exclude).github/*') | ||
|
|
||
| if [[ "${CHECK_CMD}" == "markdownlint" ]]; then | ||
| npm install -g markdownlint-cli@0.17.0 | ||
| fi | ||
|
|
||
| ${CHECK_CMD} \$diff_docs_files | ||
| """ | ||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('Verify') { | ||
| steps { | ||
| dir(REFS.repo) { | ||
| sh label: 'Debug info', script: """ | ||
| git rev-parse --show-toplevel | ||
| git status -s . | ||
| git log --format="%h %B" --oneline -n 3 | ||
| """ | ||
| sh label: 'Run pull_verify checks', script: """#!/usr/bin/env bash | ||
| set -uo pipefail | ||
|
|
||
| mapfile -t diff_docs_files < <( | ||
| git diff-tree --name-only --no-commit-id -r origin/${REFS.base_ref}..HEAD -- '*.md' ':(exclude).github/*' | ||
| ) | ||
|
|
||
| if ((\${#diff_docs_files[@]} == 0)); then | ||
| echo 'No changed Markdown files, skip pull_verify checks.' | ||
| exit 0 | ||
| fi | ||
|
|
||
| printf 'Changed Markdown files (%s):\\n' "\${#diff_docs_files[@]}" | ||
| printf ' - %s\\n' "\${diff_docs_files[@]}" | ||
|
|
||
| cp -r ../check-scripts/* ./ | ||
|
|
||
| failed_checks=() | ||
|
|
||
| run_check() { | ||
| local name="\$1" | ||
| shift | ||
|
|
||
| echo "==> Running \${name}" | ||
| if "\$@" "\${diff_docs_files[@]}"; then | ||
| echo "==> \${name}: PASS" | ||
| else | ||
| echo "==> \${name}: FAIL" | ||
| failed_checks+=("\${name}") | ||
| fi | ||
| echo | ||
| } | ||
|
|
||
| run_check 'check-conflicts' python3 ./check-conflicts.py | ||
| run_check 'check-control-char' python3 ./check-control-char.py | ||
| run_check 'check-tags' python3 ./check-tags.py | ||
| run_check 'check-manual-line-breaks' python3 ./check-manual-line-breaks.py | ||
|
Comment on lines
+79
to
+100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of managing check scripts at runtime by copying them or referencing sibling directories, these scripts should be baked into the Docker image. This approach improves CI reliability and performance by ensuring a consistent environment and reducing runtime overhead, consistent with repository practices. References
|
||
|
|
||
| echo '==> Installing markdownlint-cli@0.17.0' | ||
| if npm install -g markdownlint-cli@0.17.0; then | ||
| run_check 'markdownlint' markdownlint | ||
| else | ||
| echo '==> markdownlint-install: FAIL' | ||
| failed_checks+=('markdownlint-install') | ||
| fi | ||
|
|
||
| run_check 'check-file-encoding' python3 ./check-file-encoding.py | ||
|
|
||
| if ((\${#failed_checks[@]} > 0)); then | ||
| printf 'pull_verify failed checks (%s):\\n' "\${#failed_checks[@]}" | ||
| printf ' - %s\\n' "\${failed_checks[@]}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo 'All pull_verify checks passed.' | ||
| """ | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of managing check scripts at runtime by copying them or referencing sibling directories, these scripts should be baked into the Docker image. This approach improves CI reliability and performance by ensuring a consistent environment and reducing runtime overhead, consistent with repository practices.
References