Make sure that jjb-cleanup.sh allows unbound vars
[releng/global-jjb.git] / ensure-documented.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 # Checks for JJB documentation interest points and ensures they are documented.
13
14 mapfile -t jjb_files < <(find jjb -name "*.yaml")
15
16 undocumented_count=0
17 for file in "${jjb_files[@]}"; do
18     mapfile -t docs_interests < <(grep -e '\- builder:' \
19          -e '\- job-group:' \
20          -e '\- job-template:' \
21          -e '\- parameter:' \
22          -e '\- property:' \
23          -e '\- publisher:' \
24          -e '\- scm:' \
25          -e '\- trigger:' \
26          -e '\- wrapper:' \
27          -A1 "$file" \
28          | grep 'name: ' | awk -F': ' '{print $2}' | sort | uniq \
29          | tr -d "'")
30
31     for item in "${docs_interests[@]}"; do
32         if ! grep -q "$item" "docs/${file//.yaml/.rst}"; then
33             echo "$file:$item"
34             let "undocumented_count++"
35         fi
36     done
37 done
38
39 if [ $undocumented_count -gt 0 ]; then
40     echo "Number of undocumented items: $undocumented_count"
41     exit 1
42 fi