From c06fff6e65e6c94f84c5c9f23392aeb5f9065e79 Mon Sep 17 00:00:00 2001 From: Saikrishna Bairamoni <84093461+SaikrishnaBairamoni@users.noreply.github.com> Date: Fri, 1 Sep 2023 11:35:24 -0400 Subject: [PATCH 1/4] build asn1-codec and add sonar cloud --- .github/workflows/ci.yml | 132 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6889f77 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,132 @@ +name: asn1-codec +on: + push: + +jobs: + asn1-codec: + runs-on: ubuntu-latest + container: + image: ubuntu:jammy-20230126 + env: + working-directory: /asn1_codec + BUILD_WRAPPER_OUT_DIR: "$GITHUB_WORKSPACE/bw-output" + options: "--user root" + steps: + - name: checkout code + uses: actions/checkout@v2 + - name: Install Deps + run: | + apt update + apt-get -y install sudo wget curl gnupg lsb-release gcovr unzip gcc-multilib libasan* + sudo apt-get -y install software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + chmod +x /usr/local/bin/docker-compose + sudo apt-get -y update + sudo apt-get -y install docker-ce + working-directory: ${{env.working-directory}} + - name: install g++ + run: | + sudo apt-get -y install build-essential + sudo apt -y install cmake g++ libprotobuf-dev protobuf-compiler + sudo apt -y install apt-transport-https ca-certificates curl software-properties-common + export CXX="g++" + sudo apt install -y gcc-12 g++-12 + sudo apt -y install libpng-dev libgraphicsmagick1-dev libcairo2-dev + working-directory: ${{env.working-directory}} + - name: install librdkafka + run: | + sudo apt-get -y update && sudo apt-get -y upgrade + sudo apt-get -y install automake flex bison + sudo apt-get -y install build-essential + sudo apt -y install cmake g++ libprotobuf-dev protobuf-compiler + sudo apt-get install autotools-dev + sudo apt -y install apt-transport-https ca-certificates curl software-properties-common + git clone --depth 1 https://github.com/confluentinc/librdkafka.git librdkafka + cd librdkafka + cmake -H. -B_cmake_build + cmake --build _cmake_build + cmake --build _cmake_build --target install + working-directory: ${{env.working-directory}} + - name: Install pugixml + run: | + git clone https://github.com/vlm/asn1c.git + git clone https://github.com/zeux/pugixml.git + ls -la && pwd + cd ./pugixml && mkdir -p build && cd build && cmake .. && make && make install + working-directory: ${{env.working-directory}} + - name: Build and install asn1c submodule + run: | + ls -la && pwd + sudo apt-get -y install libtool autoconf + cd ./asn1c && aclocal && test -f configure || autoreconf -iv && ./configure && make && make install + working-directory: ${{env.working-directory}} + - name: Generate ASN.1 API. + run: | + ls -la && pwd + export LD_LIBRARY_PATH=/usr/local/lib + git clone https://github.com/usdot-jpo-ode/scms-asn1.git + cd ./asn1c_combined && bash doIt.sh + working-directory: ${{env.working-directory}} + - name: export + run: | + echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.profile + echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc + echo "export CC=gcc" >> ~/.profile + echo "export CC=gcc" >> ~/.bashrc + working-directory: ${{env.working-directory}} + - name: Install sonar-scanner and build-wrapper + uses: SonarSource/sonarcloud-github-c-cpp@v1 + - name: Build and Generate test coverage + run: | + sudo su - root + sudo chmod o+w /root + sudo chmod 755 -R /__w/asn1_codec/asn1_codec/ + export BUILD_WRAPPER_OUT_DIR=$GITHUB_WORKSPACE/bw-output + build-wrapper-linux-x86-64 --out-dir $GITHUB_WORKSPACE/bw-output ./build.sh + mkdir coverage + cd coverage + gcov $GITHUB_WORKSPACE/kafka-test/src/*.cpp --object-directory /__w/asn1-codec/asn1-codec/build/kafka-test/CMakeFiles/Kafka-TestLib.dir/src/ + gcov $GITHUB_WORKSPACE/src/*.cpp --object-directory /__w/asn1-codec/asn1-codec/build/CMakeFiles/ppm_tests.dir/src/ + working-directory: ${{env.working-directory}} + - name: Archive code coverage results + uses: actions/upload-artifact@v3 + with: + name: asn1-codec + path: /__w/asn1-codec/asn1-codec/coverage/ + - name: Archive buildwrapper output + uses: actions/upload-artifact@v3 + with: + name: asn1-codec + path: /home/runner/work/asn1-codec/asn1-codec/bw-output + - name: Setup SonarScanner + uses: warchant/setup-sonar-scanner@v4 + with: + version: 4.8.0.2856 + - name: Generate sonar properties file + run: | + cat < /tmp/sonar-scanner.properties + sonar.host.url=https://sonarcloud.io + sonar.projectName=asn1-codec + sonar.projectVersion=1.0 + sonar.projectKey=usdot-jpo-ode-1_asn1-codec + sonar.organization=usdot-jpo-ode-1 + sonar.sources=src,kafka-test/src,include + sonar.cfamily.build-wrapper-output=bw-output + sonar.cfamily.gcov.reportsPath=/__w/asn1-codec/asn1-codec/coverage/ + sonar.sonar.projectBaseDir=/home/runner/work/asn1-codec/asn1-codec/ + sonar.exclusions=**/*.java + sonar.coverage.exclusions=**/*.java + sonar.exclusions=pugixml/tests/data/** + # Set Git as SCM sensor + sonar.scm.disabled=true + sonar.scm.provider=git + sonar.sourceEncoding=UTF-8 + EOF + - name: SonarScanner + uses: usdot-fhwa-stol/actions/sonar-scanner@main + with: + sonar-properties-path: /tmp/sonar-scanner.properties + sonar-token: ${{ secrets.SONAR_TOKEN }} + working-dir: $GITHUB_WORKSPACE From 253e3d31e61f822a692e664d481b9dd31f1ca6b5 Mon Sep 17 00:00:00 2001 From: Saikrishna Bairamoni <84093461+SaikrishnaBairamoni@users.noreply.github.com> Date: Fri, 1 Sep 2023 11:46:21 -0400 Subject: [PATCH 2/4] add build.sh --- build.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..ef46842 --- /dev/null +++ b/build.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Copyright (C) 2018-2020 LEIDOS. +# +# 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. + +# script executes all kafka_clients and scheduling service build and coverage steps so that they can be singularly +# wrapped by the sonarcloud build-wrapper +set -e + +ls -la && pwd + +# build asn1_codec +mkdir build +cd build +cmake .. +cmake --build . +make +ctest --output-on-failure \ No newline at end of file From 6d7a6732266f172429ff1e262b75652b0b29fec1 Mon Sep 17 00:00:00 2001 From: Saikrishna Bairamoni <84093461+SaikrishnaBairamoni@users.noreply.github.com> Date: Sun, 10 Sep 2023 17:58:52 -0400 Subject: [PATCH 3/4] clean up and add comments --- .github/workflows/ci.yml | 264 ++++++++++++++++++++------------------- 1 file changed, 136 insertions(+), 128 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6889f77..3b8db9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,132 +1,140 @@ name: asn1-codec -on: - push: + +on: [pull_request, push] + # Trigger this workflow on code pushes and pull requests jobs: asn1-codec: - runs-on: ubuntu-latest - container: - image: ubuntu:jammy-20230126 - env: - working-directory: /asn1_codec - BUILD_WRAPPER_OUT_DIR: "$GITHUB_WORKSPACE/bw-output" - options: "--user root" - steps: - - name: checkout code - uses: actions/checkout@v2 - - name: Install Deps - run: | - apt update - apt-get -y install sudo wget curl gnupg lsb-release gcovr unzip gcc-multilib libasan* - sudo apt-get -y install software-properties-common - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose - sudo apt-get -y update - sudo apt-get -y install docker-ce - working-directory: ${{env.working-directory}} - - name: install g++ - run: | - sudo apt-get -y install build-essential - sudo apt -y install cmake g++ libprotobuf-dev protobuf-compiler - sudo apt -y install apt-transport-https ca-certificates curl software-properties-common - export CXX="g++" - sudo apt install -y gcc-12 g++-12 - sudo apt -y install libpng-dev libgraphicsmagick1-dev libcairo2-dev - working-directory: ${{env.working-directory}} - - name: install librdkafka - run: | - sudo apt-get -y update && sudo apt-get -y upgrade - sudo apt-get -y install automake flex bison - sudo apt-get -y install build-essential - sudo apt -y install cmake g++ libprotobuf-dev protobuf-compiler - sudo apt-get install autotools-dev - sudo apt -y install apt-transport-https ca-certificates curl software-properties-common - git clone --depth 1 https://github.com/confluentinc/librdkafka.git librdkafka - cd librdkafka - cmake -H. -B_cmake_build - cmake --build _cmake_build - cmake --build _cmake_build --target install - working-directory: ${{env.working-directory}} - - name: Install pugixml - run: | - git clone https://github.com/vlm/asn1c.git - git clone https://github.com/zeux/pugixml.git - ls -la && pwd - cd ./pugixml && mkdir -p build && cd build && cmake .. && make && make install - working-directory: ${{env.working-directory}} - - name: Build and install asn1c submodule - run: | - ls -la && pwd - sudo apt-get -y install libtool autoconf - cd ./asn1c && aclocal && test -f configure || autoreconf -iv && ./configure && make && make install - working-directory: ${{env.working-directory}} - - name: Generate ASN.1 API. - run: | - ls -la && pwd - export LD_LIBRARY_PATH=/usr/local/lib - git clone https://github.com/usdot-jpo-ode/scms-asn1.git - cd ./asn1c_combined && bash doIt.sh - working-directory: ${{env.working-directory}} - - name: export - run: | - echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.profile - echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc - echo "export CC=gcc" >> ~/.profile - echo "export CC=gcc" >> ~/.bashrc - working-directory: ${{env.working-directory}} - - name: Install sonar-scanner and build-wrapper - uses: SonarSource/sonarcloud-github-c-cpp@v1 - - name: Build and Generate test coverage - run: | - sudo su - root - sudo chmod o+w /root - sudo chmod 755 -R /__w/asn1_codec/asn1_codec/ - export BUILD_WRAPPER_OUT_DIR=$GITHUB_WORKSPACE/bw-output - build-wrapper-linux-x86-64 --out-dir $GITHUB_WORKSPACE/bw-output ./build.sh - mkdir coverage - cd coverage - gcov $GITHUB_WORKSPACE/kafka-test/src/*.cpp --object-directory /__w/asn1-codec/asn1-codec/build/kafka-test/CMakeFiles/Kafka-TestLib.dir/src/ - gcov $GITHUB_WORKSPACE/src/*.cpp --object-directory /__w/asn1-codec/asn1-codec/build/CMakeFiles/ppm_tests.dir/src/ - working-directory: ${{env.working-directory}} - - name: Archive code coverage results - uses: actions/upload-artifact@v3 - with: - name: asn1-codec - path: /__w/asn1-codec/asn1-codec/coverage/ - - name: Archive buildwrapper output - uses: actions/upload-artifact@v3 - with: - name: asn1-codec - path: /home/runner/work/asn1-codec/asn1-codec/bw-output - - name: Setup SonarScanner - uses: warchant/setup-sonar-scanner@v4 - with: - version: 4.8.0.2856 - - name: Generate sonar properties file - run: | - cat < /tmp/sonar-scanner.properties - sonar.host.url=https://sonarcloud.io - sonar.projectName=asn1-codec - sonar.projectVersion=1.0 - sonar.projectKey=usdot-jpo-ode-1_asn1-codec - sonar.organization=usdot-jpo-ode-1 - sonar.sources=src,kafka-test/src,include - sonar.cfamily.build-wrapper-output=bw-output - sonar.cfamily.gcov.reportsPath=/__w/asn1-codec/asn1-codec/coverage/ - sonar.sonar.projectBaseDir=/home/runner/work/asn1-codec/asn1-codec/ - sonar.exclusions=**/*.java - sonar.coverage.exclusions=**/*.java - sonar.exclusions=pugixml/tests/data/** - # Set Git as SCM sensor - sonar.scm.disabled=true - sonar.scm.provider=git - sonar.sourceEncoding=UTF-8 - EOF - - name: SonarScanner - uses: usdot-fhwa-stol/actions/sonar-scanner@main - with: - sonar-properties-path: /tmp/sonar-scanner.properties - sonar-token: ${{ secrets.SONAR_TOKEN }} - working-dir: $GITHUB_WORKSPACE + runs-on: ubuntu-latest + container: + image: ubuntu:jammy-20230126 + env: + working-directory: /asn1_codec + BUILD_WRAPPER_OUT_DIR: "$GITHUB_WORKSPACE/bw-output" + options: "--user root" + steps: + - name: checkout code + uses: actions/checkout@v2 + # Checkout the code from the repository + + - name: Install necessary dependencies + run: | + apt update + apt-get -y install sudo wget curl gnupg lsb-release gcovr unzip gcc-multilib libasan* + sudo apt-get -y install software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + chmod +x /usr/local/bin/docker-compose + sudo apt-get -y update + sudo apt-get -y install docker-ce + working-directory: ${{ env.working-directory }} + + - name: Install g++ and related dependencies + run: | + sudo apt-get -y install build-essential + sudo apt -y install cmake g++ libprotobuf-dev protobuf-compiler + sudo apt -y install apt-transport-https ca-certificates curl software-properties-common + export CXX="g++" + sudo apt install -y gcc-12 g++-12 + sudo apt -y install libpng-dev libgraphicsmagick1-dev libcairo2-dev + working-directory: ${{ env.working-directory }} + + - name: Install librdkafka + run: | + sudo apt-get -y update && sudo apt-get -y upgrade + sudo apt-get -y install automake flex bison + sudo apt-get -y install build-essential + sudo apt -y install cmake g++ libprotobuf-dev protobuf-compiler + sudo apt-get install autotools-dev + sudo apt -y install apt-transport-https ca-certificates curl software-properties-common + git clone --depth 1 https://github.com/confluentinc/librdkafka.git librdkafka + cd librdkafka + cmake -H. -B_cmake_build + cmake --build _cmake_build + cmake --build _cmake_build --target install + working-directory: ${{ env.working-directory }} + + - name: Install pugixml + run: | + git clone https://github.com/vlm/asn1c.git + git clone https://github.com/zeux/pugixml.git + cd ./pugixml && mkdir -p build && cd build && cmake .. && make && make install + working-directory: ${{ env.working-directory }} + + - name: Build and install asn1c submodule + run: | + sudo apt-get -y install libtool autoconf + cd ./asn1c && aclocal && test -f configure || autoreconf -iv && ./configure && make && make install + working-directory: ${{ env.working-directory }} + + - name: Generate ASN.1 API. + run: | + export LD_LIBRARY_PATH=/usr/local/lib + git clone https://github.com/usdot-jpo-ode/scms-asn1.git + cd ./asn1c_combined && bash doIt.sh + working-directory: ${{ env.working-directory }} + + - name: Export environment variables + run: | + echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.profile + echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc + echo "export CC=gcc" >> ~/.profile + echo "export CC=gcc" >> ~/.bashrc + working-directory: ${{ env.working-directory }} + + - name: Install sonar-scanner and build-wrapper + uses: SonarSource/sonarcloud-github-c-cpp@v1 + # Install SonarScanner and build-wrapper for code analysis + + - name: Build and Generate test coverage + run: | + sudo su - root + sudo chmod o+w /root + sudo chmod 755 -R /__w/asn1_codec/asn1_codec/ + export BUILD_WRAPPER_OUT_DIR=$GITHUB_WORKSPACE/bw-output + build-wrapper-linux-x86-64 --out-dir $GITHUB_WORKSPACE/bw-output ./build.sh + mkdir coverage + cd coverage + gcov $GITHUB_WORKSPACE/kafka-test/src/*.cpp --object-directory /__w/asn1-codec/asn1-codec/build/kafka-test/CMakeFiles/Kafka-TestLib.dir/src/ + gcov $GITHUB_WORKSPACE/src/*.cpp --object-directory /__w/asn1-codec/asn1-codec/build/CMakeFiles/ppm_tests.dir/src/ + working-directory: ${{ env.working-directory }} + + - name: Archive code coverage results + uses: actions/upload-artifact@v3 + with: + name: asn1-codec + path: /__w/asn1-codec/asn1-codec/coverage/ + # Archive code coverage results for later reference + + - name: Archive buildwrapper output + uses: actions/upload-artifact@v3 + with: + name: asn1-codec + path: /home/runner/work/asn1-codec/asn1-codec/bw-output + # Archive build-wrapper output + + - name: Setup SonarScanner + uses: warchant/setup-sonar-scanner@v4 + with: + version: 4.8.0.2856 + # Set up SonarScanner for code analysis + + - name: Generate sonar properties file + run: | + # Generate SonarScanner properties file + cat < /tmp/sonar-scanner.properties + sonar.host.url=https://sonarcloud.io + sonar.projectName=asn1-codec + sonar.projectVersion=1.0 + sonar.projectKey=usdot-jpo-ode-1_asn1-codec + sonar.organization=usdot-jpo-ode-1 + sonar.sources=src,kafka-test/src,include + sonar.cfamily.build-wrapper-output=bw-output + sonar.cfamily.gcov.reportsPath=/__w/asn1-codec/asn + - name: SonarScanner + uses: usdot-fhwa-stol/actions/sonar-scanner@main + with: + sonar-properties-path: /tmp/sonar-scanner.properties + sonar-token: ${{ secrets.SONAR_TOKEN }} + working-dir: $GITHUB_WORKSPACE \ No newline at end of file From d833658b3872b7bdb8f2e4f73dad037ae91d578a Mon Sep 17 00:00:00 2001 From: Saikrishna Bairamoni <84093461+SaikrishnaBairamoni@users.noreply.github.com> Date: Sun, 10 Sep 2023 18:00:04 -0400 Subject: [PATCH 4/4] fix --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b8db9a..59cf8cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,16 @@ jobs: sonar.organization=usdot-jpo-ode-1 sonar.sources=src,kafka-test/src,include sonar.cfamily.build-wrapper-output=bw-output - sonar.cfamily.gcov.reportsPath=/__w/asn1-codec/asn + sonar.cfamily.gcov.reportsPath=/__w/asn1-codec/asn1-codec/coverage/ + sonar.sonar.projectBaseDir=/home/runner/work/asn1-codec/asn1-codec/ + sonar.exclusions=**/*.java + sonar.coverage.exclusions=**/*.java + sonar.exclusions=pugixml/tests/data/** + # Set Git as SCM sensor + sonar.scm.disabled=true + sonar.scm.provider=git + sonar.sourceEncoding=UTF-8 + EOF - name: SonarScanner uses: usdot-fhwa-stol/actions/sonar-scanner@main with: