forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#65724 - pietroalbini:ci-remove-template-par…
…ameter, r=alexcrichton ci: refactor pr tools job skipping We have a job in our CI (PR's x86_64-gnu-tools) that's supposed to run only when a submodule is changed in the PR, and it works by having a task at the start of the build that skips all the following tasks if the condition isn't met. Before this commit that task was gated with template parameters, which is a unique feature of Azure Pipelines. To make our CI more generic this commit switches the gate to use a simple environment variable plus a condition, which should be supported on more CI providers. This PR also extracts the skipping logic into a script. r? @alexcrichton
- Loading branch information
Showing
3 changed files
with
25 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# Set the SKIP_JOB environment variable if this job is supposed to only run | ||
# when submodules are updated and they were not. The following time consuming | ||
# tasks will be skipped when the environment variable is present. | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" | ||
|
||
if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then | ||
echo "Executing the job since there is no skip rule in effect" | ||
elif git diff HEAD^ | grep --quiet "^index .* 160000"; then | ||
# Submodules pseudo-files inside git have the 160000 permissions, so when | ||
# those files are present in the diff a submodule was updated. | ||
echo "Executing the job since submodules are updated" | ||
else | ||
echo "Not executing this job since no submodules were updated" | ||
ciCommandSetEnv SKIP_JOB 1 | ||
fi |