Skip to content

Commit 6c405fa

Browse files
author
Ran Isenberg
committed
merge
2 parents af99733 + 522bae0 commit 6c405fa

File tree

159 files changed

+7654
-3080
lines changed

Some content is hidden

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

159 files changed

+7654
-3080
lines changed

.flake8

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ exclude = docs, .eggs, setup.py, example, .aws-sam, .git, dist, *.md, *.yaml, ex
33
ignore = E203, E266, W503, BLK100, W291, I004
44
max-line-length = 120
55
max-complexity = 15
6+
per-file-ignores =
7+
tests/e2e/utils/data_builder/__init__.py:F401
8+
tests/e2e/utils/data_fetcher/__init__.py:F401
69

710
[isort]
811
multi_line_output = 3

.github/boring-cyborg.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ labelPRBasedOnFilePath:
3737
area/feature_flags:
3838
- aws_lambda_powertools/feature_flags/*
3939
- aws_lambda_powertools/feature_flags/**/*
40-
area/jmespath_util:
40+
area/jmespath:
4141
- aws_lambda_powertools/utilities/jmespath_utils/*
4242
area/typing:
4343
- aws_lambda_powertools/utilities/typing/*
4444
- mypy.ini
45-
area/utilities:
46-
- aws_lambda_powertools/utilities/*
47-
- aws_lambda_powertools/utilities/**/*
45+
area/commons:
46+
- aws_lambda_powertools/shared/*
4847

4948
documentation:
5049
- docs/*
@@ -96,6 +95,8 @@ labelPRBasedOnFilePath:
9695
firstPRWelcomeComment: >
9796
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
9897
98+
In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: [Invite link](https://discord.gg/B8zZKbbyET)
99+
99100
# Comment to be posted to congratulate user on their first merged PR
100101
firstPRMergeComment: >
101102
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!
@@ -104,6 +105,8 @@ firstPRMergeComment: >
104105
firstIssueWelcomeComment: >
105106
Thanks for opening your first issue here! We'll come back to you as soon as we can.
106107
108+
In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: [Invite link](https://discord.gg/B8zZKbbyET)
109+
107110
###### IssueLink Adder #################################################################################################
108111
# Insert Issue (Jira/Github etc) link in PR description based on the Issue ID in PR title.
109112
#insertIssueLinkInPrDescription:
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
const {
2+
PR_NUMBER,
3+
PR_ACTION,
4+
PR_AUTHOR,
5+
IGNORE_AUTHORS,
6+
} = require("./constants")
7+
8+
9+
/**
10+
* Notify PR author to split XXL PR in smaller chunks
11+
*
12+
* @param {object} core - core functions instance from @actions/core
13+
* @param {object} gh_client - Pre-authenticated REST client (Octokit)
14+
* @param {string} owner - GitHub Organization
15+
* @param {string} repository - GitHub repository
16+
*/
17+
const notifyAuthor = async ({
18+
core,
19+
gh_client,
20+
owner,
21+
repository,
22+
}) => {
23+
core.info(`Commenting on PR ${PR_NUMBER}`)
24+
25+
let msg = `### ⚠️Large PR detected⚠️
26+
27+
Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.
28+
`;
29+
30+
try {
31+
await gh_client.rest.issues.createComment({
32+
owner: owner,
33+
repo: repository,
34+
body: msg,
35+
issue_number: PR_NUMBER,
36+
});
37+
} catch (error) {
38+
core.setFailed("Failed to notify PR author to split large PR");
39+
console.error(err);
40+
}
41+
}
42+
43+
module.exports = async ({github, context, core}) => {
44+
if (IGNORE_AUTHORS.includes(PR_AUTHOR)) {
45+
return core.notice("Author in IGNORE_AUTHORS list; skipping...")
46+
}
47+
48+
if (PR_ACTION != "labeled") {
49+
return core.notice("Only run on PRs labeling actions; skipping")
50+
}
51+
52+
53+
/** @type {string[]} */
54+
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
issue_number: PR_NUMBER,
58+
})
59+
60+
// Schema: https://docs.github.com/en/rest/issues/labels#list-labels-for-an-issue
61+
for (const label of labels) {
62+
core.info(`Label: ${label}`)
63+
if (label.name == "size/XXL") {
64+
await notifyAuthor({
65+
core: core,
66+
gh_client: github,
67+
owner: context.repo.owner,
68+
repository: context.repo.repo,
69+
})
70+
break;
71+
}
72+
}
73+
}

.github/workflows/build_changelog.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Standalone workflow to update changelog if necessary
2+
name: Build changelog
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
changelog:
9+
uses: ./.github/workflows/reusable_publish_changelog.yml

