Skip to content

Commit

Permalink
update issue template and label generation to resolve registry
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Aug 31, 2024
1 parent 49b5f02 commit 1cf7120
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 24 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/generate-registry-area-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on:
push:
branches: [main]
paths:
- model/registry/**
- model/**
- ./.github/workflows/generate-registry-area-labels.yml
- ./.github/workflows/scripts/generate-registry-area-labels.sh
- ./internal/tools/scripts/generate-registry-area-labels.sh
workflow_dispatch:

jobs:
Expand All @@ -14,11 +14,7 @@ jobs:
if: ${{ github.repository_owner == 'open-telemetry' }}
steps:
- uses: actions/checkout@v4

- name: Run update permissions
run: chmod +x ./.github/workflows/scripts/generate-registry-area-labels.sh

- name: Generate registry area labels
run: ./.github/workflows/scripts/generate-registry-area-labels.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make generate-registry-area-labels

Check failure on line 20 in .github/workflows/generate-registry-area-labels.yml

View workflow job for this annotation

GitHub Actions / yamllint

[empty-lines] too many blank lines (1 > 0)
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,22 @@ generate-gh-issue-templates:
/home/weaver/target/
$(TOOLS_DIR)/scripts/update-issue-template-areas.sh $(PWD)/internal/tools/bin/areas.txt

# Updates github labels for areas based on the root namespaces in the resolved registry
.PHONY: generate-registry-area-labels
update-registry-area-labels:
docker run --rm \
-u $(id -u ${USER}):$(id -g ${USER}) \
--mount 'type=bind,source=$(PWD)/internal/tools/scripts,target=/home/weaver/templates,readonly' \
--mount 'type=bind,source=$(PWD)/model,target=/home/weaver/source,readonly' \
--mount 'type=bind,source=$(PWD)/internal/tools/bin,target=/home/weaver/target' \
$(WEAVER_CONTAINER) registry generate \
--registry=/home/weaver/source \
--templates=/home/weaver/templates \
--config=/home/weaver/templates/registry/areas-weaver.yaml \
. \
/home/weaver/target/
$(TOOLS_DIR)/scripts/generate-registry-area-labels.sh $(PWD)/internal/tools/bin/areas.txt

# A previous iteration of calculating "LATEST_RELEASED_SEMCONV_VERSION"
# relied on "git describe". However, that approach does not work with
# light-weight developer forks/branches that haven't synced tags. Hence the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@
set -euo pipefail

CUR_DIRECTORY=$(dirname "$0")
AREAS=$(sh "${CUR_DIRECTORY}/get-registry-areas.sh")
AREAS=$1

echo -e "\nStarting to create area labels"
echo -e "--------------------------------\n"

for AREA in ${AREAS}; do
LABEL_NAME=$(basename "${AREA}" .yaml)

if (( "${#LABEL_NAME}" > 50 )); then
echo "'${LABEL_NAME}' exceeds GitHubs 50-character limit on labels, skipping"
while IFS= read -r label; do
if (( "${#label}" > 50 )); then
echo -e "Label $label exceeds GitHubs 50-character limit on labels, skipping"
continue
fi
echo "area:${LABEL_NAME}"
gh label create "area:${LABEL_NAME}" -c "#425cc7" --force
done
echo "$label"
gh label create "$label" -c "#425cc7" --force
done < ${AREAS}

echo -e "\nLabels created successfully"
echo -e "--------------------------------\n"
Expand Down
13 changes: 13 additions & 0 deletions internal/tools/scripts/registry/areas-weaver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
templates:
- pattern: areas.md.j2
filter: >
semconv_grouped_attributes({"exclude_deprecated": true}) | .[].root_namespace
application_mode: single
whitespace_control:
trim_blocks: true
lstrip_blocks: true
keep_trailing_newline: true
text_maps:
areas:
az: azure
hw: hardware
5 changes: 5 additions & 0 deletions internal/tools/scripts/registry/areas.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- template.set_file_name("areas.txt") -}}

{% for item in ctx | map('map_text', 'areas') | sort %}
area:{{ item | kebab_case }}
{% endfor %}
7 changes: 1 addition & 6 deletions internal/tools/scripts/update-issue-template-areas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@ END_AREA_LIST="# End semconv area list"
replacement=" ${START_AREA_LIST}"

while IFS= read -r line; do
replacement="${replacement}\n$line"
replacement="${replacement}\n - $line"
done < ${AREAS}

for AREA in ${AREAS}; do
LABEL_NAME=$(basename "${AREA}" .yaml)

done

echo -e "\nStarting to replace areas in ISSUE_TEMPLATES:"
echo -e "---------------------------------------------\n"

Expand Down

0 comments on commit 1cf7120

Please sign in to comment.