Skip to content

Commit c09c86e

Browse files
kkarbowiakbmoffatt
andauthored
Add building and packaging a demo project to CI and revert #136 (#183)
* Add demo project * Add build-demo CI job * Revert "Simplified method for picking out shared libraries from system package query result (#136)" This reverts commit 5fb60b9. --------- Co-authored-by: Bryan Moffatt <[email protected]> Co-authored-by: Bryan Moffatt <[email protected]>
1 parent fa438eb commit c09c86e

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

.github/workflows/workflow.yml

+22
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ jobs:
4646
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_CLANG_TIDY=clang-tidy
4747
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
4848
49+
build-demo:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v3
53+
54+
- name: Install Dependencies
55+
run: sudo apt-get update && sudo apt-get install -y clang-tidy libcurl4-openssl-dev
56+
57+
- name: Build and install lambda runtime
58+
run: |
59+
mkdir build && cd build
60+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/lambda-install
61+
make
62+
make install
63+
64+
- name: Build and package demo project
65+
run: |
66+
cd examples/demo
67+
mkdir build && cd build
68+
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=~/lambda-install
69+
make
70+
make aws-lambda-package-demo
4971
5072

5173
format:

examples/demo/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.9)
2+
set(CMAKE_CXX_STANDARD 11)
3+
project(demo LANGUAGES CXX)
4+
find_package(aws-lambda-runtime)
5+
add_executable(${PROJECT_NAME} "main.cpp")
6+
target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-lambda-runtime)
7+
target_compile_features(${PROJECT_NAME} PRIVATE "cxx_std_11")
8+
target_compile_options(${PROJECT_NAME} PRIVATE "-Wall" "-Wextra")
9+
10+
# this line creates a target that packages your binary and zips it up
11+
aws_lambda_package_target(${PROJECT_NAME})

examples/demo/main.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <aws/lambda-runtime/runtime.h>
2+
3+
using namespace aws::lambda_runtime;
4+
5+
static invocation_response my_handler(invocation_request const& req)
6+
{
7+
if (req.payload.length() > 42) {
8+
return invocation_response::failure("error message here"/*error_message*/,
9+
"error type here" /*error_type*/);
10+
}
11+
12+
return invocation_response::success("json payload here" /*payload*/,
13+
"application/json" /*MIME type*/);
14+
}
15+
16+
int main()
17+
{
18+
run_handler(my_handler);
19+
return 0;
20+
}

packaging/packager

+12-5
Original file line numberDiff line numberDiff line change
@@ -56,36 +56,43 @@ if ! type zip > /dev/null 2>&1; then
5656
exit 1
5757
fi
5858

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

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

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

8080
function package_libc_dpkg() {
8181
if type dpkg-query > /dev/null 2>&1; then
82-
dpkg-query --listfiles libc6:$(dpkg --print-architecture) | find_so_files
82+
architecture=$(dpkg --print-architecture)
83+
if [[ $(dpkg-query --listfiles libc6:$architecture | wc -l) -gt 0 ]]; then
84+
dpkg-query --listfiles libc6:$architecture | pluck_so_files
85+
fi
8386
fi
8487
}
8588

8689
function package_libc_rpm() {
90+
arch=$(uname -m)
91+
8792
if type rpm > /dev/null 2>&1; then
88-
rpm --query --list glibc.$(uname -m) | find_so_files
93+
if [[ $(rpm --query --list glibc.$arch | wc -l) -gt 1 ]]; then
94+
rpm --query --list glibc.$arch | pluck_so_files
95+
fi
8996
fi
9097
}
9198

0 commit comments

Comments
 (0)