Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

LOG = logging.getLogger(__name__)


class GlobalToolInstallAction(BaseAction):

"""
Expand Down Expand Up @@ -64,7 +65,7 @@ def execute(self):
LOG.debug("Running `dotnet lambda package` in %s", self.source_dir)

zipfilename = os.path.basename(os.path.normpath(self.source_dir)) + ".zip"
zipfullpath = os.path.join(self.artifacts_dir, zipfilename)
zipfullpath = os.path.abspath(os.path.join(self.artifacts_dir, zipfilename))

arguments = ['lambda', 'package', '--output-package', zipfullpath]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Wrapper around calls to dotent CLI through a subprocess.
"""

import sys
import logging

from .utils import OSUtils

LOG = logging.getLogger(__name__)


class DotnetCLIExecutionError(Exception):
"""
Exception raised when dotnet CLI fails.
Expand All @@ -20,6 +20,7 @@ class DotnetCLIExecutionError(Exception):
def __init__(self, **kwargs):
Exception.__init__(self, self.MESSAGE.format(**kwargs))


class SubprocessDotnetCLI(object):
"""
Wrapper around the Dotnet CLI, encapsulating
Expand Down
4 changes: 2 additions & 2 deletions aws_lambda_builders/workflows/dotnet_clipackage/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import os
import platform
import shutil
import subprocess
import zipfile

from aws_lambda_builders.utils import which


Expand All @@ -25,7 +25,7 @@ def is_windows(self):
def which(self, executable, executable_search_paths=None):
return which(executable, executable_search_paths=executable_search_paths)

def expand_zip(self, zipfullpath,destination_dir):
def expand_zip(self, zipfullpath, destination_dir):
ziparchive = zipfile.ZipFile(zipfullpath, 'r')
ziparchive.extractall(destination_dir)
ziparchive.close()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module github.com/awslabs/aws-lambda-builders
module github.com/awslabs/aws-lambda-builders
27 changes: 12 additions & 15 deletions tests/unit/workflows/dotnet_clipackage/test_actions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
from unittest import TestCase

from mock import patch
import os
import platform

from aws_lambda_builders.actions import ActionFailedError
from aws_lambda_builders.workflows.dotnet_clipackage.dotnetcli import DotnetCLIExecutionError
from aws_lambda_builders.workflows.dotnet_clipackage.actions import GlobalToolInstallAction, RunPackageAction
from aws_lambda_builders.workflows.dotnet_clipackage.dotnetcli import DotnetCLIExecutionError


class TestGlobalToolInstallAction(TestCase):
Expand Down Expand Up @@ -43,9 +43,9 @@ class TestRunPackageAction(TestCase):
def setUp(self, MockSubprocessDotnetCLI, MockOSUtils):
self.subprocess_dotnet = MockSubprocessDotnetCLI.return_value
self.os_utils = MockOSUtils
self.source_dir = os.path.join('/source_dir')
self.artifacts_dir = os.path.join('/artifacts_dir')
self.scratch_dir = os.path.join('/scratch_dir')
self.source_dir = os.path.join(os.getcwd(), 'source_dir')
self.artifacts_dir = os.path.join(os.getcwd(), 'artifacts_dir')
self.scratch_dir = os.path.join(os.getcwd(), 'scratch_dir')

def tearDown(self):
self.subprocess_dotnet.reset_mock()
Expand All @@ -59,10 +59,10 @@ def test_build_package(self):

action.execute()

zipFilePath = os.path.join('/', 'artifacts_dir', 'source_dir.zip')
zipFilePath = os.path.abspath(os.path.join(self.artifacts_dir, 'source_dir.zip'))

self.subprocess_dotnet.run.assert_called_once_with(['lambda', 'package', '--output-package', zipFilePath],
cwd='/source_dir')
cwd=self.source_dir)

def test_build_package_arguments(self):
mode = "Release"
Expand All @@ -72,14 +72,11 @@ def test_build_package_arguments(self):

action.execute()

if platform.system().lower() == 'windows':
zipFilePath = '/artifacts_dir\\source_dir.zip'
else:
zipFilePath = '/artifacts_dir/source_dir.zip'
zipFilePath = os.path.abspath(os.path.join(self.artifacts_dir, 'source_dir.zip'))

self.subprocess_dotnet.run.assert_called_once_with(['lambda', 'package', '--output-package',
zipFilePath, '--framework', 'netcoreapp2.1'],
cwd='/source_dir')
cwd=self.source_dir)

def test_build_error(self):
mode = "Release"
Expand All @@ -97,10 +94,10 @@ def test_debug_configuration_set(self):
action = RunPackageAction(self.source_dir, self.subprocess_dotnet, self.artifacts_dir, options, mode,
self.os_utils)

zipFilePath = os.path.join('/', 'artifacts_dir', 'source_dir.zip')
zipFilePath = os.path.abspath(os.path.join(self.artifacts_dir, 'source_dir.zip'))

action.execute()

self.subprocess_dotnet.run.assert_called_once_with(
['lambda', 'package', '--output-package', zipFilePath, '--configuration', 'Debug'],
cwd='/source_dir')
cwd=self.source_dir)