Skip to content
Open
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
52 changes: 41 additions & 11 deletions .github/workflows/L1-Test.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,58 @@
name: Unit tests Common Utilities
name: L1 Unit Tests

on:
pull_request:
branches: [ develop, main ]
push:
branches: [ topic/RDK-57502 ]

env:
AUTOMATICS_UNAME: ${{ secrets.AUTOMATICS_UNAME }}
AUTOMATICS_PASSCODE: ${{ secrets.AUTOMATICS_PASSCODE }}

jobs:
execute-unit-tests-on-pr:
name: Execute unit tests in gtest test suite
execute-L1-tests-on-pr:
name: Execute L1 test suite in test container environment
runs-on: ubuntu-latest
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull test container image
run: docker pull ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest

- name: Start test container
run: |
docker run -d --name native-platform -v ${{ github.workspace }}:/mnt/L1_CONTAINER_SHARED_VOLUME ghcr.io/rdkcentral/docker-device-mgt-service-test/native-platform:latest
- name: Run unit tests
run: sh unit_test.sh
- name: Run L1 Unit Tests inside container
run: docker exec -i native-platform /bin/bash -c "cd /mnt/L1_CONTAINER_SHARED_VOLUME/ && sh unit_test.sh"

- name: Upload test results to automatic test result management system
- name: Copy L1 test results to runner
run: |
docker cp native-platform:/tmp/Gtest_Report /tmp/Gtest_Report
ls -l /tmp/Gtest_Report
upload-test-results:
Comment on lines +13 to +42

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 23 hours ago

To fix this problem, an explicit permissions block should be added to the workflow at the root or job level to restrict the GitHub Actions token to the minimum required privileges. In this workflow, only reading repository contents is necessary (for actions/checkout), so contents: read is sufficient. This permissions block can be placed at the top level of the workflow so that it applies to all jobs, unless a specific job requires additional permissions. Edit the .github/workflows/L1-Test.yaml file to add:

permissions:
  contents: read

after the name: block and before the on: block. No additional dependencies or code changes outside the workflow file are needed.

Suggested changeset 1
.github/workflows/L1-Test.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/L1-Test.yaml b/.github/workflows/L1-Test.yaml
--- a/.github/workflows/L1-Test.yaml
+++ b/.github/workflows/L1-Test.yaml
@@ -1,5 +1,8 @@
 name: L1 Unit Tests
 
+permissions:
+  contents: read
+
 on:
   push:
     branches: [ topic/RDK-57502 ]
EOF
@@ -1,5 +1,8 @@
name: L1 Unit Tests

permissions:
contents: read

on:
push:
branches: [ topic/RDK-57502 ]
Copilot is powered by AI and may make mistakes. Always verify output.
name: Upload L1 test results to automatic test result management system
needs: execute-L1-tests-on-pr
runs-on: ubuntu-latest
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest
volumes:
- /tmp/Gtest_Report:/tmp/Gtest_Report

steps:
- name: Upload results
if: github.repository_owner == 'rdkcentral'
run: |
echo "Contents in /tmp/Gtest_Report:"
ls -l /tmp/Gtest_Report
git config --global --add safe.directory `pwd`
gtest-json-result-push.py /tmp/Gtest_Report https://rdkeorchestrationservice.apps.cloud.comcast.net/rdke_orchestration_api/push_unit_test_results `pwd`

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
3 changes: 1 addition & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
# SPDX-License-Identifier: Apache-2.0
#

SUBDIRS = parsejson dwnlutils utils

SUBDIRS = parsejson dwnlutils utils uploadutils
14 changes: 12 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ PKG_CHECK_MODULES([cjson], [libcjson >= 1.7.12])
PKG_CHECK_MODULES([curl], [libcurl >= 7.60.0])
IS_LIBRDKCERTSEL_ENABLED=" "

AC_ARG_ENABLE([cpc-code],
[AS_HELP_STRING([--enable-cpc-code], [Enable CPC code support])],
[USE_CPC_CODE="$enableval"],
[USE_CPC_CODE=no])

AM_CONDITIONAL([USE_CPC_CODE], [test "$USE_CPC_CODE" = "yes"])

if test "$USE_CPC_CODE" = "yes"; then
AC_DEFINE([USE_CPC_CODE], [1], [Define to enable CPC CODE support])
fi

