Skip to content

Update and fix CI workflows #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Nov 24, 2021
Merged
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
44 changes: 44 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -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

3 changes: 1 addition & 2 deletions ci/codebuild/ubuntu-18.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions ci/docker/amazon-linux-2017.03
Original file line number Diff line number Diff line change
@@ -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

2 changes: 0 additions & 2 deletions include/aws/lambda-runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ class runtime {
std::string const& url,
std::string const& request_id,
invocation_response const& handler_response);

private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for making this public?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy pointed out that these were already made private a few lines up

ref: https://github.com/bmoffatt/aws-lambda-cpp/runs/4305830378?check_suite_focus=true

/home/runner/work/aws-lambda-cpp/aws-lambda-cpp/include/aws/lambda-runtime/runtime.h:167:1: error: redundant access specifier has the same accessibility as the previous access specifier [readability-redundant-access-specifiers,-warnings-as-errors]
private:
^~~~~~~~
/home/runner/work/aws-lambda-cpp/aws-lambda-cpp/include/aws/lambda-runtime/runtime.h:159:1: note: previously declared here
private:
^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! That's what I get for looking at this on a 5" phone screen.

std::string const m_user_agent_header;
std::array<std::string const, 3> const m_endpoints;
CURL* const m_curl_handle;
Expand Down
16 changes: 9 additions & 7 deletions src/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<http::response*>(userdata);
auto* const resp = static_cast<http::response*>(userdata);
assert(size == 1);
(void)size; // avoid warning in release builds
assert(resp);
Expand Down Expand Up @@ -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<http::response*>(userdata);
auto* const resp = static_cast<http::response*>(userdata);
assert(resp);
for (size_t i = 0; i < nmemb; i++) {
if (ptr[i] != ':') {
Expand All @@ -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<std::pair<std::string const&, size_t>*>(userdata);
auto* ctx = static_cast<std::pair<std::string const&, size_t>*>(userdata);
assert(ctx);
auto const unread = ctx->first.length() - ctx->second;
if (0 == unread) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -396,7 +398,7 @@ void run_handler(std::function<invocation_response(invocation_request const&)> 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;
Expand Down
1 change: 1 addition & 0 deletions tests/gtest/gtest.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// clang-format off
// Copyright 2005, Google Inc.
// All rights reserved.
//
Expand Down
4 changes: 4 additions & 0 deletions tests/runtime_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <aws/lambda/model/DeleteFunctionRequest.h>
#include <aws/lambda/model/InvokeRequest.h>
#include "gtest/gtest.h"
#include <unistd.h>

extern std::string aws_prefix;

Expand Down Expand Up @@ -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)
Expand Down