Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: refactor pr tools job skipping #65724

Merged
merged 3 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/ci/azure-pipelines/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ jobs:
IMAGE: x86_64-gnu-llvm-6.0
mingw-check:
IMAGE: mingw-check

- job: LinuxTools
timeoutInMinutes: 600
pool:
vmImage: ubuntu-16.04
steps:
- template: steps/run.yml
parameters:
only_on_updated_submodules: 'yes'
variables:
IMAGE: x86_64-gnu-tools
x86_64-gnu-tools:
IMAGE: x86_64-gnu-tools
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
22 changes: 2 additions & 20 deletions src/ci/azure-pipelines/steps/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
#
# Check travis config for `gdb --batch` command to print all crash logs

parameters:
# When this parameter is set to anything other than an empty string the tests
# will only be executed when the commit updates submodules
only_on_updated_submodules: ''

steps:

# Disable automatic line ending conversion, which is enabled by default on
Expand All @@ -26,21 +21,8 @@ steps:
- checkout: self
fetchDepth: 2

# 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.
- ${{ if parameters.only_on_updated_submodules }}:
- bash: |
set -e
# Submodules pseudo-files inside git have the 160000 permissions, so when
# those files are present in the diff a submodule was updated.
if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then
echo "Executing the job since submodules are updated"
else
echo "Not executing this job since no submodules were updated"
echo "##vso[task.setvariable variable=SKIP_JOB;]1"
fi
displayName: Decide whether to run this job
- bash: src/ci/scripts/should-skip-this.sh
displayName: Decide whether to run this job

# Spawn a background process to collect CPU usage statistics which we'll upload
# at the end of the build. See the comments in the script here for more
Expand Down
20 changes: 20 additions & 0 deletions src/ci/scripts/should-skip-this.sh
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 "^index .* 160000" >/dev/null 2>&1; then
pietroalbini marked this conversation as resolved.
Show resolved Hide resolved
# 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