Skip to content

Commit de863b3

Browse files
authored
[CI] update-semconv-mounts.pl: warn if semconv submod not init (#8307)
1 parent d1b4d6a commit de863b3

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

scripts/update-semconv-mounts.pl

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#!/usr/bin/perl -w
22
#
3-
# Script to generate module.yaml from module-template.yaml
4-
# by adding autogenerated semconv mount entries.
3+
# Script to generate module.yaml from module-template.yaml by adding
4+
# autogenerated semconv mount entries. The entries are generated from the list
5+
# of README.md files in the semconv submodule.
56
#
6-
# Reads from: $MODULE_CONFIG_TEMPLATE (version-controlled template)
7-
# Writes to: $MODULE_CONFIG_YAML (generated, gitignored)
7+
# Note that this script might be called in situations where some but not all
8+
# content-modules have been initialized. If the semconv submodule is not
9+
# git-submodule initialized, the script will warn and exit.
10+
#
11+
# Reads from: $MODULE_CONFIG_TEMPLATE (version-controlled template) Writes to:
12+
# $MODULE_CONFIG_YAML (generated, gitignored)
813

914
use strict;
1015
use warnings;
@@ -25,6 +30,27 @@ ($)
2530
my $END_MARKER = markerFor("above");
2631

2732
sub main() {
33+
if (! -e $SEMCONV_DIR) {
34+
# The directory should be present even if the submodule isn't initialized.
35+
print STDERR "ERROR: submodule directory not found: $SEMCONV_DIR\n";
36+
exit 1;
37+
}
38+
39+
if (! -e "$SEMCONV_DIR/.git") {
40+
print STDERR
41+
"WARNING: submodule not initialized, '.git' directory not found in $SEMCONV_DIR\n" .
42+
" Skipping semconv mount config generation.\n" .
43+
" Run 'npm run get:submodule' to initialize.\n";
44+
exit 0;
45+
} else {
46+
print STDERR "Submodule found and initialized: $SEMCONV_DIR\n";
47+
}
48+
49+
if (! -e $SEMCONV_DOCS_DIR) {
50+
print STDERR "ERROR: directory '$SEMCONV_DOCS_DIR' expected but not found.\n";
51+
exit 1;
52+
}
53+
2854
# Find all README.md by running system `find`. Must be in
2955
# $SEMCONV_DIR for find to generate the correct relative paths
3056
my $readme_files = `cd $SEMCONV_DIR && find docs -name "README.md" | sort`;

0 commit comments

Comments
 (0)