Debian Codegraph @

.cargo/vendor/zerocopy/ci/check_job_dependencies.sh

raw
1 #!/usr/bin/env bash
2 #
3 # Copyright 2024 The Fuchsia Authors
4 #
5 # Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
6 # <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
7 # license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
8 # This file may not be copied, modified, or distributed except according to
9 # those terms.
10
11 set -eo pipefail
12 which yq > /dev/null
13 jobs=$(for i in $(find .github -iname '*.yaml' -or -iname '*.yml')
14 do
15 # Select jobs that are triggered by pull request.
16 if yq -e '.on | has("pull_request")' "$i" 2>/dev/null >/dev/null
17 then
18 # This gets the list of jobs that all-jobs-succeed does not depend on.
19 comm -23 \
20 <(yq -r '.jobs | keys | .[]' "$i" | sort | uniq) \
21 <(yq -r '.jobs.all-jobs-succeed.needs[]' "$i" | sort | uniq)
22 fi
23
24 # The grep call here excludes all-jobs-succeed from the list of jobs that
25 # all-jobs-succeed does not depend on. If all-jobs-succeed does
26 # not depend on itself, we do not care about it.
27 done | sort | uniq | (grep -v '^all-jobs-succeed$' || true)
28 )
29
30 if [ -n "$jobs" ]
31 then
32 missing_jobs="$(echo "$jobs" | tr ' ' '\n')"
33 echo "all-jobs-succeed missing dependencies on some jobs: $missing_jobs" | tee -a $GITHUB_STEP_SUMMARY >&2
34 exit 1
35 fi