Skip to content

Commit

Permalink
Add workflow checks for semconv
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopgrassi committed Sep 12, 2024
1 parent bc94569 commit 016ea1f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/semconv-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Semantic Conventions - validate

on:
pull_request:
paths:
- "src/OpenTelemetry.SemanticConventions/**"

jobs:
run-dotnet-format:
runs-on: ubuntu-latest

steps:
- name: check out code

Check failure on line 13 in .github/workflows/semconv-validation.yml

View workflow job for this annotation

GitHub Actions / lint-yml / run-yamllint

13:5 [indentation] wrong indentation: expected 6 but found 4
uses: actions/checkout@v4

- name: Check script versions
shell: pwsh
run: .\build\scripts\check-semconv-versions.ps1

- name: Generate semantic conventions
working-directory: src\OpenTelemetry.SemanticConventions
shell: pwsh
run: |
.\scripts\generate.ps1
- name: Verify no changes
working-directory: src\OpenTelemetry.SemanticConventions
run: |
git diff --exit-code '.' || (echo 'Manual changes to Semantic Convention attributes are not allowed. Please re-generate the files and commit.' && exit 1)
31 changes: 31 additions & 0 deletions build/scripts/check-semconv-versions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

$rootDirectory = Get-Location

$PowerShellScript = "$($rootDirectory)\src\OpenTelemetry.SemanticConventions\scripts\generate.ps1"
$BashScript = "$($rootDirectory)\src\OpenTelemetry.SemanticConventions\scripts\generate.sh"

# PS semconv version
$PsSemConvVersion = Select-String -Path $PowerShellScript -Pattern '\$SEMCONV_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }
# PS weaver version
$PsWeaverVersion = Select-String -Path $PowerShellScript -Pattern '\$GENERATOR_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }

# Bash semconv version
$BashSemConvVersion = Select-String -Path $BashScript -Pattern 'SEMCONV_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }
# Bash weaver version
$BashWeaverVersion = Select-String -Path $BashScript -Pattern 'SEMCONV_VERSION="([^"]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }

# Check if the semconv versions match
if ($PsSemConvVersion -ne $BashSemConvVersion) {
Write-Host "Semantic Convention version mismatch detected!"
Write-Host "PowerShell version: $PsSemConvVersion"
Write-Host "Bash version: $BashSemConvVersion"
exit 1
}

# Check if the weaver versions match
if ($PsWeaverVersion -ne $BashWeaverVersion) {
Write-Host "Weaver version mismatch detected!"
Write-Host "PowerShell version: $PsWeaverVersion"
Write-Host "Bash version: $BashWeaverVersion"
exit 1
}
4 changes: 2 additions & 2 deletions src/OpenTelemetry.SemanticConventions/scripts/generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ $SCRIPT_DIR = $PSScriptRoot
$ROOT_DIR = "${SCRIPT_DIR}/../"

# freeze the spec version to make SemanticAttributes generation reproducible
$SEMCONV_VERSION = "1.26.0"
$GENERATOR_VERSION = "v0.9.2"
$SEMCONV_VERSION="1.26.0"
$GENERATOR_VERSION="v0.9.2"

Set-Location $SCRIPT_DIR

Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.SemanticConventions/scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="${SCRIPT_DIR}/../"

# freeze the spec version to make SemanticAttributes generation reproducible
SEMCONV_VERSION=1.26.0
GENERATOR_VERSION=v0.9.2
SEMCONV_VERSION="1.26.0"
GENERATOR_VERSION="v0.9.2"

cd ${SCRIPT_DIR}

Expand Down

0 comments on commit 016ea1f

Please sign in to comment.