Skip to content

Commit

Permalink
chore(dependabot): setup dependabot + bot update
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed Jun 13, 2023
1 parent 88063df commit 0c0e605
Show file tree
Hide file tree
Showing 20 changed files with 279 additions and 409 deletions.
24 changes: 24 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2

updates:
# Enable version updates for npm
- package-ecosystem: "npm"
# Look for `package.json` and `lock` files in the `root` directory
directory: "/"
# Check the npm registry for updates every day (weekdays)
schedule:
interval: "weekly"
day: "monday"
labels:
- "dependabot"
- "dependencies"

# Do we need to declare each package.json :scream: ?
# - package-ecosystem: "npm"
# directory: "apps/ledger-live-desktop"
# schedule:
# interval: "weekly"
# day: "monday"
# labels:
# - "dependabot"
# - "dependencies"
10 changes: 0 additions & 10 deletions apps/ledger-live-desktop/.dependabot/config.yml

This file was deleted.

12 changes: 0 additions & 12 deletions tools/github-bot/.dockerignore

This file was deleted.

8 changes: 0 additions & 8 deletions tools/github-bot/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions tools/github-bot/src/commands/generate-screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function generateScreenshots(app: Probot) {
});
});

app.on("check_run.requested_action", async (context) => {
app.on("check_run.requested_action", async context => {
const { payload } = context;

if (payload.requested_action.identifier !== ACTION_ID) return;
Expand All @@ -83,7 +83,7 @@ export function generateScreenshots(app: Probot) {
description:
"Regenerates playwright screenshots for the Live Desktop app and commit the changes.",
summaryFile: "summary.json",
getInputs: (payload) => ({
getInputs: payload => ({
ref: payload.check_run.head_sha,
login: payload.sender.login,
}),
Expand Down
4 changes: 2 additions & 2 deletions tools/github-bot/src/commands/regen-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function regenDoc(app: Probot) {
});
});

app.on("check_run.requested_action", async (context) => {
app.on("check_run.requested_action", async context => {
const { payload } = context;

if (payload.requested_action.identifier !== ACTION_ID) return;
Expand All @@ -83,7 +83,7 @@ export function regenDoc(app: Probot) {
checkRunName: "@Libs • Regen Doc Files",
description: "Regenerates documentation files for LedgerJS libraries",
summaryFile: "summary.json",
getInputs: (payload) => ({
getInputs: payload => ({
ref: payload.check_run.head_sha,
login: payload.sender.login,
}),
Expand Down
4 changes: 2 additions & 2 deletions tools/github-bot/src/commands/regen-pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function regenPods(app: Probot) {
});
});

app.on("check_run.requested_action", async (context) => {
app.on("check_run.requested_action", async context => {
const { payload } = context;

if (payload.requested_action.identifier !== ACTION_ID) return;
Expand All @@ -83,7 +83,7 @@ export function regenPods(app: Probot) {
checkRunName: "@Mobile • Regen Pods",
description: "Regenerates iOS podlock file",
summaryFile: "summary.json",
getInputs: (payload) => ({
getInputs: payload => ({
ref: payload.check_run.head_sha,
login: payload.sender.login,
}),
Expand Down
6 changes: 3 additions & 3 deletions tools/github-bot/src/commands/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export const commands = (
name: string;
arguments?: string;
commentId?: number;
}
) => {}
},
) => Promise<void>,
) => {
const matcher = /^\/([\w-]+)\b *(.*)?$/m;

app.on(["issue_comment.created" /*, "issues.opened" */], async (context) => {
app.on(["issue_comment.created"], async context => {
if (context.isBot) return;

const { payload, octokit } = context;
Expand Down
14 changes: 6 additions & 8 deletions tools/github-bot/src/features/autoClose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isValidBody, isValidBranchName, isValidUser } from "./tools";
* @param app The Probot application.
*/
export function autoClose(app: Probot) {
app.on(["pull_request.opened", "pull_request.reopened"], async (context) => {
app.on(["pull_request.opened", "pull_request.reopened"], async context => {
const { payload, octokit } = context;
const repository = context.repo();

Expand All @@ -19,11 +19,10 @@ export function autoClose(app: Probot) {
if (
!isValidUser(login) &&
// Close automatic PRs from smartling - except the ones triggered manually
!/^(smartling-content-updated|smartling-translation-completed)-.+/.test(
branch
)
)
!/^(smartling-content-updated|smartling-translation-completed)-.+/.test(branch)
) {
return;
}

const isBranchValid = isValidBranchName(branch);
const isBodyValid = isValidBody(payload.pull_request.body);
Expand All @@ -40,8 +39,6 @@ export function autoClose(app: Probot) {
"\n" +
"Found Issues:\n";

let comment;

if (!isBranchValid) {
body += `- _the branch name \`${branch}\` is invalid_\n`;
}
Expand All @@ -52,7 +49,8 @@ export function autoClose(app: Probot) {
body +=
"_💡 make sure you added comments only inside the template sections - and not above the `📝 Description` heading_\n";
}
comment = context.issue({

const comment = context.issue({
body,
});

Expand Down
13 changes: 3 additions & 10 deletions tools/github-bot/src/features/autoClose/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ export const isValidBranchName = (branch: string): boolean =>
["release", "hotfix"].includes(branch);

export const isValidUser = (user: string): boolean =>
![
"ledgerlive",
"live-github-bot[bot]",
"github-actions[bot]",
"dependabot[bot]",
].includes(user);
!["ledgerlive", "live-github-bot[bot]", "github-actions[bot]", "dependabot[bot]"].includes(user);

export const isValidBody = (body: string | null): boolean => {
if (!body) return false;
Expand All @@ -34,9 +29,7 @@ export const isValidBody = (body: string | null): boolean => {
};
}

const headingIndex = requiredHeadings.findIndex((heading) =>
line.startsWith(heading)
);
const headingIndex = requiredHeadings.findIndex(heading => line.startsWith(heading));
// Template required heading is still in the body.
if (headingIndex > -1) {
acc.matchHeadings[headingIndex] = true;
Expand All @@ -48,7 +41,7 @@ export const isValidBody = (body: string | null): boolean => {
{
dummyDescription: false,
matchHeadings: requiredHeadings.map(() => false),
}
},
);

return !results.dummyDescription && results.matchHeadings.every(Boolean);
Expand Down
6 changes: 3 additions & 3 deletions tools/github-bot/src/features/lintCommits/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function lintCommits(app: Probot) {
// …even though the docs say that it's supposed to be .synchronize, it's not.
"pull_request.edited",
],
async (context) => {
async context => {
const { payload, octokit } = context;
const { owner, repo } = context.repo();
const login = payload.sender.login;
Expand All @@ -35,7 +35,7 @@ export function lintCommits(app: Probot) {
login: login,
},
});
}
},
);

monitorWorkflow(app, {
Expand All @@ -44,7 +44,7 @@ export function lintCommits(app: Probot) {
description:
"Lint the Pull Request commit messages according to the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.",
summaryFile: "summary.json",
getInputs: (payload) => ({
getInputs: payload => ({
ref: payload.check_run.head_sha,
from: payload.check_run.pull_requests[0]?.base.ref,
login: payload.sender.login,
Expand Down
46 changes: 14 additions & 32 deletions tools/github-bot/src/features/orchestrator/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export type PullRequestMetadata = {
base_owner: string;
is_fork: boolean;
};
export type CheckSuite = Awaited<
ReturnType<Octokit["checks"]["getSuite"]>
>["data"];
export type CheckSuite = Awaited<ReturnType<Octokit["checks"]["getSuite"]>>["data"];

export const SYNC_ACTION = "sync_action";
export const REPO_OWNER = "LedgerHQ";
Expand All @@ -30,19 +28,14 @@ export enum RUNNERS {
const commonGetInputs = (
payload: GetInputsPayload,
metadata?: PullRequestMetadata,
localRef?: string
localRef?: string,
) => {
return "workflow_run" in payload
? {
login: payload.workflow_run.actor.login,
ref:
localRef ??
metadata?.head_branch ??
payload.workflow_run.pull_requests[0]?.head.ref,
ref: localRef ?? metadata?.head_branch ?? payload.workflow_run.pull_requests[0]?.head.ref,
base_ref:
metadata?.base_branch ||
payload.workflow_run.pull_requests[0]?.base.ref ||
"develop",
metadata?.base_branch || payload.workflow_run.pull_requests[0]?.base.ref || "develop",
}
: {
login: payload.sender.login,
Expand All @@ -63,7 +56,7 @@ export const WORKFLOWS = {
payload: GetInputsPayload,
metadata?: PullRequestMetadata,
localRef?: string,
draft?: boolean
draft?: boolean,
) => {
const common = commonGetInputs(payload, metadata, localRef);
return { ...common, draft };
Expand All @@ -81,7 +74,7 @@ export const WORKFLOWS = {
payload: GetInputsPayload,
metadata?: PullRequestMetadata,
localRef?: string,
draft?: boolean
draft?: boolean,
) => {
const common = commonGetInputs(payload, metadata, localRef);
return { ...common, draft };
Expand All @@ -99,7 +92,7 @@ export const WORKFLOWS = {
payload: GetInputsPayload,
metadata?: PullRequestMetadata,
localRef?: string,
draft?: boolean
draft?: boolean,
) => {
const common = commonGetInputs(payload, metadata, localRef);
return { ...common, draft };
Expand All @@ -117,16 +110,15 @@ export const WORKFLOWS = {
payload: GetInputsPayload,
metadata?: PullRequestMetadata,
localRef?: string,
draft?: boolean
draft?: boolean,
) => {
const common = commonGetInputs(payload, metadata, localRef);
return { ...common, draft };
},
},
"build-mobile.yml": {
checkRunName: "@Mobile • Build App",
description:
"Build the Ledger Live Mobile application and attach the apk to the workflow run.",
description: "Build the Ledger Live Mobile application and attach the apk to the workflow run.",
runsOn: RUNNERS.internal,
required: true,
affected: ["live-mobile"],
Expand All @@ -135,8 +127,7 @@ export const WORKFLOWS = {
},
"build-mobile-external.yml": {
checkRunName: "@Mobile • Build App (external)",
description:
"Build the Ledger Live Mobile application and attach the apk to the workflow run.",
description: "Build the Ledger Live Mobile application and attach the apk to the workflow run.",
runsOn: RUNNERS.external,
required: true,
affected: ["live-mobile"],
Expand Down Expand Up @@ -169,28 +160,19 @@ export const WORKFLOWS = {
required: true,
affected: [/^libs\/.*/],
summaryFile: "summary.json",
getInputs: (
payload: GetInputsPayload,
metadata?: PullRequestMetadata,
localRef?: string
) => {
getInputs: (payload: GetInputsPayload, metadata?: PullRequestMetadata, localRef?: string) => {
return "workflow_run" in payload
? {
login: payload.workflow_run.actor.login,
ref:
localRef ??
metadata?.head_branch ??
payload.workflow_run.pull_requests[0]?.head.ref,
localRef ?? metadata?.head_branch ?? payload.workflow_run.pull_requests[0]?.head.ref,
since_branch:
metadata?.base_branch ||
payload.workflow_run.pull_requests[0]?.base.ref ||
"develop",
metadata?.base_branch || payload.workflow_run.pull_requests[0]?.base.ref || "develop",
}
: {
login: payload.sender.login,
ref: payload.check_run.pull_requests[0]?.head.ref,
since_branch:
payload.check_run.pull_requests[0]?.base.ref || "develop",
since_branch: payload.check_run.pull_requests[0]?.base.ref || "develop",
};
},
},
Expand Down
Loading

0 comments on commit 0c0e605

Please sign in to comment.