Skip to content
代码片段 群组 项目
提交 8807bf6c 编辑于 作者: Marcel Amirault's avatar Marcel Amirault
浏览文件

Test only changed docs in merged results pipelines

Check what type of pipeline is running. If it's a merged
results pipeline, use CI variables to determine the
merge-base. Use git diff with merge-base to see what files
changes, filtering on markdown files, then run vale and
markdownlint on only those changed files.
上级 cf057764
No related branches found
No related tags found
无相关合并请求
...@@ -55,7 +55,18 @@ then ...@@ -55,7 +55,18 @@ then
((ERRORCODE++)) ((ERRORCODE++))
fi fi
MD_DOC_PATH=${MD_DOC_PATH:-doc} # Run Vale and Markdownlint only on changed files. Only works on merged results
# pipelines, so first checks if a merged results CI variable is present. If not present,
# runs test on all files.
if [ -z "${CI_MERGE_REQUEST_TARGET_BRANCH_SHA}" ]
then
MD_DOC_PATH=${MD_DOC_PATH:-doc}
echo "Merge request pipeline (detached) detected. Testing all files."
else
MERGE_BASE=$(git merge-base ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA} ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA})
MD_DOC_PATH=$(git diff --name-only "${MERGE_BASE}..${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}" '*.md')
echo -e "Merged results pipeline detected. Testing only the following files:\n${MD_DOC_PATH}"
fi
function run_locally_or_in_docker() { function run_locally_or_in_docker() {
local cmd=$1 local cmd=$1
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册