3
3
pull_request :
4
4
# paths:
5
5
# - "**/*.properties"
6
+ # - "scripts/api/data/metadatablocks/*"
6
7
jobs :
7
8
duplicate_keys :
8
9
name : Duplicate Keys
32
33
if [ "$FAIL" -eq 1 ]; then
33
34
exit 1
34
35
fi
36
+
37
+ metadata_blocks_properties :
38
+ name : Metadata Blocks Properties
39
+ runs-on : ubuntu-latest
40
+ steps :
41
+ - uses : actions/checkout@v3
42
+ - name : Run metadata block properties verification script
43
+ shell : bash
44
+ run : |
45
+ for MDB in $(find scripts/api/data/metadatablocks -name '*.tsv'); do
46
+ BLOCK_NAME=$(sed -n "2p" "$MDB" | cut -f2)
47
+ BLOCK_DISPLAYNAME=$(sed -n "2p" "$MDB" | cut -f4)
48
+ PROPERTIES_FILE="src/main/java/propertyFiles/$BLOCK_NAME.properties"
49
+
50
+ # Check correct file exists
51
+ if [ ! -r "$PROPERTIES_FILE" ]; then
52
+ echo "::error::Missing properties file for metadata block '$BLOCK_NAME', expected at '$PROPERTIES_FILE'"
53
+ continue
54
+ fi
55
+
56
+ # Check metadata block properties exist and are equal to TSV source
57
+ if ! grep -a -q -e "^metadatablock.name=$BLOCK_NAME$" "$PROPERTIES_FILE"; then
58
+ echo "::error::Missing 'metadatablock.name=$BLOCK_NAME' or different from TSV source"
59
+ fi
60
+ if ! grep -a -q -e "^metadatablock.displayName=$BLOCK_DISPLAYNAME$" "$PROPERTIES_FILE"; then
61
+ echo "::error::Missing 'metadatablock.displayName=$BLOCK_DISPLAYNAME' or different from TSV source"
62
+ fi
63
+ if ! grep -a -q -e "^metadatablock.displayFacet=" "$PROPERTIES_FILE"; then
64
+ echo "::error::Missing 'metadatablock.displayFacet=...'"
65
+ fi
66
+
67
+ # Check dataset fields
68
+ for FIELD in $(grep -a -A1000 "^#datasetField" "$MDB" | tail -n+2 | grep -a -B1000 "^#controlledVocabulary" | head -n-1 | cut -f2); do
69
+ for ENTRY in title description watermark; do
70
+ if ! grep -a -q -e "^datasetfieldtype.$FIELD.$ENTRY=" "$PROPERTIES_FILE"; then
71
+ echo "::error::Missing key 'datasetfieldtype.$FIELD.$ENTRY=...'"
72
+ fi
73
+ done
74
+ done
75
+
76
+ # Check CV entries
77
+ grep -a -A1000 "^#controlledVocabulary" "$MDB" | tail -n+2 |
78
+ {
79
+ while read LINE; do
80
+ FIELD_NAME=$(echo "$LINE" | cut -f1)
81
+ # TODO: needs to replace UTF-8 chars with nearest ascii here!
82
+ FIELD_VALUE=$(echo "$LINE" | cut -f2 | tr '[:upper:]' '[:lower:]' | tr " " "_")
83
+ if ! grep -q -a -e "^controlledvocabulary.$FIELD_NAME.$FIELD_VALUE=" "$PROPERTIES_FILE"; then
84
+ echo "::error::Missing key 'controlledvocabulary.$FIELD_NAME.$FIELD_VALUE=...'"
85
+ fi
86
+ done
87
+ };
88
+ done
0 commit comments