2 # Set the SKIP_JOB environment variable if this job is supposed to only run
3 # when submodules are updated and they were not. The following time consuming
4 # tasks will be skipped when the environment variable is present.
9 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
11 if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then
12 echo "Executing the job since there is no skip rule in effect"
16 git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
17 BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
19 echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
21 if git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
22 # Submodules pseudo-files inside git have the 160000 permissions, so when
23 # those files are present in the diff a submodule was updated.
24 echo "Executing the job since submodules are updated"
25 elif ! git diff --quiet "$BASE_COMMIT" -- src/tools/clippy src/tools/rustfmt; then
26 # There is not an easy blanket search for subtrees. For now, manually list
28 echo "Executing the job since clippy or rustfmt subtree was updated"
29 elif ! (git diff --quiet "$BASE_COMMIT" -- \
30 src/test/rustdoc-gui \
32 src/tools/rustdoc-gui); then
33 # There was a change in either rustdoc or in its GUI tests.
34 echo "Executing the job since rustdoc was updated"
36 echo "Not executing this job since no submodules nor subtrees were updated"
37 ciCommandSetEnv SKIP_JOB 1