ci: remove team reviewers

Team reviewers is a nice feature that comes with a severe drawback: it
makes testing the workflows incredibly difficult as they won't work
without a similar token by the tester.
This commit is contained in:
dundargoc 2023-04-22 13:50:27 +02:00 committed by GitHub
parent 515106ac08
commit 669030ec08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 61 deletions

View File

@ -2,17 +2,15 @@ module.exports = async ({github, context}) => {
const requestedReviewers = await github.rest.pulls.listRequestedReviewers({ const requestedReviewers = await github.rest.pulls.listRequestedReviewers({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: context.issue.number pull_number: context.issue.number,
}); });
const reviewers = requestedReviewers.data.users.map(e => e.login) const reviewers = requestedReviewers.data.users.map((e) => e.login);
const team_reviewers = requestedReviewers.data.teams.map(e => e.name);
github.rest.pulls.removeRequestedReviewers({ github.rest.pulls.removeRequestedReviewers({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: context.issue.number, pull_number: context.issue.number,
reviewers: reviewers, reviewers: reviewers,
team_reviewers: team_reviewers
}); });
} };

View File

@ -2,101 +2,107 @@ module.exports = async ({github, context}) => {
const pr_data = await github.rest.pulls.get({ const pr_data = await github.rest.pulls.get({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: context.issue.number pull_number: context.issue.number,
}) });
const labels = pr_data.data.labels.map(e => e.name) const labels = pr_data.data.labels.map((e) => e.name);
const reviewers = new Set() const reviewers = new Set();
const team_reviewers = new Set() if (labels.includes("api")) {
if (labels.includes('api')) { reviewers.add("bfredl");
reviewers.add("bfredl")
} }
if (labels.includes('build')) { if (labels.includes("build")) {
team_reviewers.add('ci'); reviewers.add("dundargoc");
reviewers.add("jamessan");
reviewers.add("justinmk");
} }
if (labels.includes('ci')) { if (labels.includes("ci")) {
team_reviewers.add('ci'); reviewers.add("dundargoc");
reviewers.add("jamessan");
reviewers.add("justinmk");
} }
if (labels.includes('column')) { if (labels.includes("column")) {
reviewers.add("lewis6991") reviewers.add("lewis6991");
} }
if (labels.includes('dependencies')) { if (labels.includes("dependencies")) {
reviewers.add("jamessan") reviewers.add("jamessan");
} }
if (labels.includes('diagnostic')) { if (labels.includes("diagnostic")) {
reviewers.add("gpanders") reviewers.add("gpanders");
} }
if (labels.includes('diff')) { if (labels.includes("diff")) {
reviewers.add("lewis6991") reviewers.add("lewis6991");
} }
if (labels.includes('distribution')) { if (labels.includes("distribution")) {
reviewers.add("jamessan") reviewers.add("jamessan");
} }
if (labels.includes('documentation')) { if (labels.includes("documentation")) {
reviewers.add("clason") reviewers.add("clason");
} }
if (labels.includes('extmarks')) { if (labels.includes("extmarks")) {
reviewers.add("bfredl") reviewers.add("bfredl");
} }
if (labels.includes('filetype')) { if (labels.includes("filetype")) {
reviewers.add("clason") reviewers.add("clason");
reviewers.add("gpanders") reviewers.add("gpanders");
reviewers.add("smjonas") reviewers.add("smjonas");
} }
if (labels.includes('lsp')) { if (labels.includes("lsp")) {
team_reviewers.add('lsp'); reviewers.add("folke");
reviewers.add("glepnir");
reviewers.add("mfussenegger");
} }
if (labels.includes('platform:nix')) { if (labels.includes("platform:nix")) {
reviewers.add("teto") reviewers.add("teto");
} }
if (labels.includes('project-management')) { if (labels.includes("project-management")) {
reviewers.add("bfredl") reviewers.add("bfredl");
reviewers.add("justinmk") reviewers.add("justinmk");
} }
if (labels.includes('test')) { if (labels.includes("test")) {
reviewers.add("justinmk") reviewers.add("justinmk");
} }
if (labels.includes('treesitter')) { if (labels.includes("treesitter")) {
team_reviewers.add('treesitter'); reviewers.add("bfredl");
reviewers.add("clason");
reviewers.add("lewis6991");
} }
if (labels.includes('typo')) { if (labels.includes("typo")) {
reviewers.add("dundargoc") reviewers.add("dundargoc");
} }
if (labels.includes('ui')) { if (labels.includes("ui")) {
reviewers.add("bfredl") reviewers.add("bfredl");
} }
if (labels.includes('vim-patch')) { if (labels.includes("vim-patch")) {
reviewers.add("seandewar") reviewers.add("seandewar");
reviewers.add("zeertzjq") reviewers.add("zeertzjq");
} }
// Remove person that opened the PR since they can't review themselves // Remove person that opened the PR since they can't review themselves
const pr_opener = pr_data.data.user.login const pr_opener = pr_data.data.user.login;
reviewers.delete(pr_opener) reviewers.delete(pr_opener);
github.rest.pulls.requestReviewers({ github.rest.pulls.requestReviewers({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: context.issue.number, pull_number: context.issue.number,
reviewers: Array.from(reviewers), reviewers: Array.from(reviewers),
team_reviewers: Array.from(team_reviewers)
}); });
} };

View File

@ -13,7 +13,6 @@ jobs:
- name: 'Request reviewers' - name: 'Request reviewers'
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
github-token: ${{ secrets.TEAM_REVIEW }}
script: | script: |
const script = require('./.github/scripts/reviews.js') const script = require('./.github/scripts/reviews.js')
await script({github, context}) await script({github, context})

View File

@ -43,7 +43,6 @@ jobs:
- name: 'Request reviewers' - name: 'Request reviewers'
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
github-token: ${{ secrets.TEAM_REVIEW }}
script: | script: |
const script = require('./.github/scripts/reviews.js') const script = require('./.github/scripts/reviews.js')
await script({github, context}) await script({github, context})

View File

@ -12,7 +12,6 @@ jobs:
- name: 'Remove reviewers' - name: 'Remove reviewers'
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
github-token: ${{ secrets.TEAM_REVIEW }}
script: | script: |
const script = require('./.github/scripts/remove-reviewers.js') const script = require('./.github/scripts/remove-reviewers.js')
await script({github, context}) await script({github, context})