Skip to content

Commit f665b87

Browse files
author
Michal Ploski
committed
Merge branch 'develop' into docs/quick-start
2 parents 9f4ee51 + 0c6ac0f commit f665b87

File tree

86 files changed

+6093
-2653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+6093
-2653
lines changed

.github/boring-cyborg.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
##### Labeler ##########################################################################################################
22
labelPRBasedOnFilePath:
3-
area/utilities:
4-
- aws_lambda_powertools/utilities/*
5-
- aws_lambda_powertools/utilities/**/*
6-
- aws_lambda_powertools/middleware_factory/*
7-
- aws_lambda_powertools/middleware_factory/**/*
83
area/logger:
94
- aws_lambda_powertools/logging/*
105
- aws_lambda_powertools/logging/**/*
@@ -42,6 +37,13 @@ labelPRBasedOnFilePath:
4237
area/feature_flags:
4338
- aws_lambda_powertools/feature_flags/*
4439
- aws_lambda_powertools/feature_flags/**/*
40+
area/jmespath_util:
41+
- aws_lambda_powertools/utilities/jmespath_utils/*
42+
area/utilities:
43+
- aws_lambda_powertools/utilities/*
44+
- aws_lambda_powertools/utilities/**/*
45+
- aws_lambda_powertools/middleware_factory/*
46+
- aws_lambda_powertools/middleware_factory/**/*
4547

