Skip to content

Commit 218e0b1

Browse files
committed
chore: update pr, issue, and release automation
1 parent 0171735 commit 218e0b1

File tree

8 files changed

+341
-79
lines changed

8 files changed

+341
-79
lines changed

.github/boring-cyborg.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
##### Labeler ##########################################################################################################
2+
labelPRBasedOnFilePath:
3+
area/logger:
4+
- packages/logger/src/*
5+
- packages/logger/src/**/*
6+
area/tracer:
7+
- packages/tracer/src/*
8+
- packages/tracer/src/**/*
9+
area/metrics:
10+
- packages/metrics/src/*
11+
- packages/metrics/src/**/*
12+
area/idempotency:
13+
- packages/idempotency/src/*
14+
- packages/idempotency/src/**/*
15+
area/parameters:
16+
- packages/parameters/src/*
17+
- packages/parameters/src/**/*
18+
area/parser:
19+
- packages/parser/src/*
20+
- packages/parser/src/**/*
21+
area/validator:
22+
- packages/validator/src/*
23+
- packages/validator/src/**/*
24+
area/batch:
25+
- packages/batch/src/*
26+
- packages/batch/src/**/*
27+
area/commons:
28+
- packages/commons/src/*
29+
- packages/commons/src/**/*
30+
area/layers:
31+
- layers/src/*
32+
- layers/src/**/*
33+
- layers/bin/*
34+
- layers/cdk.json
35+
36+
type/tests:
37+
- packages/logger/tests/*
38+
- packages/logger/tests/**/*
39+
- packages/logger/jest.config.js
40+
- packages/tracer/tests/*
41+
- packages/tracer/tests/**/*
42+
- packages/tracer/jest.config.js
43+
- packages/metrics/tests/*
44+
- packages/metrics/tests/**/*
45+
- packages/metrics/jest.config.js
46+
- packages/idempotency/tests/*
47+
- packages/idempotency/tests/**/*
48+
- packages/idempotency/jest.config.js
49+
- packages/parameters/tests/*
50+
- packages/parameters/tests/**/*
51+
- packages/parameters/jest.config.js
52+
- packages/parser/tests/*
53+
- packages/parser/tests/**/*
54+
- packages/parser/jest.config.js
55+
- packages/validator/tests/*
56+
- packages/validator/tests/**/*
57+
- packages/validator/jest.config.js
58+
- packages/batch/tests/*
59+
- packages/batch/tests/**/*
60+
- packages/batch/jest.config.js
61+
- packages/commons/tests/*
62+
- packages/commons/tests/**/*
63+
- packages/commons/jest.config.js
64+
- layers/jest.config.js
65+
- layers/tests/*
66+
- layers/tests/**/*
67+
68+
area/documentation:
69+
- docs/*
70+
- docs/**/*
71+
- mkdocs.yml
72+
- typedoc.js
73+
- examples/cdk/bin/*
74+
- examples/cdk/functions/*
75+
- examples/cdk/functions/**/*
76+
- examples/cdk/src/*
77+
- examples/cdk/src/**/*
78+
- examples/cdk/tests/*
79+
- examples/cdk/tests/**/*
80+
- examples/cdk/README.md
81+
- examples/cdk/cdk.json
82+
- examples/sam/events/*
83+
- examples/sam/src/*
84+
- examples/sam/src/**/*
85+
- examples/sam/tests/*
86+
- examples/sam/tests/**/*
87+
- examples/sam/README.md
88+
- examples/sam/template.yaml
89+
90+
area/automation:
91+
- .github/scripts/*
92+
- .github/scripts/**/*
93+
- .github/workflows/*
94+
- .github/workflows/**/*
95+
- .github/release-drafter.yml
96+
- .github/boring-cyborg.yml
97+
- .github/semantic.yml
98+
99+
type/internal:
100+
- .github/CODEOWNERS
101+
- .github/PULL_REQUEST_TEMPLATE.md
102+
- .github/ISSUE_TEMPLATE/*
103+
- CONTRIBUTING.md
104+
- MAINTAINERS.md
105+
- CODE_OF_CONDUCT.md
106+
- SECURITY.md
107+
- LICENSE
108+
- LICENSE-THIRD-PARTY
109+
- lerna.json
110+
- .nvmrc
111+
- .eslintrc.js
112+
- .eslintignore
113+
- .npmignore
114+
- .gitpod.yml
115+
- .husky/*
116+
- .devcontainer/*
117+
- packages/logger/tsconfig*.json
118+
- packages/logger/README.md
119+
- packages/metrics/tsconfig*.json
120+
- packages/metrics/README.md
121+
- packages/tracer/tsconfig*.json
122+
- packages/tracer/README.md
123+
- packages/parser/tsconfig*.json
124+
- packages/parser/README.md
125+
- packages/idempotency/tsconfig*.json
126+
- packages/idempotency/README.md
127+
- packages/batch/tsconfig*.json
128+
- packages/batch/README.md
129+
- packages/commons/tsconfig*.json
130+
- packages/commons/README.md
131+
- packages/validator/tsconfig*.json
132+
- packages/validator/README.md
133+
- packages/parser/tsconfig*.json
134+
- packages/parser/README.md
135+
- layers/tsconfig*.json
136+
- layers/README.md
137+
- examples/sam/tsconfig*.json
138+
- examples/cdk/tsconfig*.json
139+
140+
type/dependencies:
141+
- package.json
142+
- package-lock.json
143+
- packages/tracer/package.json
144+
- packages/metrics/package.json
145+
- packages/logger/package.json
146+
- packages/commons/package.json
147+
- packages/parameters/package.json
148+
- packages/idempotency/package.json
149+
- packages/parser/package.json
150+
- packages/validator/package.json
151+
- packages/batch/package.json
152+
- layers/package.json
153+
- examples/cdk/package.json
154+
- examples/sam/package.json
155+
156+
##### Greetings ########################################################################################################
157+
firstPRWelcomeComment: >
158+
Thanks a lot for your first contribution! Please check out our [contributing guidelines](https://github.com/awslabs/aws-lambda-powertools-typescript/blob/chore/pr_automation/CONTRIBUTING.md) and don't hesitate to ask whatever you need.
159+
160+
In the meantime, check out the #typescript channel on our AWS Lambda Powertools Discord: [Invite link](https://discord.gg/B8zZKbbyET)
161+
162+
# Comment to be posted to congratulate user on their first merged PR
163+
firstPRMergeComment: >
164+
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!
165+
166+
# Comment to be posted to on first time issues
167+
firstIssueWelcomeComment: >
168+
Thanks for opening your first issue here! We'll come back to you as soon as we can.
169+
170+
In the meantime, check out the #typescript channel on our AWS Lambda Powertools Discord: [Invite link](https://discord.gg/B8zZKbbyET)

.github/scripts/constants.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ module.exports = Object.freeze({
3636
/** @type {string[]} */
3737
"IGNORE_AUTHORS": ["dependabot[bot]"],
3838

