Chore: Upgrade Jenkins-job-builder to 6.2.0
[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-template:' \
20         -e '\- parameter:' \
21         -e '\- property:' \
22         -e '\- publisher:' \
23         -e '\- scm:' \
24         -e '\- trigger:' \
25         -e '\- wrapper:' \
26         -A1 "$file" \
27         | grep 'name: ' | awk -F': ' '{print $2}' | sort | uniq \
28         | tr -d "'" | tr -d '"')
29
30     for item in "${docs_interests[@]}"; do
31         if ! grep -q "$item" "docs/${file//.yaml/.rst}"; then
32             echo "$file:$item"
33             undocumented_count=$((undocumented_count+1))
34         fi
35     done
36 done
37
38 if [ "$undocumented_count" -gt 0 ]; then
39     echo "Number of undocumented items: $undocumented_count"
40     exit 1
41 fi