AC_ARG_ENABLE([rdkcertselector],
AS_HELP_STRING([--enable-rdkcertselector],[enables rdkcertselector replacement (default is no)]),
[
Expand Down Expand Up @@ -87,11 +98,10 @@ AC_CONFIG_FILES([Makefile
dwnlutils/Makefile
utils/Makefile
parsejson/Makefile
uploadutils/Makefile
])

BUILD_BINS="false"
AM_CONDITIONAL([build_parsejson_bins], [test "x$BUILD_BINS" = xtrue])

AC_OUTPUT


1 change: 1 addition & 0 deletions unit-test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#

AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS = uploadutil

# Define the program name and the source files
bin_PROGRAMS = system_utils_gtest rdk_fwdl_utils_gtest common_device_api_gtest urlHelper_gtest json_parse_gtest downloadUtil_gtest
Expand Down
2 changes: 1 addition & 1 deletion unit-test/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ AC_C_CONST
AC_FUNC_MALLOC
AC_FUNC_REALLOC
# Generate the Makefile
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile uploadutil/Makefile])
# Generate the configure script
AC_OUTPUT
60 changes: 60 additions & 0 deletions unit-test/uploadutil/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2023 Comcast Cable Communications Management, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

AUTOMAKE_OPTIONS = subdir-objects

# Define the program name and the source files
bin_PROGRAMS = uploadUtil_gtest upload_status_gtest codebig_upload_gtest mtls_upload_gtest

# Define the include directories
COMMON_CPPFLAGS = -std=c++11 -I/usr/include/cjson -I../../utils -I../../mocks -I../../uploadutils -I../../dwnlutils -I../../parsejson -DGTEST_ENABLE -DLIBRDKCERTSELECTOR

# Define the libraries to link against
COMMON_LDADD = -lcjson -lgcov -lcurl -lgtest -lgtest_main -lgmock_main -lgmock -lfwutils -ldwnlutil

# Define the compiler flags
COMMON_CXXFLAGS = -frtti -fprofile-arcs -ftest-coverage -fpermissive

# Define the source files
uploadUtil_gtest_SOURCES = uploadUtil_gtest.cpp ../../uploadutils/uploadUtil.c ../../utils/rdkv_cdl_log_wrapper.c ../../parsejson/json_parse.c

upload_status_gtest_SOURCES = upload_status_gtest.cpp ../../uploadutils/upload_status.c ../../utils/rdkv_cdl_log_wrapper.c

codebig_upload_gtest_SOURCES = codebig_upload_gtest.cpp ../../uploadutils/codebig_upload.c ../../utils/rdkv_cdl_log_wrapper.c

mtls_upload_gtest_SOURCES = mtls_upload_gtest.cpp ../../uploadutils/mtls_upload.c ../../utils/rdkv_cdl_log_wrapper.c

# Apply common properties to each program
uploadUtil_gtest_CPPFLAGS = $(COMMON_CPPFLAGS)
uploadUtil_gtest_LDADD = $(COMMON_LDADD)
uploadUtil_gtest_CXXFLAGS = $(COMMON_CXXFLAGS)
uploadUtil_gtest_CFLAGS = $(COMMON_CXXFLAGS)

upload_status_gtest_CPPFLAGS = $(COMMON_CPPFLAGS)
upload_status_gtest_LDADD = $(COMMON_LDADD)
upload_status_gtest_CXXFLAGS = $(COMMON_CXXFLAGS)
upload_status_gtest_CFLAGS = $(COMMON_CXXFLAGS)

codebig_upload_gtest_CPPFLAGS = $(COMMON_CPPFLAGS)
codebig_upload_gtest_LDADD = $(COMMON_LDADD)
codebig_upload_gtest_CXXFLAGS = $(COMMON_CXXFLAGS)
codebig_upload_gtest_CFLAGS = $(COMMON_CXXFLAGS)

mtls_upload_gtest_CPPFLAGS = $(COMMON_CPPFLAGS)
mtls_upload_gtest_LDADD = $(COMMON_LDADD)
mtls_upload_gtest_CXXFLAGS = $(COMMON_CXXFLAGS)
mtls_upload_gtest_CFLAGS = $(COMMON_CXXFLAGS)
Loading
Loading