Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/OWNERS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* @andrewnester @anton-107 @denik @pietern @shreyas-goenka @simonfaltum
/cmd/bundle/ @andrewnester @anton-107 @denik @pietern @shreyas-goenka @simonfaltum @lennartkats-db
/cmd/bundle/ @andrewnester @anton-107 @denik @pietern @shreyas-goenka @lennartkats-db
/libs/template/ @andrewnester @anton-107 @denik @pietern @shreyas-goenka @simonfaltum @lennartkats-db
/acceptance/pipelines/ @jefferycheng1 @kanterov @lennartkats-db
/cmd/pipelines/ @jefferycheng1 @kanterov @lennartkats-db
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/owners.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ function findOwners(filepath, rules) {
}

/**
* Get core team from the * catch-all rule.
* Get maintainers from the * catch-all rule.
* @returns {string[]} logins
*/
function getCoreTeam(rules) {
function getMaintainers(rules) {
const catchAll = rules.find((r) => r.pattern === "*");
return catchAll ? catchAll.owners : [];
}

module.exports = { parseOwnersFile, ownersMatch, findOwners, getCoreTeam };
module.exports = { parseOwnersFile, ownersMatch, findOwners, getMaintainers };
34 changes: 17 additions & 17 deletions .github/workflows/maintainer-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ const path = require("path");
const {
parseOwnersFile,
findOwners,
getCoreTeam,
getMaintainers,
} = require("../scripts/owners");

// Check if the PR author is exempted.
// If ALL changed files are owned by non-core-team owners that include the
// author, the PR can merge with any approval (not necessarily core team).
function isExempted(authorLogin, files, rules, coreTeam) {
// If ALL changed files are owned by non-maintainer owners that include the
// author, the PR can merge with any approval (not necessarily a maintainer).
function isExempted(authorLogin, files, rules, maintainers) {
if (files.length === 0) return false;
const coreSet = new Set(coreTeam);
const maintainerSet = new Set(maintainers);
for (const { filename } of files) {
const owners = findOwners(filename, rules);
const nonCoreOwners = owners.filter((o) => !coreSet.has(o));
if (nonCoreOwners.length === 0 || !nonCoreOwners.includes(authorLogin)) {
const nonMaintainers = owners.filter((o) => !maintainerSet.has(o));
if (nonMaintainers.length === 0 || !nonMaintainers.includes(authorLogin)) {
return false;
}
}
Expand All @@ -28,11 +28,11 @@ module.exports = async ({ github, context, core }) => {
"OWNERS"
);
const rules = parseOwnersFile(ownersPath);
const coreTeam = getCoreTeam(rules);
const maintainers = getMaintainers(rules);

if (coreTeam.length === 0) {
if (maintainers.length === 0) {
core.setFailed(
"Could not determine core team from .github/OWNERS (no * rule found)."
"Could not determine maintainers from .github/OWNERS (no * rule found)."
);
return;
}
Expand All @@ -43,17 +43,17 @@ module.exports = async ({ github, context, core }) => {
pull_number: context.issue.number,
});

const coreTeamApproved = reviews.some(
const maintainerApproved = reviews.some(
({ state, user }) =>
state === "APPROVED" && user && coreTeam.includes(user.login)
state === "APPROVED" && user && maintainers.includes(user.login)
);

if (coreTeamApproved) {
if (maintainerApproved) {
const approver = reviews.find(
({ state, user }) =>
state === "APPROVED" && user && coreTeam.includes(user.login)
state === "APPROVED" && user && maintainers.includes(user.login)
);
core.info(`Core team approval from @${approver.user.login}`);
core.info(`Maintainer approval from @${approver.user.login}`);
return;
}

Expand All @@ -67,7 +67,7 @@ module.exports = async ({ github, context, core }) => {
pull_number: context.issue.number,
});

if (authorLogin && isExempted(authorLogin, files, rules, coreTeam)) {
if (authorLogin && isExempted(authorLogin, files, rules, maintainers)) {
const hasAnyApproval = reviews.some(({ state }) => state === "APPROVED");
if (!hasAnyApproval) {
core.setFailed(
Expand All @@ -78,6 +78,6 @@ module.exports = async ({ github, context, core }) => {
}

core.setFailed(
`Requires approval from a core team member: ${coreTeam.join(", ")}.`
`Requires approval from a maintainer: ${maintainers.join(", ")}.`
);
};
4 changes: 3 additions & 1 deletion .github/workflows/maintainer-approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ defaults:

jobs:
check:
runs-on: ubuntu-latest
runs-on:
group: databricks-deco-testing-runner-group
labels: ubuntu-latest-deco
timeout-minutes: 5
permissions:
pull-requests: read
Expand Down
Loading