diff --git a/.github/workflows/generate-registry-area-labels.yml b/.github/workflows/generate-registry-area-labels.yml index 58f3b62b3a..a3b9f9ce6b 100644 --- a/.github/workflows/generate-registry-area-labels.yml +++ b/.github/workflows/generate-registry-area-labels.yml @@ -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: @@ -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 + diff --git a/Makefile b/Makefile index cc5b935464..18a5024897 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/.github/workflows/scripts/generate-registry-area-labels.sh b/internal/tools/scripts/generate-registry-area-labels.sh old mode 100755 new mode 100644 similarity index 64% rename from .github/workflows/scripts/generate-registry-area-labels.sh rename to internal/tools/scripts/generate-registry-area-labels.sh index 3a2af777e6..63621a04dd --- a/.github/workflows/scripts/generate-registry-area-labels.sh +++ b/internal/tools/scripts/generate-registry-area-labels.sh @@ -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" diff --git a/internal/tools/scripts/registry/areas-weaver.yaml b/internal/tools/scripts/registry/areas-weaver.yaml new file mode 100644 index 0000000000..074629a1cf --- /dev/null +++ b/internal/tools/scripts/registry/areas-weaver.yaml @@ -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 diff --git a/internal/tools/scripts/registry/areas.md.j2 b/internal/tools/scripts/registry/areas.md.j2 new file mode 100644 index 0000000000..f10bdea506 --- /dev/null +++ b/internal/tools/scripts/registry/areas.md.j2 @@ -0,0 +1,5 @@ +{{- template.set_file_name("areas.txt") -}} + +{% for item in ctx | map('map_text', 'areas') | sort %} +area:{{ item | kebab_case }} +{% endfor %} \ No newline at end of file diff --git a/internal/tools/scripts/update-issue-template-areas.sh b/internal/tools/scripts/update-issue-template-areas.sh index 80ce20aa3c..3b906dfc55 100755 --- a/internal/tools/scripts/update-issue-template-areas.sh +++ b/internal/tools/scripts/update-issue-template-areas.sh @@ -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"