Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: automated updation of voteTrackingFile.json on removal of a TSC Member #1626

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 43 additions & 17 deletions .github/workflows/tsc_management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: [closed]
paths:
- 'MAINTAINERS.yaml'
- "MAINTAINERS.yaml"

jobs:
detect_tsc_membership_changes:
Expand Down Expand Up @@ -50,17 +50,17 @@ jobs:
function hasIsTscMemberChanged(maintainerGithub) {
const mainMaintainer = mainFile.find(m => m.github === maintainerGithub);
const prMaintainer = prFile.find(m => m.github === maintainerGithub);

core.info(`Checking for ${maintainerGithub}`);

if (!mainMaintainer || !prMaintainer) {
console.error('Maintainer not found:', maintainerGithub);
return;
}

core.info(`${maintainerGithub} in mainFile has isTscMember as:`, mainMaintainer.isTscMember);
core.info(`${maintainerGithub} in prFile has isTscMember as:`, prMaintainer.isTscMember);

if (mainMaintainer.isTscMember !== prMaintainer.isTscMember) {
core.info(`isTscMember value changed for ${maintainerGithub}`);
updatedMaintainers.push({ githubUser: maintainerGithub, updatedValue: mainMaintainer.isTscMember });
Expand All @@ -70,15 +70,15 @@ jobs:

// Loop over all maintainers and find the changes
mainFile.forEach(maintainer => hasIsTscMemberChanged(maintainer.github));

// Log final results
core.info("Final updatedValue:", updatedValue);
core.info("Final updatedMaintainers:", JSON.stringify(updatedMaintainers));

// Set outputs
core.setOutput("updatedValue", updatedValue);
core.setOutput("updatedMaintainers", JSON.stringify(updatedMaintainers));
outputs:
outputs:
updatedValue: ${{ steps.compare-files.outputs.updatedValue }}
updatedMaintainers: ${{ steps.compare-files.outputs.updatedMaintainers }}

Expand Down Expand Up @@ -165,6 +165,24 @@ jobs:
core.setFailed(`Failed to remove ${maintainer.githubUser} from the team: ${error.message}`);
}
}
- name: Update voteTrackingFile.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's good direction, but you need to put some more work in it

  • you need to test it manually on a test repo, maybe on fork it will work - and proof it works
  • you need to make sure the changes in the file are in the end reflected in the repo. Now, your workflow will update json file, but in the virtual machine, where this job runs - not in actual repository. Look at update_emeritus job for inspiration. Probably better if your step is acutally done as part of update_emeritus - so just one PR is done with 2 files changed.

also you need to manually remove any emeritus from https://github.com/asyncapi/community/blob/master/TSC_VOTING_OVERVIEW.md is still there

also, voteTrackingFile.json update should also be reflected in TSC_VOTING_OVERVIEW.md. Might be that some refactor of https://github.com/asyncapi/community/blob/master/.github/scripts/vote_tracker.js is needed. We might need a separate function we can run in automation, just to refresh the file basing on curren voteTrackingFile.json with no need on voting to happen

uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const fs = require('fs');
const path = './voteTrackingFile.json';
const removedMaintainers = JSON.parse('${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }}');

let voteTrackingData = JSON.parse(fs.readFileSync(path, 'utf8'));

removedMaintainers.forEach(maintainer => {
voteTrackingData = voteTrackingData.filter(vote => vote.name !== maintainer.githubUser);
});

fs.writeFileSync(path, JSON.stringify(voteTrackingData, null, 2));

console.log('Updated voteTrackingFile.json:\n', JSON.stringify(voteTrackingData, null, 2));
outputs:
removedMaintainers: ${{ needs.detect_tsc_membership_changes.outputs.updatedMaintainers }}

Expand Down Expand Up @@ -230,7 +248,7 @@ jobs:

// Log the updated content to the console
console.log('Updated Emeritus.yaml:\n', content);

- name: Create new branch
run: |
git checkout -b update-emeritus-${{ github.run_id }}
Expand All @@ -247,13 +265,21 @@ jobs:

notify_slack_on_failure:
if: always() && (needs.detect_tsc_membership_changes.result == 'failure' || needs.add_tsc_member.result == 'failure' || needs.display_message.result == 'failure' || needs.update_emeritus.result == 'failure' || needs.remove_tsc_member.result == 'failure' || needs.remove_tsc_goodbye.result == 'failure')
needs: [detect_tsc_membership_changes, add_tsc_member, display_message, update_emeritus,remove_tsc_goodbye, remove_tsc_member]
needs:
[
detect_tsc_membership_changes,
add_tsc_member,
display_message,
update_emeritus,
remove_tsc_goodbye,
remove_tsc_member,
]
runs-on: ubuntu-latest
steps:
- name: Report workflow run status to Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{secrets.SLACK_CI_FAIL_NOTIFY}}
SLACK_TITLE: 🚨 TSC Management Workflow failed 🚨
SLACK_MESSAGE: Failed to post a message to new TSC member
MSG_MINIMAL: true
- name: Report workflow run status to Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{secrets.SLACK_CI_FAIL_NOTIFY}}
SLACK_TITLE: 🚨 TSC Management Workflow failed 🚨
SLACK_MESSAGE: Failed to post a message to new TSC member
MSG_MINIMAL: true
60 changes: 30 additions & 30 deletions .github/workflows/vote-verifcation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,44 @@ jobs:
uses: actions/github-script@v6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are changes in this fine necessary or just simple style refresh, autoformatter?

with:
github-token: ${{ secrets.GH_TOKEN_BOT_EVE }}
script : |
const isTSCMember = ${{ steps.verify_member.outputs.isTSCMember}}
if(!isTSCMember) {
const commentText = `Hi @${{ github.actor }}, since you are not a [TSC Member](https://www.asyncapi.com/community/tsc), you cannot start or stop voting. Please [read more about voting process](https://github.com/asyncapi/community/blob/master/voting.md)`;
console.log(`User ❌ @${{ github.actor }} is not a TSC Member`);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentText
});
} else if('${{github.actor}}' != 'git-vote[bot]') {
console.log(`User ✅ @${{ github.actor }} is a TSC Member`);
}
script: |
const isTSCMember = ${{ steps.verify_member.outputs.isTSCMember}}
if(!isTSCMember) {
const commentText = `Hi @${{ github.actor }}, since you are not a [TSC Member](https://www.asyncapi.com/community/tsc), you cannot start or stop voting. Please [read more about voting process](https://github.com/asyncapi/community/blob/master/voting.md)`;
console.log(`User ❌ @${{ github.actor }} is not a TSC Member`);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentText
});
} else if('${{github.actor}}' != 'git-vote[bot]') {
console.log(`User ✅ @${{ github.actor }} is a TSC Member`);
}

- name: Add the label
run: |
if [ "${{steps.verify_member.outputs.isTSCMember}}" == "true" ]; then
if [ "${{ github.event.comment.body }}" == "/vote" ]; then
if [ "${{ github.event_name }}" != "pull_request" ]; then
gh issue edit ${{ github.event.issue.number }} --add-label "vote"
else
gh pr edit ${{ github.event.issue.number }} --add-label "vote"
fi
if [ "${{steps.verify_member.outputs.isTSCMember}}" == "true" ]; then
if [ "${{ github.event.comment.body }}" == "/vote" ]; then
if [ "${{ github.event_name }}" != "pull_request" ]; then
gh issue edit ${{ github.event.issue.number }} --add-label "vote"
else
gh pr edit ${{ github.event.issue.number }} --add-label "vote"
fi
fi
fi
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_BOT_EVE }}
- name: Remove the label
run: |
if [ "${{steps.verify_member.outputs.isTSCMember}}" == "true" ]; then
if [ "${{ github.event.comment.body }}" == "/cancel-vote" ]; then
if [ "${{ github.event_name }}" != "pull_request" ]; then
gh issue edit ${{ github.event.issue.number }} --remove-label "vote"
else
gh pr edit ${{ github.event.issue.number }} --remove-label "vote"
fi
if [ "${{steps.verify_member.outputs.isTSCMember}}" == "true" ]; then
if [ "${{ github.event.comment.body }}" == "/cancel-vote" ]; then
if [ "${{ github.event_name }}" != "pull_request" ]; then
gh issue edit ${{ github.event.issue.number }} --remove-label "vote"
else
gh pr edit ${{ github.event.issue.number }} --remove-label "vote"
fi
fi
fi
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_BOT_EVE }}
2 changes: 1 addition & 1 deletion Emeritus.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file lists individuals who were previously TSC members and Ambassadors but are no longer active.

emeritus_tsc:
- jotamusik
- jotamusik
- LouisXhaferi
- aeworxet
- arjungarg07
Expand Down
Loading