4648
documentation:
4749
- docs/*
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Label PR based on title
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Record PR number"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
upload:
11+
runs-on: ubuntu-latest
12+
# Guardrails to only ever run if PR recording workflow was indeed
13+
# run in a PR event and ran successfully
14+
if: >
15+
${{ github.event.workflow_run.event == 'pull_request' &&
16+
github.event.workflow_run.conclusion == 'success' }}
17+
steps:
18+
- name: 'Download artifact'
19+
uses: actions/github-script@v5
20+
# For security, we only download artifacts tied to the successful PR recording workflow
21+
with:
22+
script: |
23+
const fs = require('fs');
24+
25+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
run_id: ${{github.event.workflow_run.id }},
29+
});
30+
31+
const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0];
32+
33+
const artifact = await github.rest.actions.downloadArtifact({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
artifact_id: matchArtifact.id,
37+
archive_format: 'zip',
38+
});
39+
40+
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(artifact.data));
41+
# NodeJS standard library doesn't provide ZIP capabilities; use system `unzip` command instead
42+
- run: unzip pr.zip
43+
44+
- name: 'Label PR based on title'
45+
uses: actions/github-script@v5
46+
with:
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
# This safely runs in our base repo, not on fork
49+
# thus allowing us to provide a write access token to label based on PR title
50+
# and label PR based on semantic title accordingly
51+
script: |
52+
const fs = require('fs');
53+
const pr_number = Number(fs.readFileSync('./number'));
54+
const pr_title = fs.readFileSync('./title', 'utf-8').trim();
55+
56+
const FEAT_REGEX = /feat(\((\w+)\))?(\:.+)/
57+
const BUG_REGEX = /(fix|bug)(\((\w+)\))?(\:.+)/
58+
const DOCS_REGEX = /(docs|doc)(\((\w+)\))?(\:.+)/
59+
const CHORE_REGEX = /(chore)(\((\w+)\))?(\:.+)/
60+
const DEPRECATED_REGEX = /(deprecated)(\((\w+)\))?(\:.+)/
61+
const REFACTOR_REGEX = /(refactor)(\((\w+)\))?(\:.+)/
62+
63+
const labels = {
64+
"feature": FEAT_REGEX,
65+
"bug": BUG_REGEX,
66+
"documentation": DOCS_REGEX,
67+
"internal": CHORE_REGEX,
68+
"enhancement": REFACTOR_REGEX,
69+
"deprecated": DEPRECATED_REGEX,
70+
}
71+
72+
for (const label in labels) {
73+
const matcher = new RegExp(labels[label])
74+
const isMatch = matcher.exec(pr_title)
75+
if (isMatch != null) {
76+
console.info(`Auto-labeling PR ${pr_number} with ${label}`)
77+
78+
await github.rest.issues.addLabels({
79+
issue_number: pr_number,
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
labels: [label]
83+
})
84+
85+
break
86+
}
87+
}

.github/workflows/post_release.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
const STAGED_LABEL = "status/staged-next-release";
2+
3+
/**
4+
* Fetch issues using GitHub REST API
5+
*
6+
* @param {object} gh_client - Pre-authenticated REST client (Octokit)
7+
* @param {string} org - GitHub Organization
8+
* @param {string} repository - GitHub repository
9+
* @param {string} state - GitHub issue state (open, closed)
10+
* @param {string} label - Comma-separated issue labels to fetch
11+
* @return {Object[]} issues - Array of issues matching params
12+
* @see {@link https://octokit.github.io/rest.js/v18#usage|Octokit client}
13+
*/
14+
const fetchIssues = async ({
15+
gh_client,
16+
org,
17+
repository,
18+
state = "open",
19+
label = STAGED_LABEL,
20+
}) => {
21+
22+
try {
23+
const { data: issues } = await gh_client.rest.issues.listForRepo({
24+
owner: org,
25+
repo: repository,
26+
state: state,
27+
labels: label,
28+
});
29+
30+
return issues;
31+
32+
} catch (error) {
33+
console.error(error);
34+
throw new Error("Failed to fetch issues")
35+
}
36+
37+
};
38+
39+
/**
40+
* Notify new release and close staged GitHub issue
41+
*
42+
* @param {object} gh_client - Pre-authenticated REST client (Octokit)
43+
* @param {string} owner - GitHub Organization
44+
* @param {string} repository - GitHub repository
45+
* @param {string} release_version - GitHub Release version
46+
* @see {@link https://octokit.github.io/rest.js/v18#usage|Octokit client}
47+
*/
48+
const notifyRelease = async ({
49+
gh_client,
50+
owner,
51+
repository,
52+
release_version,
53+
}) => {
54+
const release_url = `https://github.com/${owner}/${repository}/releases/tag/v${release_version}`;
55+
56+
const issues = await fetchIssues({
57+
gh_client: gh_client,
58+
org: owner,
59+
repository: repository,
60+
});
61+
62+
issues.forEach(async (issue) => {
63+
console.info(`Updating issue number ${issue.number}`);
64+
65+
const comment = `This is now released under [${release_version}](${release_url}) version!`;
66+
try {
67+
await gh_client.rest.issues.createComment({
68+
owner: owner,
69+
repo: repository,
70+
body: comment,
71+
issue_number: issue.number,
72+
});
73+
} catch (error) {
74+
console.error(error);
75+
throw new Error(`Failed to update issue ${issue.number} about ${release_version} release`)
76+
}
77+
78+
79+
// Close issue and remove staged label; keep existing ones
80+
const labels = issue.labels
81+
.filter((label) => label.name != STAGED_LABEL)
82+
.map((label) => label.name);
83+
84+
try {
85+
await gh_client.rest.issues.update({
86+
repo: repository,
87+
owner: owner,
88+
issue_number: issue.number,
89+
state: "closed",
90+
labels: labels,
91+
});
92+
} catch (error) {
93+
console.error(error);
94+
throw new Error("Failed to close issue")
95+
}
96+
97+
console.info(`Issue number ${issue.number} closed and updated`);
98+
});
99+
};
100+
101+
// context: https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts
102+
module.exports = async ({ github, context }) => {
103+
const { RELEASE_TAG_VERSION } = process.env;
104+
console.log(`Running post-release script for ${RELEASE_TAG_VERSION} version`);
105+
106+
await notifyRelease({
107+
gh_client: github,
108+
owner: context.repo.owner,
109+
repository: context.repo.repo,
110+
release_version: RELEASE_TAG_VERSION,
111+
});
112+
};

.github/workflows/publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ name: Publish to PyPi
2222
# 8. Builds a fresh version of docs including Changelog updates
2323
# 9. Push latest release source code to master using release title as the commit message
2424
# 10. Builds latest documentation for new release, and update latest alias pointing to the new release tag
25+
# 11. Close and notify all issues labeled "status/staged-next-release" about the release details
2526

2627
#
2728
# === Fallback mechanism due to external failures ===
@@ -107,6 +108,12 @@ jobs:
107108
publish_dir: ./api
108109
keep_files: true
109110
destination_dir: latest/api
111+
- name: Close issues related to this release
112+
uses: actions/github-script@v5
113+
with:
114+
script: |
115+
const post_release = require('.github/workflows/post_release.js')
116+
await post_release({github, context, core})
110117
111118
sync_master:
112119
needs: release

