-
Notifications
You must be signed in to change notification settings - Fork 253
Automate schema-next generation in release workflow #2307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Generate header and `{next_version}:` section in next schema yaml based on weaver | ||
# diff output. | ||
|
||
set -euo pipefail | ||
|
||
cur_version="$1" | ||
prev_version="$2" | ||
diff_file="$3" | ||
cur_version_schema_file="schemas/$cur_version" | ||
prev_version_schema_file="schemas/$prev_version" | ||
|
||
# Check if the previous version schema file exists | ||
if [[ ! -f "$prev_version_schema_file" ]]; then | ||
echo "Previous version schema file not found: $prev_version_schema_file" | ||
exit 1 | ||
fi | ||
|
||
# check if the current version schema file exists | ||
if [[ -f "$cur_version_schema_file" ]]; then | ||
echo "Current version schema file already exists: $cur_version_schema_file" | ||
exit 1 | ||
fi | ||
|
||
if ! grep -q "^versions:$" "$prev_version_schema_file"; then | ||
echo "String 'versions:' not found in the file $prev_version_schema_file." | ||
exit 1 | ||
fi | ||
|
||
prev_header_lines=$(awk '/^versions:/{print NR; exit}' "$prev_version_schema_file") | ||
|
||
# need to replace the next_version_placeholder in the header file due to https://github.com/open-telemetry/weaver/issues/775 | ||
# TODO: remove it after the issue is fixed | ||
{ | ||
sed "s/next_version_placeholder/$cur_version/g" "$diff_file" | ||
tail -n +"$((prev_header_lines + 1))" "$prev_version_schema_file" | ||
} > "$cur_version_schema_file" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- template.set_file_name("schema-diff.yaml") }} | ||
|
||
file_format: 1.1.0 | ||
schema_url: https://opentelemetry.io/schemas/{{ctx.next_version}} | ||
versions: | ||
{{ctx.next_version}}: | ||
{% if ctx.renames.registry_attributes | length > 0 %} | ||
all: | ||
changes: | ||
- rename_attributes: | ||
attribute_map: | ||
{% for attr in ctx.renames.registry_attributes %} | ||
{{attr.old_name}}: {{attr.new_name}} | ||
{% endfor %} | ||
{% endif %} | ||
{% if ctx.renames.metrics | length > 0 %} | ||
metrics: | ||
changes: | ||
- rename_metrics: | ||
{% for metric in ctx.renames.metrics %} | ||
{{metric.old_name}}: {{metric.new_name}} | ||
{% endfor %} | ||
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
params: | ||
next_version: "next_version_placeholder" # https://github.com/open-telemetry/weaver/issues/775 | ||
templates: | ||
- pattern: schema-diff.j2 | ||
filter: > | ||
. | ||
| { | ||
renames: .changes | with_entries(.value |= (map(select(.type == "renamed")) | sort_by(.old_name))), | ||
next_version: $next_version, | ||
latest_released_version: .baseline.semconv_version, | ||
} | ||
application_mode: single | ||
whitespace_control: | ||
trim_blocks: true | ||
lstrip_blocks: true | ||
keep_trailing_newline: true |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.