From 4b701b754714f405659961fe58ef5e532c879412 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 11:32:20 +0100 Subject: [PATCH 1/8] Create survey-on-merged-pr.yml --- .github/workflows/survey-on-merged-pr.yml | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/survey-on-merged-pr.yml diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml new file mode 100644 index 000000000000..96fac4709b90 --- /dev/null +++ b/.github/workflows/survey-on-merged-pr.yml @@ -0,0 +1,42 @@ +name: Test Org Membership + +on: + workflow_dispatch: + inputs: + username: + description: "GitHub username to check" + required: true + type: string + org: + description: "GitHub organization name" + required: true + type: string + +jobs: + test-membership: + runs-on: ubuntu-latest + + steps: + - name: Install GitHub CLI + run: sudo apt-get install gh -y + + - name: Check if user is a member of the org + id: check-membership + run: | + USERNAME="${{ inputs.username }}" + ORG="${{ inputs.org }}" + STATUS=$(gh api "orgs/$ORG/members/$USERNAME" -q '.login' || true) + + if [[ "$STATUS" == "$USERNAME" ]]; then + echo "MEMBER_FOUND=true" >> $GITHUB_ENV + else + echo "MEMBER_FOUND=false" >> $GITHUB_ENV + fi + + - name: Comment on the check result + run: | + if [[ "$MEMBER_FOUND" == "true" ]]; then + echo "✅ $USERNAME is a member of the $ORG organization." + else + echo "❌ $USERNAME is NOT a member of the $ORG organization." + fi From a64c45c2b5adfacdcaf32c717ff5d94323d4a0b9 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 11:34:40 +0100 Subject: [PATCH 2/8] Update build-dev.yml --- .github/workflows/build-dev.yml | 92 ++++++++++----------------------- 1 file changed, 28 insertions(+), 64 deletions(-) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index b06ae635762d..96fac4709b90 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -1,78 +1,42 @@ -name: Dev build +name: Test Org Membership on: workflow_dispatch: inputs: - submodule_path_regex: - description: - Regex of submodule paths to updated to HEAD before building. - default: content-modules + username: + description: "GitHub username to check" + required: true + type: string + org: + description: "GitHub organization name" + required: true type: string jobs: - build-and-test: - name: BUILD and CHECK LINKS + test-membership: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Create NPM cache-hash input file - run: | - mkdir -p tmp - jq '{devDependencies, dependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json + steps: + - name: Install GitHub CLI + run: sudo apt-get install gh -y - - name: Create and use reduced-dependencies package.json + - name: Check if user is a member of the org + id: check-membership run: | - jq 'del(.dependencies, .optionalDependencies)' \ - package.json > tmp/package-min.json - cp tmp/package-min.json package.json - - - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: npm - cache-dependency-path: tmp/package-ci.json - - - run: npm install --omit=optional - - - run: npm run log:test-and-fix - env: - CMD_SKIP: i18n|registry - GET: no # For details, see: https://opentelemetry.io/docs/contributing/development/#submodule-changes - PIN_SKIP: ${{ inputs.submodule_path_regex }} - - - uses: actions/upload-artifact@v4 - with: - name: build-log-etc - path: | - tmp/build-log.txt - tmp/package*.json - static/refcache.json + USERNAME="${{ inputs.username }}" + ORG="${{ inputs.org }}" + STATUS=$(gh api "orgs/$ORG/members/$USERNAME" -q '.login' || true) + + if [[ "$STATUS" == "$USERNAME" ]]; then + echo "MEMBER_FOUND=true" >> $GITHUB_ENV + else + echo "MEMBER_FOUND=false" >> $GITHUB_ENV + fi - check-refcache: - name: REFCACHE updates? - needs: build-and-test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 - with: { name: build-log-etc } - - name: Fail when refcache contains entries with HTTP status 4XX + - name: Comment on the check result run: | - if grep -B 1 -e '"StatusCode": 4' static/refcache.json; then - echo "Run 'npx gulp prune' to remove 4xx entries from the refcache" - exit 1 + if [[ "$MEMBER_FOUND" == "true" ]]; then + echo "✅ $USERNAME is a member of the $ORG organization." + else + echo "❌ $USERNAME is NOT a member of the $ORG organization." fi - - name: Does the refcache need updating? - run: npm run diff:fail - - check-build-log-for-issues: - name: WARNINGS in build log? - needs: build-and-test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 - with: { name: build-log-etc } - - run: cat tmp/build-log.txt - - run: scripts/check-build-log.sh From 4be1f4456dcbd955f556340159691e8bb0704714 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 11:36:17 +0100 Subject: [PATCH 3/8] Update build-dev.yml --- .github/workflows/build-dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 96fac4709b90..c9645a69b180 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -32,6 +32,8 @@ jobs: else echo "MEMBER_FOUND=false" >> $GITHUB_ENV fi + env: + GH_TOKEN: ${{ github.token }} - name: Comment on the check result run: | From 5a21be461f5441903866b05d1e14586b4767881e Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 11:38:44 +0100 Subject: [PATCH 4/8] Update build-dev.yml --- .github/workflows/build-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index c9645a69b180..02d93a3bf32d 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -1,4 +1,4 @@ -name: Test Org Membership +name: Build Dev on: workflow_dispatch: @@ -33,7 +33,7 @@ jobs: echo "MEMBER_FOUND=false" >> $GITHUB_ENV fi env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} - name: Comment on the check result run: | From ebcc12c7fa3aedb6bdb79dab90f317fcb218f43a Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 11:47:25 +0100 Subject: [PATCH 5/8] Update build-dev.yml --- .github/workflows/build-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 02d93a3bf32d..47b04bd416ee 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -25,9 +25,9 @@ jobs: run: | USERNAME="${{ inputs.username }}" ORG="${{ inputs.org }}" - STATUS=$(gh api "orgs/$ORG/members/$USERNAME" -q '.login' || true) + STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false") - if [[ "$STATUS" == "$USERNAME" ]]; then + if [[ "$STATUS" == "true" ]]; then echo "MEMBER_FOUND=true" >> $GITHUB_ENV else echo "MEMBER_FOUND=false" >> $GITHUB_ENV From 4c9c562df8a61bbd5a909d301f3418dfd1e1686e Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 11:59:38 +0100 Subject: [PATCH 6/8] Update survey-on-merged-pr.yml --- .github/workflows/survey-on-merged-pr.yml | 55 ++++++++++++----------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index 96fac4709b90..59875cbb1824 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -1,42 +1,45 @@ -name: Test Org Membership +name: Survey on Merged PR by Non-Member on: - workflow_dispatch: - inputs: - username: - description: "GitHub username to check" - required: true - type: string - org: - description: "GitHub organization name" - required: true - type: string + pull_request: + types: [closed] jobs: - test-membership: + comment-on-pr: runs-on: ubuntu-latest - + if: github.event.pull_request.merged == true steps: - - name: Install GitHub CLI - run: sudo apt-get install gh -y + - name: Check if PR author is a member of the org + id: check-membership + run: | + PR_AUTHOR=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") + ORG_NAME="${{ github.repository_owner }}" + ORG_MEMBERS=$(gh api "orgs/$ORG_NAME/members" --jq '.[].login') + echo "PR_AUTHOR=${PR_AUTHOR}" >> $GITHUB_ENV + echo "MEMBER_FOUND=false" >> $GITHUB_ENV + for MEMBER in $ORG_MEMBERS; do + if [[ "$PR_AUTHOR" == "$MEMBER" ]]; then + echo "MEMBER_FOUND=true" >> $GITHUB_ENV + break + fi + done - name: Check if user is a member of the org id: check-membership run: | - USERNAME="${{ inputs.username }}" - ORG="${{ inputs.org }}" - STATUS=$(gh api "orgs/$ORG/members/$USERNAME" -q '.login' || true) - - if [[ "$STATUS" == "$USERNAME" ]]; then + USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") + ORG="${{ github.repository_owner }}" + STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false") + if [[ "$STATUS" == "true" ]]; then echo "MEMBER_FOUND=true" >> $GITHUB_ENV else echo "MEMBER_FOUND=false" >> $GITHUB_ENV fi + env: + GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} - - name: Comment on the check result + - name: Add comment to PR if author is not a member + if: env.MEMBER_FOUND == 'false' run: | - if [[ "$MEMBER_FOUND" == "true" ]]; then - echo "✅ $USERNAME is a member of the $ORG organization." - else - echo "❌ $USERNAME is NOT a member of the $ORG organization." - fi + PR_NUMBER=${{ github.event.pull_request.number }} + gh pr comment $PR_NUMBER --body "Thank you for your contribution! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by filling out this survey: https://forms.gle/WV58koUBGSG9HBY66" From a0dcb0ec18fde8512d67accdbf97ad69b9136184 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 3 Dec 2024 12:04:23 +0100 Subject: [PATCH 7/8] Update build-dev.yml --- .github/workflows/build-dev.yml | 92 ++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 47b04bd416ee..b06ae635762d 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -1,44 +1,78 @@ -name: Build Dev +name: Dev build on: workflow_dispatch: inputs: - username: - description: "GitHub username to check" - required: true - type: string - org: - description: "GitHub organization name" - required: true + submodule_path_regex: + description: + Regex of submodule paths to updated to HEAD before building. + default: content-modules type: string jobs: - test-membership: + build-and-test: + name: BUILD and CHECK LINKS runs-on: ubuntu-latest - steps: - - name: Install GitHub CLI - run: sudo apt-get install gh -y + - uses: actions/checkout@v4 - - name: Check if user is a member of the org - id: check-membership + - name: Create NPM cache-hash input file run: | - USERNAME="${{ inputs.username }}" - ORG="${{ inputs.org }}" - STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false") - - if [[ "$STATUS" == "true" ]]; then - echo "MEMBER_FOUND=true" >> $GITHUB_ENV - else - echo "MEMBER_FOUND=false" >> $GITHUB_ENV - fi + mkdir -p tmp + jq '{devDependencies, dependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json + + - name: Create and use reduced-dependencies package.json + run: | + jq 'del(.dependencies, .optionalDependencies)' \ + package.json > tmp/package-min.json + cp tmp/package-min.json package.json + + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + cache-dependency-path: tmp/package-ci.json + + - run: npm install --omit=optional + + - run: npm run log:test-and-fix env: - GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + CMD_SKIP: i18n|registry + GET: no # For details, see: https://opentelemetry.io/docs/contributing/development/#submodule-changes + PIN_SKIP: ${{ inputs.submodule_path_regex }} + + - uses: actions/upload-artifact@v4 + with: + name: build-log-etc + path: | + tmp/build-log.txt + tmp/package*.json + static/refcache.json - - name: Comment on the check result + check-refcache: + name: REFCACHE updates? + needs: build-and-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: { name: build-log-etc } + - name: Fail when refcache contains entries with HTTP status 4XX run: | - if [[ "$MEMBER_FOUND" == "true" ]]; then - echo "✅ $USERNAME is a member of the $ORG organization." - else - echo "❌ $USERNAME is NOT a member of the $ORG organization." + if grep -B 1 -e '"StatusCode": 4' static/refcache.json; then + echo "Run 'npx gulp prune' to remove 4xx entries from the refcache" + exit 1 fi + - name: Does the refcache need updating? + run: npm run diff:fail + + check-build-log-for-issues: + name: WARNINGS in build log? + needs: build-and-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: { name: build-log-etc } + - run: cat tmp/build-log.txt + - run: scripts/check-build-log.sh From 58fd6526be46e10a8b1d1a37c7a62cd536b1d49c Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Wed, 18 Dec 2024 10:25:46 +0100 Subject: [PATCH 8/8] Update survey-on-merged-pr.yml remove duplicate section --- .github/workflows/survey-on-merged-pr.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index 59875cbb1824..fdddb749d84c 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -9,21 +9,6 @@ jobs: runs-on: ubuntu-latest if: github.event.pull_request.merged == true steps: - - name: Check if PR author is a member of the org - id: check-membership - run: | - PR_AUTHOR=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") - ORG_NAME="${{ github.repository_owner }}" - ORG_MEMBERS=$(gh api "orgs/$ORG_NAME/members" --jq '.[].login') - echo "PR_AUTHOR=${PR_AUTHOR}" >> $GITHUB_ENV - echo "MEMBER_FOUND=false" >> $GITHUB_ENV - for MEMBER in $ORG_MEMBERS; do - if [[ "$PR_AUTHOR" == "$MEMBER" ]]; then - echo "MEMBER_FOUND=true" >> $GITHUB_ENV - break - fi - done - - name: Check if user is a member of the org id: check-membership run: |