@@ -34,6 +34,7 @@ long_options=(
3434 [force]=" Force a skipped test to run"
3535 [golang]=" Check '.go' files"
3636 [help]=" Display usage statement"
37+ [labels]=" Check labels databases"
3738 [licenses]=" Check licenses"
3839 [branch]=" Specify upstream branch to compare against (default '$branch ')"
3940 [all]=" Force checking of all changes, including files in the base branch"
@@ -276,6 +277,27 @@ check_versions()
276277 fi
277278}
278279
280+ check_labels ()
281+ {
282+ [ $( uname -s) != Linux ] && info " Can only check labels under Linux" && return
283+
284+ # Handle SLES which doesn't provide the required command.
285+ [ -z " $have_yamllint_cmd " ] && info " Cannot check labels as $yamllint_cmd not available" && return
286+
287+ # Since this script is called from another repositories directory,
288+ # ensure the utility is built before the script below (which uses it) is run.
289+ (cd " ${tests_repo_dir} " && make github-labels)
290+
291+ tmp=$( mktemp)
292+
293+ info " Checking labels for repo ${repo} using temporary combined database ${tmp} "
294+
295+ bash -f " ${tests_repo_dir} /cmd/github-labels/github-labels.sh" " generate" " ${repo} " " ${tmp} "
296+
297+ # All tests passed so remove combined labels database
298+ rm -f " ${tmp} "
299+ }
300+
279301# Ensure all files (where possible) contain an SPDX license header
280302check_license_headers ()
281303{
@@ -618,6 +640,7 @@ main()
618640 --force) force=" true" ;;
619641 --golang) func=check_go ;;
620642 -h|--help) usage; exit 0 ;;
643+ --labels) func=check_labels;;
621644 --licenses) func=check_license_headers ;;
622645 --repo) repo=" $2 " ; shift ;;
623646 --vendor) func=check_vendor;;
@@ -671,6 +694,7 @@ main()
671694 check_docs
672695 check_files
673696 check_vendor
697+ check_labels
674698}
675699
676700main " $@ "
0 commit comments