Skip to content

Commit 0ee61ee

Browse files
authored
Update and fix CI workflows (#133)
* Create github workflow.yml * satisfy the format check * satisfy clang-tidy warning readability-qualified-auto * satisfy clang-tidy warning readability-redundant-access-specifiers * Update codebuild ubuntu-18.04.yml * sleep a bit after creating function resource in tests * reflect fixes made to codebuild environment for amazon linux
1 parent 1f61972 commit 0ee61ee

File tree

7 files changed

+60
-14
lines changed

7 files changed

+60
-14
lines changed

.github/workflows/workflow.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Validate Project
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: Debug
12+
13+
jobs:
14+
build:
15+
# The CMake configure and build commands are platform agnostic and should work equally
16+
# well on Windows or Mac. You can convert this to a matrix build if you need
17+
# cross-platform coverage.
18+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Install Dependencies
25+
run: sudo apt-get install -y clang-tidy libcurl4-openssl-dev
26+
27+
- name: Configure CMake
28+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
29+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
30+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_CLANG_TIDY=clang-tidy
31+
32+
- name: Build It
33+
# Build your program with the given configuration
34+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
35+
36+
format:
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
42+
- name: Check Formatting
43+
run: ./ci/codebuild/format-check.sh
44+

ci/codebuild/ubuntu-18.04.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ phases:
88
build:
99
commands:
1010
- echo Build started on `date`
11-
- ci/codebuild/build.sh -DCMAKE_CXX_CLANG_TIDY=clang-tidy -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TESTS=ON -DTEST_RESOURCE_PREFIX=ubuntu1804
12-
- ci/codebuild/format-check.sh
11+
- ci/codebuild/build.sh -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TESTS=ON -DTEST_RESOURCE_PREFIX=ubuntu1804
1312
- ci/codebuild/run-tests.sh aws-lambda-package-lambda-test-fun ubuntu1804
1413
post_build:
1514
commands:

ci/docker/amazon-linux-2017.03

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
FROM amazonlinux:2017.03
22

33
RUN yum install gcc64-c++ git ninja-build curl-devel openssl-devel zlib-devel gtest-devel python36-pip zip -y
4-
RUN git clone https://github.com/aws/aws-sdk-cpp.git
4+
RUN git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
55

66
RUN curl -fLo cmake-install https://github.com/Kitware/CMake/releases/download/v3.13.0/cmake-3.13.0-Linux-x86_64.sh; \
77
sh cmake-install --skip-license --prefix=/usr --exclude-subdirectory;
88

99
RUN pip-3.6 install --upgrade pip
1010

11-
RUN git clone https://github.com/aws/aws-sdk-cpp.git
12-

include/aws/lambda-runtime/runtime.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ class runtime {
163163
std::string const& url,
164164
std::string const& request_id,
165165
invocation_response const& handler_response);
166-
167-
private:
168166
std::string const m_user_agent_header;
169167
std::array<std::string const, 3> const m_endpoints;
170168
CURL* const m_curl_handle;

src/runtime.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static size_t write_data(char* ptr, size_t size, size_t nmemb, void* userdata)
6161
return 0;
6262
}
6363

64-
auto const resp = static_cast<http::response*>(userdata);
64+
auto* const resp = static_cast<http::response*>(userdata);
6565
assert(size == 1);
6666
(void)size; // avoid warning in release builds
6767
assert(resp);
@@ -110,7 +110,7 @@ static size_t write_header(char* ptr, size_t size, size_t nmemb, void* userdata)
110110

111111
logging::log_debug(LOG_TAG, "received header: %s", std::string(ptr, nmemb).c_str());
112112

113-
auto const resp = static_cast<http::response*>(userdata);
113+
auto* const resp = static_cast<http::response*>(userdata);
114114
assert(resp);
115115
for (size_t i = 0; i < nmemb; i++) {
116116
if (ptr[i] != ':') {
@@ -127,7 +127,7 @@ static size_t write_header(char* ptr, size_t size, size_t nmemb, void* userdata)
127127
static size_t read_data(char* buffer, size_t size, size_t nitems, void* userdata)
128128
{
129129
auto const limit = size * nitems;
130-
auto ctx = static_cast<std::pair<std::string const&, size_t>*>(userdata);
130+
auto* ctx = static_cast<std::pair<std::string const&, size_t>*>(userdata);
131131
assert(ctx);
132132
auto const unread = ctx->first.length() - ctx->second;
133133
if (0 == unread) {
@@ -160,9 +160,11 @@ static int rt_curl_debug_callback(CURL* handle, curl_infotype type, char* data,
160160
runtime::runtime(std::string const& endpoint) : runtime(endpoint, "AWS_Lambda_Cpp/" + std::string(get_version())) {}
161161

162162
runtime::runtime(std::string const& endpoint, std::string const& user_agent)
163-
: m_user_agent_header("User-Agent: " + user_agent), m_endpoints{{endpoint + "/2018-06-01/runtime/init/error",
164-
endpoint + "/2018-06-01/runtime/invocation/next",
165-
endpoint + "/2018-06-01/runtime/invocation/"}},
163+
: m_user_agent_header("User-Agent: " + user_agent),
164+
m_endpoints{
165+
{endpoint + "/2018-06-01/runtime/init/error",
166+
endpoint + "/2018-06-01/runtime/invocation/next",
167+
endpoint + "/2018-06-01/runtime/invocation/"}},
166168
m_curl_handle(curl_easy_init())
167169
{
168170
if (!m_curl_handle) {
@@ -396,7 +398,7 @@ void run_handler(std::function<invocation_response(invocation_request const&)> c
396398
{
397399
logging::log_info(LOG_TAG, "Initializing the C++ Lambda Runtime version %s", aws::lambda_runtime::get_version());
398400
std::string endpoint("http://");
399-
if (auto ep = std::getenv("AWS_LAMBDA_RUNTIME_API")) {
401+
if (auto* ep = std::getenv("AWS_LAMBDA_RUNTIME_API")) {
400402
assert(ep);
401403
logging::log_debug(LOG_TAG, "LAMBDA_SERVER_ADDRESS defined in environment as: %s", ep);
402404
endpoint += ep;

tests/gtest/gtest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// clang-format off
12
// Copyright 2005, Google Inc.
23
// All rights reserved.
34
//

tests/runtime_tests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <aws/lambda/model/DeleteFunctionRequest.h>
1313
#include <aws/lambda/model/InvokeRequest.h>
1414
#include "gtest/gtest.h"
15+
#include <unistd.h>
1516

1617
extern std::string aws_prefix;
1718

@@ -85,6 +86,9 @@ struct LambdaRuntimeTest : public ::testing::Test {
8586

8687
auto outcome = m_lambda_client.CreateFunction(create_function_request);
8788
ASSERT_TRUE(outcome.IsSuccess()) << "Failed to create function " << function_name;
89+
90+
// work around Lambda function pending creation state
91+
sleep(5);
8892
}
8993

9094
void delete_function(Aws::String const& function_name, bool assert = true)

0 commit comments

Comments
 (0)