From 5e637e6c690e45d13ebf7296e1ea9dcc188d0f07 Mon Sep 17 00:00:00 2001 From: Stas Bekman Date: Wed, 9 Dec 2020 12:36:36 -0800 Subject: [PATCH] [wip] [ci] doc-job-skip take #4 dry-run (#8980) * ci-doc-job-skip-take-4 * wip * wip * wip * wip * skip yaml * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * ready to test * yet another way * trying with HEAD * trying with head.sha * trying with head.sha fix * trying with head.sha fix wip * undo * try to switch to sha * current branch * current branch * PR number check * joy ride * joy ride * joy ride * joy ride * joy ride * joy ride * joy ride * joy ride * joy ride * joy ride * joy ride * joy ride --- .circleci/config.yml | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3963270e61fae8..b6a1b50bd52609 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,21 +11,40 @@ commands: - run: name: docs-only changes skip check command: | - # pipeline.git.base_revision is not always defined, so only proceed if all external vars are defined - if test -n "<< pipeline.git.base_revision >>" && test -n "<< pipeline.git.revision >>" && test -n "$(git diff --name-only << pipeline.git.base_revision >>...<< pipeline.git.revision >>)" + if test -n "$CIRCLE_PR_NUMBER" then - if git diff --name-only << pipeline.git.base_revision >>...<< pipeline.git.revision >> | egrep -qv '\.(md|rst)$' + echo $CIRCLE_PR_NUMBER + resp=$(curl -Ls https://api.github.com/repos/huggingface/transformers/pulls/${CIRCLE_PR_NUMBER}) + user=$(jq -r .user.login \<<< $resp) # PR creator username + head_ref=$(jq -r .head.ref \<<< $resp) # PR user's branch name + echo head_ref=$head_ref, user=$user + fi + + if test -n "$user" && test -n "$head_ref" + then + git clone https://github.com/$user/transformers user-clone + cd user-clone + git checkout $head_ref + fork_point_sha=$(git merge-base --fork-point master) + cd - + fi + + if test -n "$fork_point_sha" && test -n "$(git diff --name-only $fork_point_sha)" + then + git --no-pager diff --name-only $fork_point_sha + if git diff --name-only $fork_point_sha | egrep -qv '\.(md|rst)$' then echo "Non-docs were modified in this PR, proceeding normally" else echo "Only docs were modified in this PR, quitting this job" - # disable skipping for now, as circleCI's base_revision is inconsistent leading to invalid ranges + # enable skipping once we get this sorted out # circleci step halt fi else - echo "Can't perform skipping check w/o base_revision defined, continuing the job" + echo "Not enough data to perform a skipping check - continuing the job" fi + # TPU REFERENCES references: checkout_ml_testing: &checkout_ml_testing