.github/workflows/codeql-analysis.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: "CodeQL"
22

33
on:
44
push:
5-
branches: [develop]
5+
branches: [develop, v2]
66

77
jobs:
88
analyze:
@@ -14,23 +14,23 @@ jobs:
1414
matrix:
1515
# Override automatic language detection by changing the below list
1616
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
17-
language: ['python']
17+
language: ["python"]
1818
# Learn more...
1919
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
2020

2121
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v3
22+
- name: Checkout repository
23+
uses: actions/checkout@v3
2424

25-
# Initializes the CodeQL tools for scanning.
26-
- name: Initialize CodeQL
27-
uses: github/codeql-action/init@v2
28-
with:
29-
languages: ${{ matrix.language }}
30-
# If you wish to specify custom queries, you can do so here or in a config file.
31-
# By default, queries listed here will override any specified in a config file.
32-
# Prefix the list here with "+" to use these queries and those in the config file.
33-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
25+
# Initializes the CodeQL tools for scanning.
26+
- name: Initialize CodeQL
27+
uses: github/codeql-action/init@v2
28+
with:
29+
languages: ${{ matrix.language }}
30+
# If you wish to specify custom queries, you can do so here or in a config file.
31+
# By default, queries listed here will override any specified in a config file.
32+
# Prefix the list here with "+" to use these queries and those in the config file.
33+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
3434

35-
- name: Perform CodeQL Analysis
36-
uses: github/codeql-action/analyze@v2
35+
- name: Perform CodeQL Analysis
36+
uses: github/codeql-action/analyze@v2

.github/workflows/on_label_added.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: On Label added
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Record PR details"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
get_pr_details:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
uses: ./.github/workflows/reusable_export_pr_details.yml
13+
with:
14+
record_pr_workflow_id: ${{ github.event.workflow_run.id }}
15+
workflow_origin: ${{ github.event.repository.full_name }}
16+
secrets:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
split-large-pr:
20+
needs: get_pr_details
21+
runs-on: ubuntu-latest
22+
permissions:
23+
issues: write
24+
pull-requests: write
25+
steps:
26+
- uses: actions/checkout@v3
27+
# Maintenance: Persist state per PR as an artifact to avoid spam on label add
28+
- name: "Suggest split large Pull Request"
29+
uses: actions/github-script@v6
30+
env:
31+
PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }}
32+
PR_ACTION: ${{ needs.get_pr_details.outputs.prAction }}
33+
PR_AUTHOR: ${{ needs.get_pr_details.outputs.prAuthor }}
34+
with:
35+
github-token: ${{ secrets.GITHUB_TOKEN }}
36+
script: |
37+
const script = require('.github/scripts/comment_on_large_pr.js');
38+
await script({github, context, core});

.github/workflows/on_opened_pr.yml

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v3
23-
- name: "Debug workflow_run event"
24-
run: echo "${{ github }}"
2523
- name: "Ensure related issue is present"
2624
uses: actions/github-script@v6
2725
env:

.github/workflows/on_push_docs.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths:
8+
- "docs/**"
9+
- "mkdocs.yml"
10+
- "examples/**"
11+
12+
jobs:
13+
changelog:
14+
permissions:
15+
contents: write
16+
uses: ./.github/workflows/reusable_publish_changelog.yml
17+
18+
release-docs:
19+
needs: changelog
20+
permissions:
21+
contents: write
22+
pages: write
23+
uses: ./.github/workflows/reusable_publish_docs.yml
24+
with:
25+
version: develop
26+
alias: stage
27+
# Maintenance: Only necessary in repo migration
28+
# - name: Create redirect from old docs
29+
# run: |
30+
# git checkout gh-pages
31+
# test -f 404.html && echo "Redirect already set" && exit 0
32+
# git checkout develop -- 404.html
33+
# git add 404.html
34+
# git commit -m "chore: set docs redirect" --no-verify
35+
# git push origin gh-pages -f

.github/workflows/publish.yml renamed to .github/workflows/on_release_notes.yml

+18-51
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ name: Publish to PyPi
2020

2121
# See MAINTAINERS.md "Releasing a new version" for release mechanisms
2222

