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 9 commits
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
48 changes: 48 additions & 0 deletions .github/actions/verifyTSCMember/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Verify TCS Member

outputs:
version:
derberg marked this conversation as resolved.
Show resolved Hide resolved
description: 'true/false'
value: ${{ steps.verify_member.outputs.isTSCMember }}

inputs:
authorName:
description: 'Name of the Commentor'
required: true

runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v3
Copy link
Member

Choose a reason for hiding this comment

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

v4 is latest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @derberg


- name: Install the dependencies
run: npm install js-yaml@^4.0.1
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
run: npm install js-yaml@^4.0.1
run: npm install [email protected]

in such cases always lock to specific version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @derberg

shell: bash

- name: Verify TSC Member
id: verify_member
uses: actions/github-script@v6
with:
script: |
const yaml = require('js-yaml');
const fs = require('fs');
const commenterName = '${{ inputs.authorName }}';
let isTSCMember = false;
try {
// Load YAML file
const data = yaml.load(fs.readFileSync('../../MAINTAINERS.yaml', 'utf8'));

// Filter persons who are TSC members and whose GitHub username matches commenterName
const filteredPersons = data.filter(person => {
return (person.isTscMember === true || person.isTscMember === "true") && person.github === commenterName;
});
// Log filtered persons
filteredPersons.forEach(person => {
isTSCMember = true;
});
Copy link
Member

Choose a reason for hiding this comment

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

cool you used filter but then you iterate again already

maybe you prefer this

// Find a person who is a TSC member and whose GitHub username matches commenterName
const tscMember = data.find(person => {
    return (person.isTscMember === true || person.isTscMember === "true") && person.github === commenterName;
});

// Check if a TSC member was found
if (tscMember) {
    isTSCMember = true;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved thanks @derberg


core.setOutput('isTSCMember', isTSCMember);
} catch (e) {
console.log(e);
}
59 changes: 59 additions & 0 deletions .github/workflows/vote-verifcation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Verification of the Vote

on:
issue_comment:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Copy link
Member

Choose a reason for hiding this comment

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

latest please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @derberg

- name: Verify the person
id: verify_member
uses: ./.github/actions/verifyMember
with:
authorName: "${{github.event.comment.user.login}}"

- name: Set Output to Environment Variable
run: echo "IS_TSC_MEMBER=${{ steps.verify_member.outputs.version }}" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

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

we for sure do not need it

later instead of ${{env.IS_TSC_MEMBER}} you can for sure do ${{ steps.verify_member.outputs.version }}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove @derberg step


- name: Checking the person authenticity for vote.
if: contains(github.event.comment.body, '/vote') || contains(github.event.comment.body, '/cancel-vote')
uses: actions/github-script@v6
with:
script: |
const isTSCMember = ${{env.IS_TSC_MEMBER}};
if (!isTSCMember) {
const commentText = `User ❌ @${{ github.actor }} is not a [TSC Member](https://github.com/asyncapi/community/blob/master/TSC_MEMBERS.json).`;
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
if: (contains(github.event.comment.body, '/cancel-vote') || contains(github.event.comment.body, '/vote')) && env.IS_TSC_MEMBER =='true'
run: |
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"
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't it be cancel-vote label?

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 a new label thanks @derberg

fi
fi
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
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
derberg marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions .gitvote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
profiles:
derberg marked this conversation as resolved.
Show resolved Hide resolved
default:
duration: 1d
pass_threshold: 51
periodic_status_check: "1 week"
AayushSaini101 marked this conversation as resolved.
Show resolved Hide resolved
allowed_voters:
teams:
- tsc_members
85 changes: 85 additions & 0 deletions docs/voting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## Voting for TSC Members
derberg marked this conversation as resolved.
Show resolved Hide resolved

There are many situation in the open source contribution, when we need to take suggestion of all the organsiation members, whether the particular issue is required or not, or the changes is valid in the specific pull request.

Now we can easily listen the suggestions of the members via **git-vot** bot.

### Voting Rules

* The voting will be done by only TSC Members.
* The duration of the voting will be 1 day.
* The vote will be passed when more than 50% voting are in favour.

### How to vote on particular issue and pull request.

You need to add only one command to start the voting process on the issue on in the particular PR. **Please not only TSC Members can participate in the voting process**.

*A **vote label** will be added on the issue after starting of the voting process.*

**Command:**

```
/vote
```

**TSC Member starting voting process:**

![image](https://hackmd.io/_uploads/Sk_L-CWyR.png)


**Reactions to participate in voting process**
* In favor of the changes. 👍
* In against of the changes. 👎
* Abstain from the voting. 👀


**Example:**

Member voted in the favor of the required changes

![image](https://hackmd.io/_uploads/BybuXCZ1C.png)


**Result:**


![image](https://hackmd.io/_uploads/ByXBNRWJA.png)


### Checking status of the vote
If anyone wants to check the status of the vote can easily check by using following command:

```
/check-vote
```
**Status of the vote**

![image](https://hackmd.io/_uploads/ry3dOLGJ0.png)

### Invalid vote execution


When unauthorised member tries to execute the /vote command, he or she will get a message related to unauthorised.

**Starting unauthorised voting:**

![image](https://hackmd.io/_uploads/BywW8AbkR.png)


**Getting response for voting**
![image](https://hackmd.io/_uploads/rkjnS0bkA.png)



### Cancelling the vote

TSC members can cancel the voting on the particular issue or PR, The cancelling vote removes the **vote** label from an issue.

**Command:**
```
cancel-vote
```

**Cancelling vote status:**

![image](https://hackmd.io/_uploads/rkhgYUzkC.png)
45 changes: 45 additions & 0 deletions tsc_members.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-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