Skip to content

Commit 2abb69d

Browse files
authored
[CI] Fix 404 due to redirects, and more (open-telemetry#6059)
1 parent 7c9dfa1 commit 2abb69d

File tree

3 files changed

+71
-39
lines changed

3 files changed

+71
-39
lines changed

content/en/docs/collector/_index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Collector
33
description: Vendor-agnostic way to receive, process and export telemetry data.
4-
aliases: [collector/about]
4+
aliases: [./about]
55
cascade:
66
vers: 0.118.0
77
weight: 270

layouts/partials/redirects/aliases.txt

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
{{/* cSpell:ignore cond */ -}}
33

44
{{ $p := . -}}
5-
{{ range $p.Aliases -}}
6-
{{/* Temporary workaround for semconv alias errors */ -}}
7-
{{ if strings.HasPrefix . "docs/specs/semconv/general" -}}
8-
{{ . | printf "%-35s" }} {{ $p.RelPermalink }}
9-
{{ else -}}
10-
{{ $alias := cond (strings.HasPrefix . "/")
11-
.
12-
(partial "relative-redirects-alias" (dict "alias" . "p" $p.Parent)) -}}
13-
{{ $alias | printf "%-35s" }} {{ $p.RelPermalink }}
5+
{{ range $alias := $p.Aliases -}}
6+
{{ if not (strings.HasPrefix $alias "/") -}}
7+
{{ $alias = partial "relative-redirects-alias"
8+
(dict
9+
"alias" $alias
10+
"p" (cond (strings.HasPrefix $alias "./") $p $p.Parent)
11+
) -}}
1412
{{ end -}}
13+
{{ $alias | printf "%-35s" }} {{ $p.RelPermalink }}
1514
{{ end -}}
1615

1716
{{- define "partials/relative-redirects-alias" -}}

scripts/content-modules/adjust-pages.pl

+62-29
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,24 @@
1717
my $semconvSpecRepoUrl = 'https://github.com/open-telemetry/semantic-conventions';
1818
my $semConvRef = "$otelSpecRepoUrl/blob/main/semantic_conventions/README.md";
1919
my $specBasePath = '/docs/specs';
20-
my %versions = qw(
21-
spec: 1.41.0
22-
otlp: 1.5.0
23-
semconv: 1.29.0
24-
);
25-
my %versFromRepo = %versions; # Use declared versions a defaults
26-
my $otelSpecVers = $versions{'spec:'};
27-
my $otlpSpecVers = $versions{'otlp:'};
28-
my $semconvVers = $versions{'semconv:'};
2920
my %patchMsgCount;
3021
my $lineNum;
3122

23+
my %versionsRaw = # Keyname must end with colons because the auto-version update script expects one
24+
qw(
25+
spec: 1.41.0
26+
otlp: 1.5.0
27+
semconv: 1.29.0
28+
);
29+
# Versions map without the colon in the keys
30+
my %versions = map { s/://r => $versionsRaw{$_} } keys %versionsRaw;
31+
# Shorthands
32+
my $otelSpecVers = $versions{'spec'};
33+
my $otlpSpecVers = $versions{'otlp'};
34+
my $semconvVers = $versions{'semconv'};
35+
36+
my %versFromSubmod = %versions; # Actual version of submodules. Updated by getVersFromSubmodule().
37+
3238
sub printTitleAndFrontMatter() {
3339
print "---\n";
3440
if ($title eq 'OpenTelemetry Specification') {
@@ -70,20 +76,20 @@ ()
7076
sub applyPatchOrPrintMsgIf($$$) {
7177
# Returns truthy if patch should be applied, otherwise prints message (once) as to why not.
7278

73-
my ($patchID, $versKey_, $targetVers) = @_;
74-
my $versKey = $versKey_ . ':';
79+
my ($patchID, $specName, $targetVers) = @_;
7580
my $vers;
81+
my $key = $specName . $patchID;
7682

77-
return 0 if $patchMsgCount{$patchID};
83+
return 0 if $patchMsgCount{$key};
7884

79-
if (($vers = $versions{$versKey}) ne $targetVers) {
80-
print STDOUT "INFO: remove obsolete patch '$patchID' now that spec '$versKey_' is at v$vers, not v$targetVers - $0\n";
81-
} elsif (($vers = $versFromRepo{$versKey}) ne $targetVers) {
82-
print STDOUT "INFO [$patchID]: skipping patch '$patchID' since spec '$versKey_' submodule is at v$vers not v$targetVers - $0\n";
85+
if (($vers = $versions{$specName}) ne $targetVers) {
86+
print STDOUT "INFO: remove obsolete patch '$patchID' now that spec '$specName' is at v$vers, not v$targetVers - $0\n";
87+
} elsif (($vers = $versFromSubmod{$specName}) ne $targetVers) {
88+
print STDOUT "INFO [$patchID]: skipping patch '$patchID' since spec '$specName' submodule is at v$vers not v$targetVers - $0\n";
8389
} else {
8490
return 'Apply the patch';
8591
}
86-
$patchMsgCount{$patchID}++;
92+
$patchMsgCount{$key}++;
8793
return 0;
8894
}
8995

@@ -95,24 +101,49 @@ ()
95101
s|$semconv_attr_naming|$1/attribute-naming/|g if /$semconv_attr_naming/;
96102
}
97103

98-
sub getVersFromRepo() {
99-
my $vers = qx(
100-
cd content-modules/semantic-conventions;
101-
git describe --tags 2>&1;
104+
sub patchEventAliases() {
105+
return unless $ARGV =~ /^tmp\/otel\/specification\/logs\//
106+
&& applyPatchOrPrintMsgIf('2025-01-23-event-aliases', 'spec', '1.41.0');
107+
108+
my $aliases = '^( - )(event-(api|sdk))$';
109+
s|$aliases|$1./$2|g if /$aliases/;
110+
}
111+
112+
sub patchSemConvAlias() {
113+
return unless $ARGV =~ /^tmp\/semconv\/docs\/general\//
114+
&& applyPatchOrPrintMsgIf('2025-01-23-general-aliases', 'semconv', '1.29.0');
115+
116+
my $aliases = '\[docs/specs/semconv/general/(trace-general)\]';
117+
s|$aliases|[$1]|g if /$aliases/;
118+
}
119+
120+
sub getVersFromSubmodule() {
121+
my %repoNames = qw(
122+
otlp opentelemetry-proto
123+
semconv semantic-conventions
124+
spec opentelemetry-specification
102125
);
103-
chomp($vers);
104126

105-
if ($?) {
106-
warn "WARNING: semconv repo: call to 'git describe' failed: '$vers'";
107-
} else {
108-
$vers =~ s/v//;
109-
$versFromRepo{'semconv:'} = $vers;
127+
foreach my $spec (keys %repoNames) {
128+
my $directory = $repoNames{$spec};
129+
my $vers = qx(
130+
cd content-modules/$directory;
131+
git describe --tags 2>&1;
132+
);
133+
chomp($vers);
134+
135+
if ($?) {
136+
warn "WARNING: submodule '$spec': call to 'git describe' failed: '$vers'";
137+
} else {
138+
$vers =~ s/v//;
139+
$versFromSubmod{$spec} = $vers;
140+
}
110141
}
111142
}
112143

113144
# main
114145

115-
getVersFromRepo();
146+
getVersFromSubmodule();
116147

117148
while(<>) {
118149
$lineNum++;
@@ -127,7 +158,9 @@ ()
127158
while(<>) {
128159
$lineNum++;
129160
last if /^-?-->/;
130-
patchAttrNaming(); # TEMPORARY patch
161+
patchAttrNaming();
162+
patchEventAliases();
163+
patchSemConvAlias();
131164
$frontMatterFromFile .= $_;
132165
}
133166
next;

0 commit comments

Comments
 (0)