Skip to content

Commit

Permalink
Merge pull request #315 from aws/develop
Browse files Browse the repository at this point in the history
release: 1.10.0
  • Loading branch information
mndeveci authored Dec 21, 2021
2 parents b3c5d7d + f95a043 commit 3257a8f
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -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/**/*
8 changes: 8 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -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.
39 changes: 39 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened]

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']
})
}
2 changes: 1 addition & 1 deletion aws_lambda_builders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
AWS Lambda Builder Library
"""
__version__ = "1.9.0"
__version__ = "1.10.0"
RPC_PROTOCOL_VERSION = "0.3"
1 change: 1 addition & 0 deletions aws_lambda_builders/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
3 changes: 2 additions & 1 deletion aws_lambda_builders/workflows/java/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
8 changes: 7 additions & 1 deletion tests/unit/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,32 @@ 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"

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()

listdir_mock.assert_any_call(source_dir)
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):
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/workflows/java/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down

0 comments on commit 3257a8f

Please sign in to comment.