From 0d9cd7d02e4778f4688468632c768795285b0d2f Mon Sep 17 00:00:00 2001 From: Jacob Fuss <32497805+jfuss@users.noreply.github.com> Date: Mon, 15 Nov 2021 12:10:49 -0600 Subject: [PATCH 1/6] Chore: Auto PR labeler (#309) --- .github/labeler.yml | 27 +++++++++++++++++++++++ .github/workflows/README.md | 8 +++++++ .github/workflows/pr-labeler.yml | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/README.md create mode 100644 .github/workflows/pr-labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 000000000..03a18a90c --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,27 @@ +area/workflow/dotnet_clipackage: +- aws_lambda_builders/workflows/dotnet_clipacakge/* +- aws_lambda_builders/workflows/dotnet_clipacakge/**/* + +area/workflow/go_modules: +- aws_lambda_builders/workflows/go_modules/* +- aws_lambda_builders/workflows/go_modules/**/* + +area/workflow/java_gradle: +- aws_lambda_builders/workflows/java_gradle/* +- aws_lambda_builders/workflows/java_gradle/**/* + +area/workflow/java_maven: +- aws_lambda_builders/workflows/java_maven/* +- aws_lambda_builders/workflows/java_maven/**/* + +area/workflow/node_npm: +- aws_lambda_builders/workflows/nodejs_npm/* +- aws_lambda_builders/workflows/nodejs_npm/**/* + +area/workflow/python_pip: +- aws_lambda_builders/workflows/python_pip/* +- aws_lambda_builders/workflows/python_pip/**/* + +area/workflow/ruby_bundler: +- aws_lambda_builders/workflows/ruby_bundler/* +- aws_lambda_builders/workflows/ruby_bundler/**/* diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 000000000..c0e878f27 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,8 @@ +This folder has Github Actions for this repo. + +** pr-labler ** + +This is responsible for tagging our prs automattically. The primary thing it does is tags internal vs external (to the team) PRs. It will +also tag PRs with `area/*` tags based upon the files being changes in the PR. This is run on `pull_request_target` which only runs what is +in the repo not what is in the Pull Request. This is done to help guard against a PR running and changing. For this, the Action should NEVER +download or checkout the PR. It is purely for tagging/labeling not CI. diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 000000000..86dc5433a --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,38 @@ +name: "Pull Request Labeler" +on: +- pull_request_target + +jobs: + apply-file-based-labels: + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v3 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + apply-internal-external-label: + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v5 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const maintainers = ['jfuss', 'c2tarun', 'hoffa', 'awood45', 'CoshUS', 'aahung', 'hawflau', 'mndeveci', 'ssenchenko', 'wchengru', 'mingkun2020', 'qingchm', 'moelasmar', 'xazhao', 'mildaniel', 'marekaiv', 'torresxb1'] + if (maintainers.includes(context.payload.sender.login)) { + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['pr/internal'] + }) + } else { + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['pr/external'] + }) + } From 71e507fbc08eb8d583be339b3701ce30bf026776 Mon Sep 17 00:00:00 2001 From: Jacob Fuss <32497805+jfuss@users.noreply.github.com> Date: Fri, 19 Nov 2021 10:00:53 -0600 Subject: [PATCH 2/6] Chore: Only add labels on open of PRs (#310) --- .github/workflows/pr-labeler.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index 86dc5433a..d6633fb88 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -1,6 +1,7 @@ name: "Pull Request Labeler" on: -- pull_request_target + pull_request_target: + types: [opened] jobs: apply-file-based-labels: From 8683b616344ce17f56b3bd2159ee4cf57ce4fb08 Mon Sep 17 00:00:00 2001 From: Wilton Wang Date: Wed, 1 Dec 2021 14:28:39 -0800 Subject: [PATCH 3/6] Added Create Directory before Copy --- aws_lambda_builders/actions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aws_lambda_builders/actions.py b/aws_lambda_builders/actions.py index a661518ad..d9025a537 100644 --- a/aws_lambda_builders/actions.py +++ b/aws_lambda_builders/actions.py @@ -136,6 +136,7 @@ def execute(self): if os.path.isdir(dependencies_source): copytree(dependencies_source, new_destination) else: + os.makedirs(os.path.dirname(dependencies_source), exist_ok=True) shutil.copy2(dependencies_source, new_destination) From 7f151faa45b9fd8c6966ce1b6676cf8522dc57f8 Mon Sep 17 00:00:00 2001 From: Wilton Wang Date: Wed, 1 Dec 2021 14:33:07 -0800 Subject: [PATCH 4/6] Updated Unit Test --- tests/unit/test_actions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_actions.py b/tests/unit/test_actions.py index 388c69f84..0178c1a38 100644 --- a/tests/unit/test_actions.py +++ b/tests/unit/test_actions.py @@ -62,12 +62,16 @@ def test_must_copy(self, copytree_mock): class TestCopyDependenciesAction_execute(TestCase): + @patch("aws_lambda_builders.actions.os.makedirs") + @patch("aws_lambda_builders.actions.os.path.dirname") @patch("aws_lambda_builders.actions.shutil.copy2") @patch("aws_lambda_builders.actions.copytree") @patch("aws_lambda_builders.actions.os.path.isdir") @patch("aws_lambda_builders.actions.os.listdir") @patch("aws_lambda_builders.actions.os.path.join") - def test_must_copy(self, path_mock, listdir_mock, isdir_mock, copytree_mock, copy2_mock): + def test_must_copy( + self, path_mock, listdir_mock, isdir_mock, copytree_mock, copy2_mock, dirname_mock, makedirs_mock + ): source_dir = "source" artifact_dir = "artifact" dest_dir = "dest" @@ -75,6 +79,7 @@ def test_must_copy(self, path_mock, listdir_mock, isdir_mock, copytree_mock, cop listdir_mock.side_effect = [[1], [1, 2, 3]] path_mock.side_effect = ["dir1", "dir2", "file1", "file2"] isdir_mock.side_effect = [True, False] + dirname_mock.side_effect = ["parent_dir_1"] action = CopyDependenciesAction(source_dir, artifact_dir, dest_dir) action.execute() @@ -82,6 +87,7 @@ def test_must_copy(self, path_mock, listdir_mock, isdir_mock, copytree_mock, cop listdir_mock.assert_any_call(artifact_dir) copytree_mock.assert_called_once_with("dir1", "dir2") copy2_mock.assert_called_once_with("file1", "file2") + makedirs_mock.assert_called_once_with("parent_dir_1", exist_ok=True) class TestMoveDependenciesAction_execute(TestCase): From 7843ac13817e494f0a0eb55b8b6a5db786748c10 Mon Sep 17 00:00:00 2001 From: Wilton_ Date: Tue, 7 Dec 2021 14:15:46 -0800 Subject: [PATCH 5/6] Updated TestJavaMoveDependenciesAction to Include lib Folder (#313) --- aws_lambda_builders/workflows/java/actions.py | 3 ++- tests/unit/workflows/java/test_actions.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/aws_lambda_builders/workflows/java/actions.py b/aws_lambda_builders/workflows/java/actions.py index eac7522c0..e412be822 100644 --- a/aws_lambda_builders/workflows/java/actions.py +++ b/aws_lambda_builders/workflows/java/actions.py @@ -59,7 +59,8 @@ def _move_dependencies(self): Move the entire lib directory from artifact folder to dependencies folder """ try: + dependencies_lib_dir = os.path.join(self.dependencies_dir, "lib") lib_folder = os.path.join(self.artifacts_dir, "lib") - self.os_utils.move(lib_folder, self.dependencies_dir) + self.os_utils.move(lib_folder, dependencies_lib_dir) except Exception as ex: raise ActionFailedError(str(ex)) diff --git a/tests/unit/workflows/java/test_actions.py b/tests/unit/workflows/java/test_actions.py index 89484220b..9b0acd05e 100644 --- a/tests/unit/workflows/java/test_actions.py +++ b/tests/unit/workflows/java/test_actions.py @@ -46,7 +46,9 @@ def test_copies_artifacts(self): action = JavaMoveDependenciesAction(self.artifacts_dir, self.dependencies_dir, self.os_utils) action.execute() - self.os_utils.move.assert_called_with(os.path.join(self.artifacts_dir, "lib"), self.dependencies_dir) + self.os_utils.move.assert_called_with( + os.path.join(self.artifacts_dir, "lib"), os.path.join(self.dependencies_dir, "lib") + ) def test_error_in_artifact_copy_raises_action_error(self): self.os_utils.move.side_effect = Exception("scandir failed!") From f95a043d22f20a6252c43280d5a823b8d4f1b9fc Mon Sep 17 00:00:00 2001 From: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Date: Tue, 21 Dec 2021 11:24:43 -0800 Subject: [PATCH 6/6] chore: bump version to 1.10.0 (#314) --- aws_lambda_builders/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws_lambda_builders/__init__.py b/aws_lambda_builders/__init__.py index a65cf3647..69aeed5f8 100644 --- a/aws_lambda_builders/__init__.py +++ b/aws_lambda_builders/__init__.py @@ -1,5 +1,5 @@ """ AWS Lambda Builder Library """ -__version__ = "1.9.0" +__version__ = "1.10.0" RPC_PROTOCOL_VERSION = "0.3"