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

ci: add workflow to enable voting #1120

Merged
merged 27 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5b0c743
Add workflow to enable voting
AayushSaini101 Mar 24, 2024
04c7047
Added required changes
AayushSaini101 Mar 28, 2024
2aa27ae
update'
AayushSaini101 Mar 28, 2024
b5b28f6
update author variable
AayushSaini101 Mar 28, 2024
d35401b
remove variable
AayushSaini101 Mar 28, 2024
603a058
update message name
AayushSaini101 Mar 28, 2024
75a665f
Merge branch 'master' into Issue-1093
AayushSaini101 Mar 28, 2024
bca1c04
Merge branch 'master' into Issue-1093
AayushSaini101 Apr 3, 2024
d7e79fd
Update suggestion
AayushSaini101 Apr 4, 2024
1be2132
improve suggestion
AayushSaini101 Apr 4, 2024
bb074f5
Improve description
AayushSaini101 Apr 4, 2024
eba881f
update suggestion
AayushSaini101 Apr 5, 2024
bc617e2
Merge branch 'master' into Issue-1093
AayushSaini101 Apr 5, 2024
7c94980
Merge branch 'master' into Issue-1093
AayushSaini101 Apr 7, 2024
369ac9a
Update .github/workflows/vote-verifcation.yml
AayushSaini101 Apr 8, 2024
ea9aeb8
Update .github/workflows/vote-verifcation.yml
AayushSaini101 Apr 8, 2024
e8443d0
Update voting.md
AayushSaini101 Apr 8, 2024
b1ab7da
Update .gitvote.yml
AayushSaini101 Apr 8, 2024
dd1fd13
Merge branch 'master' into Issue-1093
AayushSaini101 Apr 8, 2024
8102647
Merge branch 'master' into Issue-1093
AayushSaini101 Apr 8, 2024
ba2a965
Improve vote-verification.yml
AayushSaini101 Apr 8, 2024
3c618ba
Update voting.md
AayushSaini101 Apr 8, 2024
7543ccc
Update .gitvote.yml
AayushSaini101 Apr 8, 2024
28a66fe
Update voting.md
AayushSaini101 Apr 8, 2024
494ac73
Update voting.md
AayushSaini101 Apr 8, 2024
e93b988
Update voting.md
AayushSaini101 Apr 8, 2024
c859699
Remove voting
AayushSaini101 Apr 9, 2024
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
70 changes: 70 additions & 0 deletions .github/workflows/add_vote_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Add label to PR on comment

on:
issue_comment:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Get the comment body
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed @derberg thanks

id: get_comment_body
run: |
echo "Comment body: ${{ github.event.comment.body }}" | ls

- name: Verify TSC Member
id: verify_member
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const filePath = 'TSC_MEMBERS.json';
Copy link
Member

Choose a reason for hiding this comment

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

wrong file, your source of truth is https://github.com/asyncapi/community/blob/master/MAINTAINERS.yaml and entries with isTscMember set to true

also when you will be refactoring your code, please do not use old callbacks but do modern code with async/await

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed thanks @derberg

const commenterName = context.payload.sender.login;
let isTSCMember = false;

function readFileAndProcess(callback) {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
callback(err, null);
return;
}
try {
const jsonData = JSON.parse(data);
// Iterate over each object in the array
jsonData.forEach(item => {
if (item.github === commenterName) {
isTSCMember = true;
}
});
// Invoke the callback function with the result
callback(null, isTSCMember);
} catch (parseError) {
callback(parseError, null);
}
});
}

readFileAndProcess((error, result) => {
if (error) {
console.error('Error:', error);
} else {
console.log('Is TSC Member:', result);
core.setOutput('isTSCMember', isTSCMember);
}
});

- name: Add the label
Copy link
Member

Choose a reason for hiding this comment

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

we also need a step that will post a comment back in case not TSC member added /vote, to put a message that only TSC members can do it

here you have example how to do it: https://github.com/asyncapi/.github/blob/master/.github/workflows/bounty-program-commands.yml#L33

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@derberg when we allowed only TSC members voting, this will be double check, The user will be filter out when the it is not matching with the authorised voters, this will be message.

AayushSaini101/Vote#15 (comment)

