From 98efc9d01514d0bc6e55a1ae623d2fa6a2a41ef7 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sat, 18 Jan 2025 13:58:39 -0800 Subject: [PATCH] Add daily semconv check --- .github/workflows/build-dev.yml | 5 ++ .github/workflows/build-semconv-daily.yml | 22 ++++++++ .../reusable-workflow-notification.yml | 55 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 .github/workflows/build-semconv-daily.yml create mode 100644 .github/workflows/reusable-workflow-notification.yml diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index da819bb42103..6437658a4f5c 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -7,6 +7,11 @@ 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 jobs: build-and-test: diff --git a/.github/workflows/build-semconv-daily.yml b/.github/workflows/build-semconv-daily.yml new file mode 100644 index 000000000000..f60f84106fe5 --- /dev/null +++ b/.github/workflows/build-semconv-daily.yml @@ -0,0 +1,22 @@ +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 + + 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 diff --git a/.github/workflows/reusable-workflow-notification.yml b/.github/workflows/reusable-workflow-notification.yml new file mode 100644 index 000000000000..479300da46bb --- /dev/null +++ b/.github/workflows/reusable-workflow-notification.yml @@ -0,0 +1,55 @@ +# 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 + +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 for opening issues in other repos + GH_TOKEN: ${{ inputs.repo && 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