Skip to content

Commit 016ea1f

Browse files
committed
Add workflow checks for semconv
1 parent bc94569 commit 016ea1f

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Semantic Conventions - validate
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "src/OpenTelemetry.SemanticConventions/**"
7+
8+
jobs:
9+
run-dotnet-format:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: check out code
14+
uses: actions/checkout@v4
15+
16+
- name: Check script versions
17+
shell: pwsh
18+
run: .\build\scripts\check-semconv-versions.ps1
19+
20+
- name: Generate semantic conventions
21+
working-directory: src\OpenTelemetry.SemanticConventions
22+
shell: pwsh
23+
run: |
24+
.\scripts\generate.ps1
25+
26+
- name: Verify no changes
27+
working-directory: src\OpenTelemetry.SemanticConventions
28+
run: |
29+
git diff --exit-code '.' || (echo 'Manual changes to Semantic Convention attributes are not allowed. Please re-generate the files and commit.' && exit 1)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
$rootDirectory = Get-Location
3+
4+
$PowerShellScript = "$($rootDirectory)\src\OpenTelemetry.SemanticConventions\scripts\generate.ps1"
5+
$BashScript = "$($rootDirectory)\src\OpenTelemetry.SemanticConventions\scripts\generate.sh"
6+
7+
# PS semconv version
8+
$PsSemConvVersion = Select-String -Path $PowerShellScript -Pattern '\$SEMCONV_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }
9+
# PS weaver version
10+
$PsWeaverVersion = Select-String -Path $PowerShellScript -Pattern '\$GENERATOR_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }
11+
12+
# Bash semconv version
13+
$BashSemConvVersion = Select-String -Path $BashScript -Pattern 'SEMCONV_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }
14+
# Bash weaver version
15+
$BashWeaverVersion = Select-String -Path $BashScript -Pattern 'SEMCONV_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }
16+
17+
# Check if the semconv versions match
18+
if ($PsSemConvVersion -ne $BashSemConvVersion) {
19+
Write-Host "Semantic Convention version mismatch detected!"
20+
Write-Host "PowerShell version: $PsSemConvVersion"
21+
Write-Host "Bash version: $BashSemConvVersion"
22+
exit 1
23+
}
24+
25+
# Check if the weaver versions match
26+
if ($PsWeaverVersion -ne $BashWeaverVersion) {
27+
Write-Host "Weaver version mismatch detected!"
28+
Write-Host "PowerShell version: $PsWeaverVersion"
29+
Write-Host "Bash version: $BashWeaverVersion"
30+
exit 1
31+
}

src/OpenTelemetry.SemanticConventions/scripts/generate.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ $SCRIPT_DIR = $PSScriptRoot
22
$ROOT_DIR = "${SCRIPT_DIR}/../"
33

44
# freeze the spec version to make SemanticAttributes generation reproducible
5-
$SEMCONV_VERSION = "1.26.0"
6-
$GENERATOR_VERSION = "v0.9.2"
5+
$SEMCONV_VERSION="1.26.0"
6+
$GENERATOR_VERSION="v0.9.2"
77

88
Set-Location $SCRIPT_DIR
99

src/OpenTelemetry.SemanticConventions/scripts/generate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
ROOT_DIR="${SCRIPT_DIR}/../"
66

77
# freeze the spec version to make SemanticAttributes generation reproducible
8-
SEMCONV_VERSION=1.26.0
9-
GENERATOR_VERSION=v0.9.2
8+
SEMCONV_VERSION="1.26.0"
9+
GENERATOR_VERSION="v0.9.2"
1010

1111
cd ${SCRIPT_DIR}
1212

0 commit comments

Comments
 (0)