.github/workflows/record_pr.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Record PR number
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Save PR number
14+
run: |
15+
mkdir -p ./pr
16+
echo ${{ github.event.number }} > ./pr/number
17+
echo "${{ github.event.pull_request.title }}" > ./pr/title
18+
- uses: actions/upload-artifact@v2
19+
with:
20+
name: pr
21+
path: pr/

.pre-commit-config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ repos:
1111
- id: trailing-whitespace
1212
- id: end-of-file-fixer
1313
- id: check-toml
14-
- repo: https://github.com/pre-commit/pygrep-hooks
15-
rev: v1.5.1
16-
hooks:
17-
- id: python-use-type-annotations
1814
- repo: local
1915
hooks:
2016
- id: black

CHANGELOG.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,82 @@ All notable changes to this project will be documented in this file.
55
This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format for changes and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77

8-
## [Unreleased]
8+
## 1.24.0 - 2021-12-31
9+
10+
### Bug Fixes
11+
12+
* **apigateway:** support [@app](https://github.com/app).not_found() syntax & housekeeping ([#926](https://github.com/awslabs/aws-lambda-powertools-python/issues/926))
13+
* **event-sources:** handle dynamodb null type as none, not bool ([#929](https://github.com/awslabs/aws-lambda-powertools-python/issues/929))
14+
* **warning:** future distutils deprecation in 3.12 ([#921](https://github.com/awslabs/aws-lambda-powertools-python/issues/921))
15+
16+
### Documentation
17+
18+
* **general**: consistency round admonitions and snippets ([#919](https://github.com/awslabs/aws-lambda-powertools-python/issues/919))
19+
* **homepage**: Added GraphQL Sample API to Examples section of README.md ([#930](https://github.com/awslabs/aws-lambda-powertools-python/issues/930))
20+
* **batch:** remove leftover from legacy
21+
* **layer:** bump Lambda Layer to version 6
22+
* **tracer:** new ignore_endpoint feature ([#931](https://github.com/awslabs/aws-lambda-powertools-python/issues/931))
23+
24+
### Features
25+
26+
* **event-sources:** cache parsed json in data class ([#909](https://github.com/awslabs/aws-lambda-powertools-python/issues/909))
27+
* **feature_flags:** support beyond boolean values (JSON values) ([#804](https://github.com/awslabs/aws-lambda-powertools-python/issues/804))
28+
* **idempotency:** support dataclasses & pydantic models payloads ([#908](https://github.com/awslabs/aws-lambda-powertools-python/issues/908))
29+
* **logger:** support use_datetime_directive for timestamps ([#920](https://github.com/awslabs/aws-lambda-powertools-python/issues/920))
30+
* **tracer:** ignore tracing for certain hostname(s) or url(s) ([#910](https://github.com/awslabs/aws-lambda-powertools-python/issues/910))
31+
32+
### Maintenance
33+
34+
* **deps-dev:** bump mypy from 0.920 to 0.930 ([#925](https://github.com/awslabs/aws-lambda-powertools-python/issues/925))
35+
36+
## 1.23.0 - 2021-12-20
37+
38+
### Bug Fixes
39+
40+
* **apigateway:** allow list of HTTP methods in route method ([#838](https://github.com/awslabs/aws-lambda-powertools-python/issues/838))
41+
* **event-sources:** pass authorizer data to APIGatewayEventAuthorizer ([#897](https://github.com/awslabs/aws-lambda-powertools-python/issues/897))
42+
* **event-sources:** handle claimsOverrideDetails set to null ([#878](https://github.com/awslabs/aws-lambda-powertools-python/issues/878))
43+
* **idempotency:** include decorated fn name in hash ([#869](https://github.com/awslabs/aws-lambda-powertools-python/issues/869))
44+
* **metrics:** explicit type to single_metric ctx manager ([#865](https://github.com/awslabs/aws-lambda-powertools-python/issues/865))
45+
* **parameters:** mypy appconfig transform and return types ([#877](https://github.com/awslabs/aws-lambda-powertools-python/issues/877))
46+
* **parser:** mypy overload parse when using envelope ([#885](https://github.com/awslabs/aws-lambda-powertools-python/issues/885))
47+
* **parser:** kinesis sequence number is str, not int ([#907](https://github.com/awslabs/aws-lambda-powertools-python/issues/907))
48+
* **parser:** mypy support for payload type override as models ([#883](https://github.com/awslabs/aws-lambda-powertools-python/issues/883))
49+
* **tracer:** add warm start annotation (ColdStart=False) ([#851](https://github.com/awslabs/aws-lambda-powertools-python/issues/851))
50+
51+
### Documentation
52+
53+
* **nav**: reference cloudformation custom resource helper (CRD) ([#914](https://github.com/awslabs/aws-lambda-powertools-python/issues/914))
54+
* add new public Slack invite
55+
* disable search blur in non-prod env
56+
* update Lambda Layers version
57+
* **apigateway:** add new not_found feature ([#915](https://github.com/awslabs/aws-lambda-powertools-python/issues/915))
58+
* **apigateway:** fix sample layout provided ([#864](https://github.com/awslabs/aws-lambda-powertools-python/issues/864))
59+
* **appsync:** fix users.py typo to locations [#830](https://github.com/awslabs/aws-lambda-powertools-python/issues/830)
60+
* **lambda_layer:** fix CDK layer syntax
61+
62+
### Features
63+
64+
* **apigateway:** add exception_handler support ([#898](https://github.com/awslabs/aws-lambda-powertools-python/issues/898))
65+
* **apigateway:** access parent api resolver from router ([#842](https://github.com/awslabs/aws-lambda-powertools-python/issues/842))
66+
* **batch:** new BatchProcessor for SQS, DynamoDB, Kinesis ([#886](https://github.com/awslabs/aws-lambda-powertools-python/issues/886))
67+
* **logger:** allow handler with custom kwargs signature ([#913](https://github.com/awslabs/aws-lambda-powertools-python/issues/913))
68+
* **tracer:** add service annotation when service is set ([#861](https://github.com/awslabs/aws-lambda-powertools-python/issues/861))
69+
70+
### Maintenance
71+
72+
* minor housekeeping before release ([#912](https://github.com/awslabs/aws-lambda-powertools-python/issues/912))
73+
* correct pr label order
74+
* **ci:** split latest docs workflow
75+
* **deps:** bump fastjsonschema from 2.15.1 to 2.15.2 ([#891](https://github.com/awslabs/aws-lambda-powertools-python/issues/891))
76+
* **deps:** bump actions/setup-python from 2.2.2 to 2.3.0 ([#831](https://github.com/awslabs/aws-lambda-powertools-python/issues/831))
77+
* **deps:** support arm64 when developing locally ([#862](https://github.com/awslabs/aws-lambda-powertools-python/issues/862))
78+
* **deps:** bump actions/setup-python from 2.3.0 to 2.3.1 ([#852](https://github.com/awslabs/aws-lambda-powertools-python/issues/852))
79+
* **deps:** bump aws-xray-sdk from 2.8.0 to 2.9.0 ([#876](https://github.com/awslabs/aws-lambda-powertools-python/issues/876))
80+
* **deps-dev:** bump mypy from 0.910 to 0.920 ([#903](https://github.com/awslabs/aws-lambda-powertools-python/issues/903))
81+
* **deps-dev:** bump flake8 from 3.9.2 to 4.0.1 ([#789](https://github.com/awslabs/aws-lambda-powertools-python/issues/789))
82+
* **deps-dev:** bump black from 21.10b0 to 21.11b1 ([#839](https://github.com/awslabs/aws-lambda-powertools-python/issues/839))
83+
* **deps-dev:** bump black from 21.11b1 to 21.12b0 ([#872](https://github.com/awslabs/aws-lambda-powertools-python/issues/872))
984

1085
## 1.22.0 - 2021-11-17
1186

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ With [pip](https://pip.pypa.io/en/latest/index.html) installed, run: ``pip insta
4141
* [Serverless Shopping cart](https://github.com/aws-samples/aws-serverless-shopping-cart)
4242
* [Serverless Airline](https://github.com/aws-samples/aws-serverless-airline-booking)
4343
* [Serverless E-commerce platform](https://github.com/aws-samples/aws-serverless-ecommerce-platform)
44+
* [Serverless GraphQL Nanny Booking Api](https://github.com/trey-rosius/babysitter_api)
4445

4546
## Credits
4647

0 commit comments

Comments
 (0)