Which is not a proper message by a gitvote-bot, we can allow voting for all contributors, then we can provide the custom comment not default one, This would be the best way to describe the situation in comments, instead of using default comments of the particular vote, What do you think ? @derberg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The representation of the templates of the gitvote is not proper for unauthorised vote https://github.com/cncf/gitvote/tree/main/templates, We can modify easily and make proper by changing own workflow as you shared in this https://github.com/asyncapi/.github/blob/master/.github/workflows/bounty-program-commands.yml#L33

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be the message when unauthorised author commented:
image

Copy link
Member

Choose a reason for hiding this comment

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

oh yeah, if git vote bot does the verification for us, then we should use it and not do it on our own as we will the over communicate, duplicate it kinda

Copy link
Contributor Author

@AayushSaini101 AayushSaini101 Mar 28, 2024

Choose a reason for hiding this comment

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

We cannot test the /vote command in the individual account need to use in the community, Reference cncf/gitvote#480

  • i removed)%20%26%26%20env) the authorised for the /vote command, it will be handled by gitvote workflow
  • The /cancel-vote command authorisation will be handled by our workflow not by bot one, Reference: sdf AayushSaini101/Vote#29 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we also need a step that will post a comment back in case not TSC member added /vote, to put a message that only TSC members can do it

here you have example how to do it: https://github.com/asyncapi/.github/blob/master/.github/workflows/bounty-program-commands.yml#L33
Thanks @derberg Done AayushSaini101/Vote#29 (comment) Testing

if: contains(github.event.comment.body, '/vote') && steps.verify_member.outputs.isTSCMember =='true'
run:
if [ "${{ github.event_name }}" = "pull_request" ]; then
gh pr edit ${{ github.event.pull_request.number }} --add-label "vote"
else
gh issue edit ${{ github.event.issue.number }} --add-label "vote"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

71 changes: 71 additions & 0 deletions .github/workflows/remove_vote_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Remove vote label

on:
issue_comment:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Get the comment body
id: get_comment_body
run: |
echo "Comment body: ${{ github.event.comment.body }}"

- name: Verify TSC Member
id: verify_member
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const filePath = 'TSC_MEMBERS.json';
const commenterName = context.payload.sender.login;
let isTSCMember = false;

function readFileAndProcess(callback) {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
callback(err, null);
return;
}
try {
const jsonData = JSON.parse(data);
// Iterate over each object in the array
jsonData.forEach(item => {
if (item.github === commenterName) {
isTSCMember = true;
}
});
// Invoke the callback function with the result
callback(null, isTSCMember);
} catch (parseError) {
callback(parseError, null);
}
});
}

readFileAndProcess((error, result) => {
if (error) {
console.error('Error:', error);
} else {
console.log('Is TSC Member:', result);
core.setOutput('isTSCMember', isTSCMember);
}
});

- name: Add the label
if: contains(github.event.comment.body, '/cancel-vote') && steps.verify_member.outputs.isTSCMember =='true'
run:
run:|
if [ "${{ github.event_name }}" = "pull_request" ]; then
gh pr edit ${{ github.event.pull_request.number }} --remove-label "vote"
else
gh issue edit ${{ github.event.issue.number }} --remove-label "vote"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

54 changes: 54 additions & 0 deletions .gitvote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
profiles:
derberg marked this conversation as resolved.
Show resolved Hide resolved
default:
duration: 2m
AayushSaini101 marked this conversation as resolved.
Show resolved Hide resolved
pass_threshold: 51
periodic_status_check: "1 week"
AayushSaini101 marked this conversation as resolved.
Show resolved Hide resolved
allowed_voters:
teams:
- tsc_members
users:
Copy link
Member

Choose a reason for hiding this comment

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

all of them should be in tsc_members so no need to explicitly list users

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new yaml file

- aayushmau5
- imabp
- akshatnema
- anandsunderraman
- arjungarg07
- CameronRushton
- dalelane
- emilianozublena
- fmvilas
- GeraldLoeffler
- jonaslagoni
- KhudaDad414
- lbroudoux
- m3lkior
- derberg
- magicmatatjahu
- AceTheCreator
- damaru-inc
- mcturco
- NektariosFifes
- Pakisan
- theschles
- pratik2315
- rcoppen
- smoya
- Souvikns
- alequetzalli
- BOLT04
- dan-r
- KieranM1999
- JEFFLUFC
- thulieblack
- lewis-relph
- boyney123
- Tenischev
- Samridhi-98
- ron-debajyoti
- ivangsa
- Florence-Njeri
- whitlockjc
- char0n
- VisualBean
- Barbanio
- kennethaasan
- GreenRover
Loading