From 873cb217900a6bad0f63ce83d3cdc21881fd9412 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 24 Jan 2025 15:05:34 -0800 Subject: [PATCH 1/7] Change the build-semconv-daily workflow --- .github/workflows/build-dev.yml | 9 --- .github/workflows/build-semconv-daily.yml | 26 -------- .../reusable-workflow-notification.yml | 59 ------------------- .../update-semconv-integration-branch.yml | 41 +++++++++++++ 4 files changed, 41 insertions(+), 94 deletions(-) delete mode 100644 .github/workflows/build-semconv-daily.yml delete mode 100644 .github/workflows/reusable-workflow-notification.yml create mode 100644 .github/workflows/update-semconv-integration-branch.yml diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index a082581dd56a..da819bb42103 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -7,14 +7,6 @@ on: description: Regex of submodule paths to update to HEAD before building. default: content-modules type: string - workflow_call: - inputs: - submodule_path_regex: - type: string - required: true - skip_ref_cache_check: - type: boolean - default: false jobs: build-and-test: @@ -60,7 +52,6 @@ jobs: name: REFCACHE updates? needs: build-and-test runs-on: ubuntu-latest - if: ${{ !inputs.skip_ref_cache_check }} steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 diff --git a/.github/workflows/build-semconv-daily.yml b/.github/workflows/build-semconv-daily.yml deleted file mode 100644 index 8778066a19a8..000000000000 --- a/.github/workflows/build-semconv-daily.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build Semantic Conventions (daily) - -on: - schedule: - # daily at 10:24 UTC - - cron: '24 10 * * *' - workflow_dispatch: - -jobs: - build-dev: - uses: ./.github/workflows/build-dev.yml - with: - submodule_path_regex: semantic-conventions - skip_ref_cache_check: true - - workflow-notification: - needs: - - build-dev - if: always() - uses: ./.github/workflows/reusable-workflow-notification.yml - with: - success: ${{ needs.build-dev.result == 'success' }} - repo: open-telemetry/semantic-conventions - secrets: - opentelemetrybot_github_token: - ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} diff --git a/.github/workflows/reusable-workflow-notification.yml b/.github/workflows/reusable-workflow-notification.yml deleted file mode 100644 index 49b3e38db485..000000000000 --- a/.github/workflows/reusable-workflow-notification.yml +++ /dev/null @@ -1,59 +0,0 @@ -# this is useful because notifications for scheduled workflows are only sent to the user who -# initially created the given workflow -name: Reusable - Workflow notification - -on: - workflow_call: - inputs: - success: - type: boolean - required: true - repo: - type: string - required: false - secrets: - opentelemetrybot_github_token: - required: false - -jobs: - workflow-notification: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Open issue or add comment if issue already open - env: - # need to use opentelemetrybot token when opening issues in other repos - GH_TOKEN: - ${{ secrets.opentelemetrybot_github_token || secrets.GITHUB_TOKEN }} - run: | - if [ -z "${{ inputs.repo }}" ]; then - repo="$GITHUB_REPOSITORY" - title="Workflow failed: $GITHUB_WORKFLOW" - body="See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." - else - repo="${{ inputs.repo }}" - title="Workflow failed: $GITHUB_REPOSITORY $GITHUB_WORKFLOW" - body="See [$GITHUB_REPOSITORY $GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." - fi - - # TODO (trask) search doesn't support exact phrases, so it's possible that this could grab the wrong issue - number=$(gh issue list --repo $repo --search "in:title $title" --limit 1 --json number -q .[].number) - - echo $number - echo ${{ inputs.success }} - - if [[ $number ]]; then - if [[ "${{ inputs.success }}" == "true" ]]; then - gh issue close $number \ - --repo $repo - else - gh issue comment $number \ - --repo $repo \ - --body "$body" - fi - elif [[ "${{ inputs.success }}" == "false" ]]; then - gh issue create --repo $repo \ - --title "$title (#$GITHUB_RUN_NUMBER)" \ - --body "$body" - fi diff --git a/.github/workflows/update-semconv-integration-branch.yml b/.github/workflows/update-semconv-integration-branch.yml new file mode 100644 index 000000000000..e36c4bda1493 --- /dev/null +++ b/.github/workflows/update-semconv-integration-branch.yml @@ -0,0 +1,41 @@ +name: Update semconv integration branch + +on: + schedule: + # daily at 10:24 UTC + - cron: '24 10 * * *' + workflow_dispatch: + +jobs: + update-semconv-integration-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: integration/semantic-conventions + # this is needed in order to do rebase below + fetch-depth: 0 + # this is needed in order to trigger workflows on the PR + token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + + - name: Use CLA approved github bot + run: | + git config user.name opentelemetrybot + git config user.email 107717825+opentelemetrybot@users.noreply.github.com + + - name: Rebase + run: | + previous=$(git rev-parse HEAD) + git fetch origin + git merge origin/main + if [ "$(git rev-parse HEAD)" != "$previous" ]; then + git push origin integration/semantic-conventions + fi + + - name: Update submodule + run: | + git submodule update --init --remote content-modules/semantic-conventions + if ! git diff-index --quiet HEAD; then + git commit -am "Update submodule" + git push origin integration/semantic-conventions + fi From 7aac29642dc45d876e2ac58faef4ee05e4675be9 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 27 Jan 2025 11:24:14 -0800 Subject: [PATCH 2/7] Only run in otel repo --- .github/workflows/update-semconv-integration-branch.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-semconv-integration-branch.yml b/.github/workflows/update-semconv-integration-branch.yml index e36c4bda1493..9f8ed3e2183e 100644 --- a/.github/workflows/update-semconv-integration-branch.yml +++ b/.github/workflows/update-semconv-integration-branch.yml @@ -9,6 +9,7 @@ on: jobs: update-semconv-integration-branch: runs-on: ubuntu-latest + if: github.repository == 'open-telemetry/opentelemetry.io' steps: - uses: actions/checkout@v4 with: From 5311aceeecacf9f868eec6d0abed87c1f6d21110 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 28 Jan 2025 19:15:02 -0800 Subject: [PATCH 3/7] update to versioned branch --- .../update-semconv-integration-branch.yml | 67 +++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-semconv-integration-branch.yml b/.github/workflows/update-semconv-integration-branch.yml index 9f8ed3e2183e..76edeca39078 100644 --- a/.github/workflows/update-semconv-integration-branch.yml +++ b/.github/workflows/update-semconv-integration-branch.yml @@ -13,12 +13,46 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: integration/semantic-conventions - # this is needed in order to do rebase below + # this is needed in order to do the rebase below fetch-depth: 0 - # this is needed in order to trigger workflows on the PR + # this is needed in order to trigger workflows when pushing new commits to the PR token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + - name: Set environment variables + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + version=$(git branch -r \ + | grep '^ *origin/opentelemetrybot/semantic-conventions-v[0-9]+\.[0-9]+\.[0-9]+$' \ + | sed 's/ *origin\/opentelemetrybot\/semantic-conventions-//') + + if [[ -z "$versions" ]]; then + latest_version=$(gh release view \ + --repo open-telemetry/semantic-conventions \ + --json tagName \ + --jq .tagName) + if [[ $latest_version =~ ^v([0-9]+)\.([0-9]+)\.[0-9]+ ]]; then + major="${BASH_REMATCH[1]}" + minor="${BASH_REMATCH[2]}" + version="v$major.$((minor + 1)).0" + else + echo "unexpected version: $latest_version" + exit 1 + fi + fi + + echo "VERSION=$version" >> $GITHUB_ENV + echo "BRANCH=opentelemetrybot/semantic-conventions-${version}" >> $GITHUB_ENV + + - name: Checkout or create branch + run: | + if ! git ls-remote --exit-code --heads origin $BRANCH; then + git checkout -b $BRANCH origin/main + git push -u origin $BRANCH + else + git checkout $BRANCH + fi + - name: Use CLA approved github bot run: | git config user.name opentelemetrybot @@ -30,13 +64,34 @@ jobs: git fetch origin git merge origin/main if [ "$(git rev-parse HEAD)" != "$previous" ]; then - git push origin integration/semantic-conventions + git push fi - name: Update submodule run: | - git submodule update --init --remote content-modules/semantic-conventions + git submodule update --init content-modules/semantic-conventions + cd content-modules/semantic-conventions + + if git ls-remote --exit-code --tags origin $VERSION; then + git reset --hard $VERSION + else + git reset --hard origin/main + fi + + cd ../.. + if ! git diff-index --quiet HEAD; then git commit -am "Update submodule" - git push origin integration/semantic-conventions + git push + fi + + - name: Create pull request if needed + env: + # not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows + GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + run: | + prs=$(gh pr list --state open --head $BRANCH) + if [ -z "$prs" ]; then + gh pr create --title "Update semantic conventions to ${VERSION}" \ + --body "This PR updates the semantic conventions to ${VERSION}." fi From 7ec8c9a6538118478b65da1f0a28b660de61b91e Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 28 Jan 2025 19:51:16 -0800 Subject: [PATCH 4/7] draft --- .github/workflows/update-semconv-integration-branch.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-semconv-integration-branch.yml b/.github/workflows/update-semconv-integration-branch.yml index 76edeca39078..3316f3a2704e 100644 --- a/.github/workflows/update-semconv-integration-branch.yml +++ b/.github/workflows/update-semconv-integration-branch.yml @@ -93,5 +93,6 @@ jobs: prs=$(gh pr list --state open --head $BRANCH) if [ -z "$prs" ]; then gh pr create --title "Update semantic conventions to ${VERSION}" \ - --body "This PR updates the semantic conventions to ${VERSION}." + --body "This PR updates the semantic conventions to ${VERSION}." \ + --draft fi From 121a81d7cc7937937f47c216e2b110f8c2ecb6ed Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 29 Jan 2025 16:06:38 -0800 Subject: [PATCH 5/7] feedback --- .../update-semconv-integration-branch.yml | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update-semconv-integration-branch.yml b/.github/workflows/update-semconv-integration-branch.yml index 3316f3a2704e..12f678896a22 100644 --- a/.github/workflows/update-semconv-integration-branch.yml +++ b/.github/workflows/update-semconv-integration-branch.yml @@ -22,16 +22,19 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + branch_prefix="opentelemetrybot/semconv-integration-" + version=$(git branch -r \ - | grep '^ *origin/opentelemetrybot/semantic-conventions-v[0-9]+\.[0-9]+\.[0-9]+$' \ - | sed 's/ *origin\/opentelemetrybot\/semantic-conventions-//') + | grep "^ *origin/$branch_prefix-v[0-9]+\.[0-9]+\..*-dev" \ + | sed "s|^ *origin/$branch_prefix-||" + | sed "s|-dev$||") if [[ -z "$versions" ]]; then latest_version=$(gh release view \ --repo open-telemetry/semantic-conventions \ --json tagName \ --jq .tagName) - if [[ $latest_version =~ ^v([0-9]+)\.([0-9]+)\.[0-9]+ ]]; then + if [[ $latest_version =~ ^v([0-9]+)\.([0-9]+)\. ]]; then major="${BASH_REMATCH[1]}" minor="${BASH_REMATCH[2]}" version="v$major.$((minor + 1)).0" @@ -42,7 +45,7 @@ jobs: fi echo "VERSION=$version" >> $GITHUB_ENV - echo "BRANCH=opentelemetrybot/semantic-conventions-${version}" >> $GITHUB_ENV + echo "BRANCH=$branch_prefix-${version}-dev" >> $GITHUB_ENV - name: Checkout or create branch run: | @@ -58,7 +61,7 @@ jobs: git config user.name opentelemetrybot git config user.email 107717825+opentelemetrybot@users.noreply.github.com - - name: Rebase + - name: Merge from main run: | previous=$(git rev-parse HEAD) git fetch origin @@ -78,10 +81,12 @@ jobs: git reset --hard origin/main fi + commit_desc=$(git describe --tags) + cd ../.. if ! git diff-index --quiet HEAD; then - git commit -am "Update submodule" + git commit -am "Update semconv submodule to $commit_desc" git push fi @@ -92,7 +97,7 @@ jobs: run: | prs=$(gh pr list --state open --head $BRANCH) if [ -z "$prs" ]; then - gh pr create --title "Update semantic conventions to ${VERSION}" \ - --body "This PR updates the semantic conventions to ${VERSION}." \ + gh pr create --title "Update semantic conventions to ${VERSION}-dev" \ + --body "This PR updates the semantic conventions to ${VERSION}-dev." \ --draft fi From ecce0a14848287aaa63a850366efd99f2375a9cd Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 29 Jan 2025 16:50:27 -0800 Subject: [PATCH 6/7] Update semconv-pin --- .github/workflows/update-semconv-integration-branch.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-semconv-integration-branch.yml b/.github/workflows/update-semconv-integration-branch.yml index 12f678896a22..a3d5b6da3537 100644 --- a/.github/workflows/update-semconv-integration-branch.yml +++ b/.github/workflows/update-semconv-integration-branch.yml @@ -45,7 +45,7 @@ jobs: fi echo "VERSION=$version" >> $GITHUB_ENV - echo "BRANCH=$branch_prefix-${version}-dev" >> $GITHUB_ENV + echo "BRANCH=$branch_prefix-$version-dev" >> $GITHUB_ENV - name: Checkout or create branch run: | @@ -85,6 +85,8 @@ jobs: cd ../.. + sed -i "s/^\tsemconv-pin = .*/\tsemconv-pin = $commit_desc/" .gitmodules + if ! git diff-index --quiet HEAD; then git commit -am "Update semconv submodule to $commit_desc" git push @@ -97,7 +99,7 @@ jobs: run: | prs=$(gh pr list --state open --head $BRANCH) if [ -z "$prs" ]; then - gh pr create --title "Update semantic conventions to ${VERSION}-dev" \ - --body "This PR updates the semantic conventions to ${VERSION}-dev." \ + gh pr create --title "Update semantic conventions to $VERSION-dev" \ + --body "This PR updates the semantic conventions to $VERSION-dev." \ --draft fi From 7aa469ac9bde14e836f2872f6e723951b5d67a5a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 29 Jan 2025 18:21:06 -0800 Subject: [PATCH 7/7] fix --- .github/workflows/update-semconv-integration-branch.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-semconv-integration-branch.yml b/.github/workflows/update-semconv-integration-branch.yml index a3d5b6da3537..6bda4e2cd865 100644 --- a/.github/workflows/update-semconv-integration-branch.yml +++ b/.github/workflows/update-semconv-integration-branch.yml @@ -22,11 +22,11 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - branch_prefix="opentelemetrybot/semconv-integration-" + branch_prefix="opentelemetrybot/semconv-integration" version=$(git branch -r \ | grep "^ *origin/$branch_prefix-v[0-9]+\.[0-9]+\..*-dev" \ - | sed "s|^ *origin/$branch_prefix-||" + | sed "s|^ *origin/$branch_prefix-||" \ | sed "s|-dev$||") if [[ -z "$versions" ]]; then @@ -82,7 +82,6 @@ jobs: fi commit_desc=$(git describe --tags) - cd ../.. sed -i "s/^\tsemconv-pin = .*/\tsemconv-pin = $commit_desc/" .gitmodules