23+
env:
24+
BRANCH: develop
25+
2326
on:
2427
release:
2528
types: [published]
@@ -66,16 +69,16 @@ jobs:
6669
id: release_version
6770
# transform tag format `v<version` to `<version`
6871
run: |
69-
RELEASE_VERSION=${RELEASE_TAG_VERSION:1}
70-
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
72+
RELEASE_VERSION="${RELEASE_TAG_VERSION:1}"
73+
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "$GITHUB_ENV"
7174
echo "::set-output name=RELEASE_VERSION::${RELEASE_VERSION}"
7275
- name: Install dependencies
7376
run: make dev
7477
- name: Run all tests, linting and baselines
7578
if: ${{ !inputs.skip_code_quality }}
7679
run: make pr
7780
- name: Bump package version
78-
run: poetry version ${RELEASE_VERSION}
81+
run: poetry version "${RELEASE_VERSION}"
7982
- name: Build python package and wheel
8083
if: ${{ !inputs.skip_pypi }}
8184
run: poetry build
@@ -98,61 +101,25 @@ jobs:
98101
role-to-assume: ${{ secrets.AWS_SAR_ROLE_ARN }}
99102
- name: publish lambda layer in SAR by triggering the internal codepipeline
100103
run: |
101-
aws ssm put-parameter --name "powertools-python-release-version" --value $RELEASE_VERSION --overwrite
104+
aws ssm put-parameter --name "powertools-python-release-version" --value "$RELEASE_VERSION" --overwrite
102105
aws codepipeline start-pipeline-execution --name ${{ secrets.AWS_SAR_PIPELINE_NAME }}
103106
104-
# NOTE: `event` type brings a detached head failing git setup
105-
# and reusable workflows only work as a standalone job
106-
# meaning we need to research for a solution that works for non-detached and detached mode
107-
# changelog:
108-
# needs: release
109-
# permissions:
110-
# contents: write
111-
# uses: ./.github/workflows/reusable_publish_changelog.yml
107+
changelog:
108+
needs: release
109+
permissions:
110+
contents: write
111+
uses: ./.github/workflows/reusable_publish_changelog.yml
112112

113113
docs:
114-
needs: release
114+
needs: [release, changelog]
115115
permissions:
116116
contents: write
117117
pages: write
118-
runs-on: ubuntu-latest
119-
env:
120-
RELEASE_VERSION: ${{ needs.release.outputs.RELEASE_VERSION }}
121-
steps:
122-
- uses: actions/checkout@v3
123-
with:
124-
fetch-depth: 0
125-
- name: Setup git client
126-
run: |
127-
git config user.name "Release bot"
128-
git config user.email [email protected]
129-
- name: Install poetry
130-
run: pipx install poetry
131-
- name: Set up Python
132-
uses: actions/setup-python@v4
133-
with:
134-
python-version: "3.8"
135-
cache: "poetry"
136-
- name: Install dependencies
137-
run: make dev
138-
- name: Build docs website and API reference
139-
run: |
140-
make release-docs VERSION=${RELEASE_VERSION} ALIAS="latest"
141-
poetry run mike set-default --push latest
142-
- name: Release API docs to release version
143-
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
144-
with:
145-
github_token: ${{ secrets.GITHUB_TOKEN }}
146-
publish_dir: ./api
147-
keep_files: true
148-
destination_dir: ${{ env.RELEASE_VERSION }}/api
149-
- name: Release API docs to latest
150-
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
151-
with:
152-
github_token: ${{ secrets.GITHUB_TOKEN }}
153-
publish_dir: ./api
154-
keep_files: true
155-
destination_dir: latest/api
118+
uses: ./.github/workflows/reusable_publish_docs.yml
119+
with:
120+
version: ${{ needs.release.outputs.RELEASE_VERSION }}
121+
alias: latest
122+
detached_mode: true
156123

157124
post_release:
158125
needs: release

.github/workflows/python_build.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- "mypy.ini"
1111
branches:
1212
- develop
13+
- v2
1314
push:
1415
paths:
1516
- "aws_lambda_powertools/**"
@@ -19,6 +20,7 @@ on:
1920
- "mypy.ini"
2021
branches:
2122
- develop
23+
- v2
2224

2325
jobs:
2426
build:
@@ -28,7 +30,6 @@ jobs:
2830
matrix:
2931
python-version: [3.7, 3.8, 3.9]
3032
env:
31-
OS: ${{ matrix.os }}
3233
PYTHON: ${{ matrix.python-version }}
3334
steps:
3435
- uses: actions/checkout@v3
@@ -55,7 +56,5 @@ jobs:
5556
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0
5657
with:
5758
file: ./coverage.xml
58-
# flags: unittests
59-
env_vars: OS,PYTHON
59+
env_vars: PYTHON
6060
name: aws-lambda-powertools-python-codecov
61-
# fail_ci_if_error: true # failing more consistently making CI unreliable despite all tests above passing

0 commit comments

Comments
 (0)