Skip to content

Commit

Permalink
feat: make labels optional, remove groups
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Mar 4, 2023
1 parent 93a46fc commit 94e7201
Show file tree
Hide file tree
Showing 63 changed files with 972 additions and 1,344 deletions.
9 changes: 9 additions & 0 deletions src/__fixtures__/labels.json
Expand Up @@ -35,6 +35,15 @@
"default": false,
"description": "Synced by reviewflow for code/approved"
},
{
"id": 1210432964,
"node_id": "MDU6TGFiZWwxMjEwNDMyOTYz",
"url": "https://api.github.com/repos/reviewflow/reviewflow-test/labels/:white_check_mark:%20bot%20approval",
"name": ":white_check_mark: bot approval",
"color": "238636",
"default": false,
"description": "Synced by reviewflow for review/auto-approve"
},
{
"id": 1210432962,
"node_id": "MDU6TGFiZWwxMjEwNDMyOTYy",
Expand Down
27 changes: 11 additions & 16 deletions src/accountConfigs/christophehurpeau.ts
@@ -1,7 +1,7 @@
import { githubPalette } from './color-palettes/githubPalette';
import type { Config } from './types';

const config: Config<'dev', never> = {
const config: Config<never> = {
autoAssignToCreator: true,
trimTitle: true,
requiresReviewRequest: false,
Expand All @@ -14,15 +14,6 @@ const config: Config<'dev', never> = {
lintPullRequestTitleWithConventionalCommit: true,
githubAutoMerge: true,
},
groups: {
dev: {
christophehurpeau: 'christophe@hurpeau.com',
tilap: 'jlavinh@gmail.com',
},
},
waitForGroups: {
dev: [],
},
teams: {},
labels: {
legacyToRemove: {
Expand All @@ -32,6 +23,12 @@ const config: Config<'dev', never> = {
},
},
list: {
/* auto approve */
'review/auto-approve': {
name: ':white_check_mark: bot approval',
color: githubPalette.successEmphasis,
},

/* checks */
'checks/failed': {
name: ':green_heart: checks/fail',
Expand Down Expand Up @@ -88,12 +85,10 @@ const config: Config<'dev', never> = {
},

review: {
dev: {
needsReview: 'code/needs-review',
requested: 'code/review-requested',
changesRequested: 'code/changes-requested',
approved: 'code/approved',
},
needsReview: 'code/needs-review',
requested: 'code/review-requested',
changesRequested: 'code/changes-requested',
approved: 'code/approved',
},
},
};
Expand Down
12 changes: 1 addition & 11 deletions src/accountConfigs/defaultConfig.ts
@@ -1,7 +1,7 @@
import { githubPalette } from './color-palettes/githubPalette';
import type { Config } from './types';

const config: Config<never, never> = {
const config: Config<never> = {
autoAssignToCreator: true,
trimTitle: true,
requiresReviewRequest: false,
Expand All @@ -13,8 +13,6 @@ const config: Config<never, never> = {
parsePR: {
title: [],
},
groups: {},
waitForGroups: {},
teams: {},
labels: {
legacyToRemove: {
Expand All @@ -40,14 +38,6 @@ const config: Config<never, never> = {
color: githubPalette.attentionEmphasis,
},
},

review: {
checks: {
inProgress: 'checks/in-progress',
succeeded: 'checks/success',
failed: 'checks/fail',
},
},
},
};

Expand Down
12 changes: 1 addition & 11 deletions src/accountConfigs/index.ts
Expand Up @@ -4,10 +4,7 @@ import ornikar from './ornikar';
import reviewflow from './reviewflow';
import type { Config as ConfigType } from './types';

export type Config<
GroupNames extends string = any,
TeamNames extends string = any,
> = ConfigType<GroupNames, TeamNames>;
export type Config<TeamNames extends string = any> = ConfigType<TeamNames>;

export const accountConfigs: Record<string, Config> = {
liwijs,
Expand All @@ -17,10 +14,3 @@ export const accountConfigs: Record<string, Config> = {
};

export { default as defaultConfig } from './defaultConfig';

// flat requires node 11
// export const getMembers = <GroupNames extends string = any>(
// groups: Record<GroupNames, Group>,
// ): string[] => {
// return Object.values(groups).flat(1);
// };
2 changes: 1 addition & 1 deletion src/accountConfigs/liwijs.ts
@@ -1,7 +1,7 @@
import chrisconfig from './christophehurpeau';
import type { Config } from './types';

const config: Config<'dev', never> = {
const config: Config<never> = {
...chrisconfig,
};
export default config;
80 changes: 9 additions & 71 deletions src/accountConfigs/ornikar.ts
Expand Up @@ -32,7 +32,7 @@ const lateOceanColorPalette = {
moonPurpleLight1: '#EDEBFC',
};

const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {
const config: Config<'ops' | 'frontends' | 'backends'> = {
autoAssignToCreator: true,
trimTitle: true,
ignoreRepoPattern: '(infra-.*|devenv|bigquery-dbt)',
Expand Down Expand Up @@ -217,73 +217,20 @@ const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {

botUsers: ['michael-robot'],

groups: {
dev: {},
design: {},
},

groupsGithubTeams: {
dev: [
'ops',
'dev',
'backend',
'frontend',
'frontend-architects',
'external-bam',
'external-padok',
'data-engineering',
],
design: ['design'],
},

teams: {
ops: {
githubTeamName: 'ops',
logins: ['JulienBreux', 'TheR3aLp3nGuinJM', 'AymenBac'],
labels: ['teams/ops'],
},

backends: {
githubTeamName: 'backend',
logins: [
'abarreir',
'arthurflachs',
'damienorny',
'Thierry-girod',
'darame07',
'Pixy',
'machartier',
'camillebaronnet',
'olivier-martinez',
'tnesztler',
],
labels: ['teams/backend'],
},

frontends: {
githubTeamName: 'frontend',
logins: [
'christophehurpeau',
'HugoGarrido',
'LentnerStefan',
'CorentinAndre',
'Mxime',
'vlbr',
'budet-b',
'mdcarter',
'ChibiBlasphem',
'PSniezak',
'aenario',
'Goldiggy',
],
labels: ['teams/frontend'],
},
},

waitForGroups: {
dev: [],
design: ['dev'],
},
labels: {
legacyToRemove: {
/* checks */
Expand All @@ -299,8 +246,7 @@ const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {
name: ':green_heart: checks/passed',
color: githubPalette.successEmphasis,
},
},
list: {

/* code */
'code/needs-review': {
name: ':ok_hand: code/needs-review',
Expand Down Expand Up @@ -350,6 +296,13 @@ const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {
name: 'frontend',
color: lateOceanColorPalette.lateOcean,
},
},
list: {
/* auto approve */
'review/auto-approve': {
name: ':white_check_mark: bot approval',
color: githubPalette.successEmphasis,
},

/* auto merge */
'merge/automerge': {
Expand Down Expand Up @@ -422,21 +375,6 @@ const config: Config<'dev' | 'design', 'ops' | 'frontends' | 'backends'> = {
color: lateOceanColorPalette.moonPurple,
},
},

review: {
dev: {
needsReview: 'code/needs-review',
requested: 'code/review-requested',
changesRequested: 'code/changes-requested',
approved: 'code/approved',
},
design: {
needsReview: 'design/needs-review',
requested: 'design/review-requested',
changesRequested: 'design/changes-requested',
approved: 'design/approved',
},
},
},
};

Expand Down
8 changes: 1 addition & 7 deletions src/accountConfigs/reviewflow.ts
Expand Up @@ -2,7 +2,7 @@ import chrisconfig from './christophehurpeau';
// import ornikarconfig from './ornikar';
import type { Config } from './types';

const config: Config<'dev', never> = {
const config: Config<never> = {
...chrisconfig,
experimentalFeatures: {
...chrisconfig.experimentalFeatures,
Expand All @@ -11,12 +11,6 @@ const config: Config<'dev', never> = {
warnOnForcePushAfterReviewStarted: {
message: 'Force-pushing after the review started is a bad practice',
},
groups: {
dev: {
christophehurpeau: 'christophe@hurpeau.com',
'chris-reviewflow': 'christophe.hurpeau+reviewflow@gmail.com',
},
},
// parsePR: ornikarconfig.parsePR,
};
export default config;
19 changes: 6 additions & 13 deletions src/accountConfigs/types.ts
Expand Up @@ -14,7 +14,6 @@ export type Group = Record<string, string | null>;

export interface Team {
githubTeamName?: string;
logins: string[];
labels?: string[];
}

Expand Down Expand Up @@ -46,23 +45,20 @@ export interface LabelDescriptor {
color: string;
}

export type GroupLabels =
export type ReviewLabels =
| 'needsReview'
| 'requested'
| 'changesRequested'
| 'approved';

export type ReviewConfig<GroupNames extends string> = Record<
GroupNames,
Record<GroupLabels, string>
>;
export type ReviewConfig = Record<ReviewLabels, string>;

export type LabelList = Record<string, LabelDescriptor>;

export interface LabelsConfig<GroupNames extends string> {
export interface LabelsConfig {
legacyToRemove?: LabelList;
list: LabelList;
review: ReviewConfig<GroupNames>;
review?: ReviewConfig;
}

interface ExperimentalFeatures {
Expand All @@ -75,7 +71,7 @@ interface WarnOnForcePushAfterReviewStarted {
message: string;
}

export interface Config<GroupNames extends string, TeamNames extends string> {
export interface Config<TeamNames extends string> {
autoAssignToCreator?: boolean;
trimTitle?: boolean;
ignoreRepoPattern?: string;
Expand All @@ -90,11 +86,8 @@ export interface Config<GroupNames extends string, TeamNames extends string> {
prDefaultOptions: Options;

botUsers?: string[];
groups: Record<GroupNames, Group>;
groupsGithubTeams?: Record<GroupNames, string[]>;
teams: Record<TeamNames, Team>;
waitForGroups?: Record<GroupNames, GroupNames[]>;

labels: LabelsConfig<GroupNames>;
labels: LabelsConfig;
defaultDmSettings?: Partial<Record<MessageCategory, boolean>>;
}
14 changes: 3 additions & 11 deletions src/app/org-settings.tsx
Expand Up @@ -3,7 +3,7 @@ import type { Router } from 'express';
import type { ProbotOctokit } from 'probot';
import { renderToStaticMarkup } from 'react-dom/server';
import { accountConfigs } from '../accountConfigs';
import { getTeamsAndGroups } from '../context/accountContext';
import { getTeams } from '../context/accountContext';
import type { MessageCategory } from '../dm/MessageCategory';
import { getUserDmSettings, updateCache } from '../dm/getUserDmSettings';
import { syncOrg } from '../events/account-handlers/actions/syncOrg';
Expand Down Expand Up @@ -144,9 +144,7 @@ export default function orgSettings(
}),
getUserDmSettings(mongoStores, org.login, org.id, user.authInfo.id),
]);
const teamsAndGroups = orgMember
? getTeamsAndGroups(accountConfig, orgMember)
: { groupName: undefined, teamNames: [] };
const teams = orgMember ? getTeams(accountConfig, orgMember) : [];

res.send(
renderToStaticMarkup(
Expand Down Expand Up @@ -218,13 +216,7 @@ export default function orgSettings(
<>User not found in database</>
) : (
<>
<div>
Group Name: {teamsAndGroups.groupName || 'No groups'}
</div>
<div>
Team Names:{' '}
{teamsAndGroups.teamNames.join(', ') || 'No teams'}
</div>
<div>Team Names: {teams.join(', ') || 'No teams'}</div>
<div>
Github Teams:{' '}
{orgMember.teams
Expand Down

0 comments on commit 94e7201

Please sign in to comment.