From 44dff625dafe80fb40a1173a15244b87afe520c5 Mon Sep 17 00:00:00 2001 From: Jeremy Tubongbanua <79019866+JeremyTubongbanua@users.noreply.github.com> Date: Fri, 3 May 2024 08:39:41 -0400 Subject: [PATCH] ci: build core examples in `examples/desktop` (#214) * ci: build examples ci * ci: * fix: repl desktop example --- .github/workflows/tests.yaml | 45 +++++++++++++++++++++++++++++++- examples/desktop/repl/run.sh | 2 +- examples/desktop/repl/src/main.c | 17 +++++++----- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 79fd37ef..17ae8d95 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -35,4 +35,47 @@ jobs: - name: Build and Run Functional Tests working-directory: tests/functional_tests run: | - tools/run_ctest.sh \ No newline at end of file + tools/run_ctest.sh + build-examples: + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + + - name: Install atSDK + run: | + tools/install.sh + + - name: Build at_talk + working-directory: examples/desktop/at_talk + run: | + cmake -S . -B build + cmake --build build + + - name: Build all CRUD examples + working-directory: examples/desktop/crud + run: | + cmake -S . -B build -DTARGET_SRC=delete.c && cmake --build build + cmake -S . -B build -DTARGET_SRC=get_publickey.c && cmake --build build + cmake -S . -B build -DTARGET_SRC=get_selfkey.c && cmake --build build + cmake -S . -B build -DTARGET_SRC=get_sharedkey.c && cmake --build build + cmake -S . -B build -DTARGET_SRC=put_publickey.c && cmake --build build + cmake -S . -B build -DTARGET_SRC=put_selfkey.c && cmake --build build + cmake -S . -B build -DTARGET_SRC=put_sharedkey.c && cmake --build build + + - name: Build events + working-directory: examples/desktop/events + run: | + cmake -S . -B build + cmake --build build + + - name: Build pkam_authenticate + working-directory: examples/desktop/pkam_authenticate + run: | + cmake -S . -B build + cmake --build build + + - name: Build REPL + working-directory: examples/desktop/repl + run: | + cmake -S . -B build + cmake --build build --target install \ No newline at end of file diff --git a/examples/desktop/repl/run.sh b/examples/desktop/repl/run.sh index 638d12f8..adc3d4c1 100755 --- a/examples/desktop/repl/run.sh +++ b/examples/desktop/repl/run.sh @@ -19,7 +19,7 @@ cd "$SCRIPT_DIRECTORY" cmake -S . -B build ## 2b. CMake build -sudo cmake --build build --target install +cmake --build build --target install # 3. Run REPL ./bin/repl $@ diff --git a/examples/desktop/repl/src/main.c b/examples/desktop/repl/src/main.c index bb4088e8..69c5b4d2 100644 --- a/examples/desktop/repl/src/main.c +++ b/examples/desktop/repl/src/main.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #define TAG "REPL" @@ -21,11 +22,18 @@ int main(int argc, char *argv[]) { int ret = 1; atlogger_set_logging_level(ATLOGGER_LOGGING_LEVEL_DEBUG); - const unsigned long cmdlen = 4096; + char atkeysfilepath[1024]; + memset(atkeysfilepath, 0, sizeof(char) * 1024); // Clear the buffer (for safety) + + const size_t bufferlen = 1024; + char buffer[bufferlen]; + memset(buffer, 0, sizeof(char) * bufferlen); // Clear the buffer (for safety + + const size_t cmdlen = 4096; atclient_atbytes cmd; atclient_atbytes_init(&cmd, cmdlen); - const unsigned long recvlen = 4096; + const size_t recvlen = 4096; atclient_atbytes recv; atclient_atbytes_init(&recv, recvlen); @@ -68,8 +76,6 @@ int main(int argc, char *argv[]) { goto exit; } - char atkeysfilepath[1024]; - memset(atkeysfilepath, 0, sizeof(char) * 1024); // Clear the buffer (for safety) sprintf(atkeysfilepath, "%s/.atsign/keys/%s_key.atKeys", homedir, atsign); if (atclient_atkeys_populate_from_path(&atkeys, atkeysfilepath) != 0) { atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "Failed to read atKeys file at path \"%s\"\n", atkeysfilepath); @@ -94,9 +100,6 @@ int main(int argc, char *argv[]) { atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_INFO, "Successfully PKAM Authenticated with atSign \"%s\"\n", atsign); - const unsigned long bufferlen = 1024; - char buffer[bufferlen]; - int loop = 1; do { memset(buffer, 0, sizeof(char) * bufferlen);