diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..7abad42 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,44 @@ +name: Validate Project + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install Dependencies + run: sudo apt-get install -y clang-tidy libcurl4-openssl-dev + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_CLANG_TIDY=clang-tidy + + - name: Build It + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Check Formatting + run: ./ci/codebuild/format-check.sh + diff --git a/ci/codebuild/ubuntu-18.04.yml b/ci/codebuild/ubuntu-18.04.yml index 5313f91..5a39a8f 100644 --- a/ci/codebuild/ubuntu-18.04.yml +++ b/ci/codebuild/ubuntu-18.04.yml @@ -8,8 +8,7 @@ phases: build: commands: - echo Build started on `date` - - ci/codebuild/build.sh -DCMAKE_CXX_CLANG_TIDY=clang-tidy -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TESTS=ON -DTEST_RESOURCE_PREFIX=ubuntu1804 - - ci/codebuild/format-check.sh + - ci/codebuild/build.sh -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TESTS=ON -DTEST_RESOURCE_PREFIX=ubuntu1804 - ci/codebuild/run-tests.sh aws-lambda-package-lambda-test-fun ubuntu1804 post_build: commands: diff --git a/ci/docker/amazon-linux-2017.03 b/ci/docker/amazon-linux-2017.03 index f66919a..0ad4621 100644 --- a/ci/docker/amazon-linux-2017.03 +++ b/ci/docker/amazon-linux-2017.03 @@ -1,12 +1,10 @@ FROM amazonlinux:2017.03 RUN yum install gcc64-c++ git ninja-build curl-devel openssl-devel zlib-devel gtest-devel python36-pip zip -y -RUN git clone https://github.com/aws/aws-sdk-cpp.git +RUN git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp RUN curl -fLo cmake-install https://github.com/Kitware/CMake/releases/download/v3.13.0/cmake-3.13.0-Linux-x86_64.sh; \ sh cmake-install --skip-license --prefix=/usr --exclude-subdirectory; RUN pip-3.6 install --upgrade pip -RUN git clone https://github.com/aws/aws-sdk-cpp.git - diff --git a/include/aws/lambda-runtime/runtime.h b/include/aws/lambda-runtime/runtime.h index 94e1e22..9602369 100644 --- a/include/aws/lambda-runtime/runtime.h +++ b/include/aws/lambda-runtime/runtime.h @@ -163,8 +163,6 @@ class runtime { std::string const& url, std::string const& request_id, invocation_response const& handler_response); - -private: std::string const m_user_agent_header; std::array const m_endpoints; CURL* const m_curl_handle; diff --git a/src/runtime.cpp b/src/runtime.cpp index 9175084..6d2a1fb 100644 --- a/src/runtime.cpp +++ b/src/runtime.cpp @@ -61,7 +61,7 @@ static size_t write_data(char* ptr, size_t size, size_t nmemb, void* userdata) return 0; } - auto const resp = static_cast(userdata); + auto* const resp = static_cast(userdata); assert(size == 1); (void)size; // avoid warning in release builds assert(resp); @@ -110,7 +110,7 @@ static size_t write_header(char* ptr, size_t size, size_t nmemb, void* userdata) logging::log_debug(LOG_TAG, "received header: %s", std::string(ptr, nmemb).c_str()); - auto const resp = static_cast(userdata); + auto* const resp = static_cast(userdata); assert(resp); for (size_t i = 0; i < nmemb; i++) { if (ptr[i] != ':') { @@ -127,7 +127,7 @@ static size_t write_header(char* ptr, size_t size, size_t nmemb, void* userdata) static size_t read_data(char* buffer, size_t size, size_t nitems, void* userdata) { auto const limit = size * nitems; - auto ctx = static_cast*>(userdata); + auto* ctx = static_cast*>(userdata); assert(ctx); auto const unread = ctx->first.length() - ctx->second; if (0 == unread) { @@ -160,9 +160,11 @@ static int rt_curl_debug_callback(CURL* handle, curl_infotype type, char* data, runtime::runtime(std::string const& endpoint) : runtime(endpoint, "AWS_Lambda_Cpp/" + std::string(get_version())) {} runtime::runtime(std::string const& endpoint, std::string const& user_agent) - : m_user_agent_header("User-Agent: " + user_agent), m_endpoints{{endpoint + "/2018-06-01/runtime/init/error", - endpoint + "/2018-06-01/runtime/invocation/next", - endpoint + "/2018-06-01/runtime/invocation/"}}, + : m_user_agent_header("User-Agent: " + user_agent), + m_endpoints{ + {endpoint + "/2018-06-01/runtime/init/error", + endpoint + "/2018-06-01/runtime/invocation/next", + endpoint + "/2018-06-01/runtime/invocation/"}}, m_curl_handle(curl_easy_init()) { if (!m_curl_handle) { @@ -396,7 +398,7 @@ void run_handler(std::function c { logging::log_info(LOG_TAG, "Initializing the C++ Lambda Runtime version %s", aws::lambda_runtime::get_version()); std::string endpoint("http://"); - if (auto ep = std::getenv("AWS_LAMBDA_RUNTIME_API")) { + if (auto* ep = std::getenv("AWS_LAMBDA_RUNTIME_API")) { assert(ep); logging::log_debug(LOG_TAG, "LAMBDA_SERVER_ADDRESS defined in environment as: %s", ep); endpoint += ep; diff --git a/tests/gtest/gtest.h b/tests/gtest/gtest.h index 844c9b7..deeb98d 100644 --- a/tests/gtest/gtest.h +++ b/tests/gtest/gtest.h @@ -1,3 +1,4 @@ +// clang-format off // Copyright 2005, Google Inc. // All rights reserved. // diff --git a/tests/runtime_tests.cpp b/tests/runtime_tests.cpp index 0032429..989b844 100644 --- a/tests/runtime_tests.cpp +++ b/tests/runtime_tests.cpp @@ -12,6 +12,7 @@ #include #include #include "gtest/gtest.h" +#include extern std::string aws_prefix; @@ -85,6 +86,9 @@ struct LambdaRuntimeTest : public ::testing::Test { auto outcome = m_lambda_client.CreateFunction(create_function_request); ASSERT_TRUE(outcome.IsSuccess()) << "Failed to create function " << function_name; + + // work around Lambda function pending creation state + sleep(5); } void delete_function(Aws::String const& function_name, bool assert = true)