Skip to content

Add building and packaging a demo project to CI and revert #136 #183

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 5 commits into from
Feb 27, 2023
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
22 changes: 22 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ jobs:
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_CLANG_TIDY=clang-tidy
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

build-demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y clang-tidy libcurl4-openssl-dev

- name: Build and install lambda runtime
run: |
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/lambda-install
make
make install

- name: Build and package demo project
run: |
cd examples/demo
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=~/lambda-install
make
make aws-lambda-package-demo


format:
Expand Down
11 changes: 11 additions & 0 deletions examples/demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 11)
project(demo LANGUAGES CXX)
find_package(aws-lambda-runtime)
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-lambda-runtime)
target_compile_features(${PROJECT_NAME} PRIVATE "cxx_std_11")
target_compile_options(${PROJECT_NAME} PRIVATE "-Wall" "-Wextra")

# this line creates a target that packages your binary and zips it up
aws_lambda_package_target(${PROJECT_NAME})
20 changes: 20 additions & 0 deletions examples/demo/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <aws/lambda-runtime/runtime.h>

using namespace aws::lambda_runtime;

static invocation_response my_handler(invocation_request const& req)
{
if (req.payload.length() > 42) {
return invocation_response::failure("error message here"/*error_message*/,
"error type here" /*error_type*/);
}

return invocation_response::success("json payload here" /*payload*/,
"application/json" /*MIME type*/);
}

int main()
{
run_handler(my_handler);
return 0;
}
17 changes: 12 additions & 5 deletions packaging/packager
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,43 @@ if ! type zip > /dev/null 2>&1; then
exit 1
fi

function find_so_files() {
function pluck_so_files() {
sed -E '/\.so$|\.so\.[0-9]+$/!d'
}

function package_libc_alpine() {
# -F matches a fixed string rather than a regex (grep that comes with busybox doesn't know --fixed-strings)
if grep -F "Alpine Linux" < /etc/os-release > /dev/null; then
if type apk > /dev/null 2>&1; then
apk info --contents musl 2>/dev/null | find_so_files | sed 's/^/\//'
apk info --contents musl 2>/dev/null | pluck_so_files | sed 's/^/\//'
fi
fi
}

function package_libc_pacman() {
if grep --extended-regexp "Arch Linux|Manjaro Linux" < /etc/os-release > /dev/null 2>&1; then
if type pacman > /dev/null 2>&1; then
pacman --query --list --quiet glibc | find_so_files
pacman --query --list --quiet glibc | pluck_so_files
fi
fi
}

function package_libc_dpkg() {
if type dpkg-query > /dev/null 2>&1; then
dpkg-query --listfiles libc6:$(dpkg --print-architecture) | find_so_files
architecture=$(dpkg --print-architecture)
if [[ $(dpkg-query --listfiles libc6:$architecture | wc -l) -gt 0 ]]; then
dpkg-query --listfiles libc6:$architecture | pluck_so_files
fi
fi
}

function package_libc_rpm() {
arch=$(uname -m)

if type rpm > /dev/null 2>&1; then
rpm --query --list glibc.$(uname -m) | find_so_files
if [[ $(rpm --query --list glibc.$arch | wc -l) -gt 1 ]]; then
rpm --query --list glibc.$arch | pluck_so_files
fi
fi
}

Expand Down