Skip to content

Commit 34715fe

Browse files
author
Michael Brewer
authored
Merge branch 'develop' into fix/1203-child-exceptions
2 parents f79ed5b + 2bd8722 commit 34715fe

15 files changed

+322
-78
lines changed

.github/workflows/auto-merge.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: auto-merge
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
dependabot:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.actor == 'dependabot[bot]' }}
14+
steps:
15+
- name: Dependabot metadata
16+
id: metadata
17+
uses: dependabot/[email protected]
18+
with:
19+
github-token: "${{ secrets.GITHUB_TOKEN }}"
20+
- name: Enable auto-merge for mypy-boto3 stubs Dependabot PRs
21+
if: ${{contains(steps.metadata.outputs.dependency-names, 'mypy-boto3')}} # && steps.metadata.outputs.update-type == 'version-update:semver-patch'
22+
run: gh pr merge --auto --squash "$PR_URL"
23+
env:
24+
PR_URL: ${{github.event.pull_request.html_url}}
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
record_pr_workflow_id:
5+
required: true
6+
type: number
7+
secrets:
8+
token:
9+
required: true
10+
# Map the workflow outputs to job outputs
11+
outputs:
12+
prNumber:
13+
description: "The first output string"
14+
value: ${{ jobs.export_pr_details.outputs.prNumber }}
15+
prTitle:
16+
description: "The second output string"
17+
value: ${{ jobs.export_pr_details.outputs.prTitle }}
18+
prBody:
19+
description: "The second output string"
20+
value: ${{ jobs.export_pr_details.outputs.prBody }}
21+
prAuthor:
22+
description: "The second output string"
23+
value: ${{ jobs.export_pr_details.outputs.prAuthor }}
24+
prAction:
25+
description: "The second output string"
26+
value: ${{ jobs.export_pr_details.outputs.prAction }}
27+
28+
name: Export Pull Request details from fork
29+
jobs:
30+
export_pr_details:
31+
runs-on: ubuntu-latest
32+
# Map the job outputs to step outputs
33+
outputs:
34+
prNumber: ${{ steps.prNumber.outputs.prNumber }}
35+
prTitle: ${{ steps.prTitle.outputs.prTitle }}
36+
prBody: ${{ steps.prBody.outputs.prBody }}
37+
prAuthor: ${{ steps.prAuthor.outputs.prAuthor }}
38+
prAction: ${{ steps.prAction.outputs.prAction }}
39+
steps:
40+
- name: "Download artifact"
41+
uses: actions/github-script@v6
42+
# For security, we only download artifacts tied to the successful PR recording workflow
43+
with:
44+
github-token: ${{ inputs.token }}
45+
script: |
46+
const fs = require('fs');
47+
48+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
run_id: ${{inputs.record_pr_workflow_id}},
52+
});
53+
54+
const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0];
55+
56+
const artifact = await github.rest.actions.downloadArtifact({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
artifact_id: matchArtifact.id,
60+
archive_format: 'zip',
61+
});
62+
63+
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(artifact.data));
64+
# NodeJS standard library doesn't provide ZIP capabilities; use system `unzip` command instead
65+
- run: unzip pr.zip
66+
- id: prNumber
67+
run: echo ::set-output name=prNumber::$(cat ./number)
68+
- id: prTitle
69+
run: echo ::set-output name=prTitle::$(cat ./title)
70+
- id: prBody
71+
run: echo ::set-output name=prBody::$(cat ./body)
72+
- id: prAuthor
73+
run: echo ::set-output name=prAuthor::$(cat ./author)
74+
- id: prAction
75+
run: echo ::set-output name=prAction::$(cat ./action)
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Closed Issue Message
2+
on:
3+
issues:
4+
types: [closed]
5+
jobs:
6+
auto_comment:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: aws-actions/closed-issue-message@v1
10+
with:
11+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
12+
message: "Comments on closed issues are hard for our team to see."

.github/workflows/on_merged_pr.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
on:
2+
pull_request:
3+
types:
4+
- closed
5+
6+
env:
7+
RELEASE_LABEL: "pending-release"
8+
MAINTAINERS_TEAM: "@awslabs/aws-lambda-powertools-python"
9+
10+
jobs:
11+
release_label_on_merge:
12+
if: github.event.pull_request.merged == true && github.event.pull_request.user.login != 'dependabot[bot]'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: "Label PR related issue for release"
16+
uses: actions/github-script@v6
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
script: |
20+
const prBody = context.payload.body;
21+
const prNumber = context.payload.number;
22+
const releaseLabel = process.env.RELEASE_LABEL;
23+
24+
const RELATED_ISSUE_REGEX = /Issue number:.+(\d)/
25+
26+
const matcher = new RegExp(RELATED_ISSUE_REGEX)
27+
const isMatch = matcher.exec(prBody)
28+
if (isMatch != null) {
29+
let relatedIssueNumber = isMatch[1]
30+
console.info(`Auto-labeling related issue ${relatedIssueNumber} for release`)
31+
32+
await github.rest.issues.addLabels({
33+
issue_number: relatedIssueNumber,
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
labels: [releaseLabel]
37+
})
38+
} else {
39+
let msg = `${MAINTAINERS_TEAM} No related issues found. Please ensure '${RELEASE_LABEL}.' label is applied before releasing.`;
40+
await github.rest.issues.createComment({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
body: msg,
44+
issue_number: prNumber,
45+
});
46+
}