39-
/** @type {string[]} */
40-
"AREAS": [
41-
"tracer",
42-
"metrics",
43-
"logger",
44-
],
39+
/** @type {RegExp} */
40+
"RELATED_ISSUE_REGEX": /\bIssue number:(?<closingWord>:closes?|close|fix|fixes?|fixed|resolves?|resolved)?\s*#(?<issue>\d+)\b/
4541
});

.github/scripts/label_missing_related_issue.js

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,64 @@ const {
55
PR_NUMBER,
66
IGNORE_AUTHORS,
77
LABEL_BLOCK,
8-
LABEL_BLOCK_REASON
8+
LABEL_BLOCK_REASON,
9+
RELATED_ISSUE_REGEX,
910
} = require("./constants");
1011

11-
module.exports = async ({github, context, core}) => {
12-
if (IGNORE_AUTHORS.includes(PR_AUTHOR)) {
13-
return core.notice("Author in IGNORE_AUTHORS list; skipping...");
14-
}
12+
module.exports = async ({ github, context, core }) => {
13+
if (IGNORE_AUTHORS.includes(PR_AUTHOR)) {
14+
return core.notice("Author in IGNORE_AUTHORS list; skipping...");
15+
}
1516

16-
if (PR_ACTION != "opened") {
17-
return core.notice("Only newly open PRs are labelled to avoid spam; skipping");
18-
}
17+
if (
18+
["opened", "edited", "ready_for_review", "reopened"].includes(PR_ACTION)
19+
) {
20+
return core.notice(
21+
"Only newly opened or updated PRs are labelled to avoid spam; skipping"
22+
);
23+
}
24+
25+
const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY);
26+
if (isMatch == null) {
27+
core.info(
28+
`No related issue found, maybe the author didn't use the template but there is one.`
29+
);
1930

20-
const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?<issue>\d+)/;
21-
const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY);
22-
if (isMatch == null) {
23-
core.info(`No related issue found, maybe the author didn't use the template but there is one.`);
31+
let msg =
32+
"No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure.";
33+
await github.rest.issues.createComment({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
body: msg,
37+
issue_number: PR_NUMBER,
38+
});
2439

25-
let msg = "No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure.";
26-
await github.rest.issues.createComment({
27-
owner: context.repo.owner,
28-
repo: context.repo.repo,
29-
body: msg,
30-
issue_number: PR_NUMBER,
31-
});
40+
return await github.rest.issues.addLabels({
41+
issue_number: PR_NUMBER,
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
labels: [LABEL_BLOCK, LABEL_BLOCK_REASON],
45+
});
46+
} else {
47+
const { closingWord, issue } = isMatch.groups;
48+
if (closingWord == null) {
49+
core.info(
50+
`Found related issue #${issue} without closing word, adding one...`
51+
);
52+
// Add closing word to the PR body
53+
const msg = `Issue number: closes ${issue}`;
54+
const updatedPRBody = PR_BODY.replace(RELATED_ISSUE_REGEX, msg);
3255

33-
return await github.rest.issues.addLabels({
34-
issue_number: PR_NUMBER,
35-
owner: context.repo.owner,
36-
repo: context.repo.repo,
37-
labels: [LABEL_BLOCK, LABEL_BLOCK_REASON]
38-
});
56+
await github.rest.issues.update({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
body: updatedPRBody,
60+
issue_number: PR_NUMBER,
61+
});
62+
} else {
63+
core.info(
64+
`Found related issue #${issue} with closing word '${closingWord}'`
65+
);
3966
}
40-
}
67+
}
68+
};

.github/scripts/label_pr_based_on_title.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ const { PR_NUMBER, PR_TITLE } = require("./constants");
33
module.exports = async ({github, context, core}) => {
44
const BUG_REGEX = /(fix|bug)(\((.+)\))?(:.+)/
55
const FEAT_REFACTOR_REGEX = /(feat|refactor)(\((.+)\))?(:.+)/
6-
const DOCS_REGEX = /(docs|doc)(\((.+)\))?(:.+)/
76
const CHORE_REGEX = /(chore)(\((.+)\))?(:.+)/
87
const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(:.+)/
98

109
const labels = {
1110
"type/feature": FEAT_REFACTOR_REGEX,
1211
"type/bug": BUG_REGEX,
13-
"area/documentation": DOCS_REGEX,
1412
"type/internal": CHORE_REGEX,
1513
"type/deprecation": DEPRECATED_REGEX,
1614
}

0 commit comments

Comments
 (0)