]> git.proxmox.com Git - rustc.git/blame - src/ci/scripts/should-skip-this.sh
New upstream version 1.55.0+dfsg1
[rustc.git] / src / ci / scripts / should-skip-this.sh
CommitLineData
e74abb32
XL
1#!/bin/bash
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.
5
6set -euo pipefail
7IFS=$'\n\t'
8
9source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
10
136023e0
XL
11if [[ -n "${CI_ONLY_WHEN_SUBMODULES_CHANGED-}" ]]; then
12 git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
13 BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
14
15 echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
16
17 if git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
18 # Submodules pseudo-files inside git have the 160000 permissions, so when
19 # those files are present in the diff a submodule was updated.
20 echo "Submodules were updated"
21 elif ! git diff --quiet "$BASE_COMMIT" -- src/tools/clippy src/tools/rustfmt; then
22 # There is not an easy blanket search for subtrees. For now, manually list
23 # the subtrees.
24 echo "Clippy or rustfmt subtrees were updated"
25 elif ! (git diff --quiet "$BASE_COMMIT" -- \
26 src/test/rustdoc-gui \
27 src/librustdoc \
28 src/tools/rustdoc-gui); then
29 # There was a change in either rustdoc or in its GUI tests.
30 echo "Rustdoc was updated"
31 else
32 echo "Not executing this job since no submodules nor subtrees were updated"
33 ciCommandSetEnv SKIP_JOB 1
34 exit 0
35 fi
17df50a5
XL
36fi
37
136023e0
XL
38if [[ -n "${CI_ONLY_WHEN_CHANNEL-}" ]]; then
39 if [[ "${CI_ONLY_WHEN_CHANNEL}" = "$(cat src/ci/channel)" ]]; then
40 echo "The channel is the expected one"
41 else
42 echo "Not executing this job as the channel is not the expected one"
43 ciCommandSetEnv SKIP_JOB 1
44 exit 0
45 fi
e74abb32 46fi
136023e0
XL
47
48
49echo "Executing the job since there is no skip rule preventing the execution"
50exit 0