.github/workflows/on_opened_pr.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
on:
2+
workflow_run:
3+
workflows: ["Record PR number"]
4+
types:
5+
- completed
6+
7+
env:
8+
BLOCK_LABEL: "do-not-merge"
9+
BLOCK_REASON_LABEL: "need-issue"
10+
11+
jobs:
12+
get_pr_details:
13+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
14+
uses: ./.github/workflows/export_pr_details.yml
15+
with:
16+
record_pr_workflow_id: ${{ github.event.workflow_run.id }}
17+
secrets:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
check_related_issue:
20+
needs: get_pr_details
21+
if: >
22+
${{ needs.get_pr_details.outputs.prAuthor != 'dependabot[bot]' &&
23+
needs.get_pr_details.outputs.prAction == 'opened'
24+
}}
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: "Ensure related issue is present"
28+
uses: actions/github-script@v6
29+
with:
30+
# Maintenance: convert into a standalone JS like post_release.js
31+
script: |
32+
const prBody = ${{ needs.get_pr_details.outputs.prBody }};
33+
const prNumber = ${{ needs.get_pr_details.outputs.prNumber }};
34+
const blockLabel = process.env.BLOCK_LABEL;
35+
const blockReasonLabel = process.env.BLOCK_REASON_LABEL;
36+
37+
const RELATED_ISSUE_REGEX = /Issue number:.+(\d)/
38+
39+
const matcher = new RegExp(RELATED_ISSUE_REGEX)
40+
const isMatch = matcher.exec(prBody)
41+
if (isMatch == null) {
42+
console.info(`No related issue found, maybe the author didn't use the template but there is one.`)
43+
44+
let msg = `⚠️ No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure. ⚠️`;
45+
await github.rest.issues.createComment({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
body: msg,
49+
issue_number: prNumber,
50+
});
51+
52+
await github.rest.issues.addLabels({
53+
issue_number: prNumber,
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
labels: [blockLabel, blockReasonLabel]
57+
})
58+
}

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
with:
4949
fetch-depth: 0
5050
- name: Set up Python
51-
uses: actions/setup-python@v3
51+
uses: actions/setup-python@v4
5252
with:
5353
python-version: "3.8"
5454
- name: Set release notes tag

.github/workflows/python_build.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ name: Code quality
22

33
on:
44
pull_request:
5+
paths:
6+
- "aws_lambda_powertools/**"
7+
- "tests/**"
8+
- "pyproject.toml"
9+
- "poetry.lock"
10+
- "mypy.ini"
511
branches:
612
- develop
713
- master
814
push:
15+
paths:
16+
- "aws_lambda_powertools/**"
17+
- "tests/**"
18+
- "pyproject.toml"
19+
- "poetry.lock"
20+
- "mypy.ini"
921
branches:
1022
- develop
1123
- master
@@ -23,7 +35,7 @@ jobs:
2335
steps:
2436
- uses: actions/checkout@v3
2537
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v3
38+
uses: actions/setup-python@v4
2739
with:
2840
python-version: ${{ matrix.python-version }}
2941
- name: Install dependencies

.github/workflows/python_docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919
- name: Set up Python
20-
uses: actions/setup-python@v3
20+
uses: actions/setup-python@v4
2121
with:
2222
python-version: "3.8"
2323
- name: Install dependencies

.github/workflows/rebuild_latest_docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
fetch-depth: 0
2727
- name: Set up Python
28-
uses: actions/setup-python@v3
28+
uses: actions/setup-python@v4
2929
with:
3030
python-version: "3.8"
3131
- name: Set release notes tag

.github/workflows/record_pr.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
mkdir -p ./pr
1616
echo ${{ github.event.number }} > ./pr/number
1717
echo "${{ github.event.pull_request.title }}" > ./pr/title
18+
echo "${{ github.event.pull_request.body }}" > ./pr/body
19+
echo "${{ github.event.pull_request.user.login }}" > ./pr/author
20+
echo "${{ github.event.action }}" > ./pr/action
1821
- uses: actions/upload-artifact@v3
1922
with:
2023
name: pr

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,5 @@ api/
304304
site/
305305
!404.html
306306
!docs/overrides/*.html
307+
308+
!.github/workflows/lib

0 commit comments

Comments
 (0)