From 9fb83c37cc0d83da9f019677e60bd39ea6005be2 Mon Sep 17 00:00:00 2001 From: Suru Dissanaike <suru.dissanaike@iopsys.eu> Date: Thu, 9 Jan 2020 13:09:15 +0100 Subject: [PATCH] iopsys/code-analysis:0.2 --- code-analysis.yml | 51 ++++++++++++++++ docker/code-analysis/Dockerfile | 85 ++++++++++++++++++++++++++- docker/code-analysis/entrypoint.sh | 9 +++ docker/code-analysis/supervisord.conf | 2 +- 4 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 code-analysis.yml create mode 100755 docker/code-analysis/entrypoint.sh diff --git a/code-analysis.yml b/code-analysis.yml new file mode 100644 index 0000000..dbe7d43 --- /dev/null +++ b/code-analysis.yml @@ -0,0 +1,51 @@ +include: + - project: 'iopsys/gitlab-ci-pipeline' + file: '/static-code-analysis.yml' + +stages: + - static_code_analysis + - format_check + - build + - unit_testing + - dynamic_code_analysis + - api_testing + +variables: + DEBUG: 'TRUE' + SOURCE_FOLDER: "." + +run_format_check: + stage: format_check + image: iopsys/code-analysis:0.1 + allow_failure: true + script: + - "ls" + +run_build: + stage: build + image: iopsys/code-analysis:0.1 + allow_failure: true + script: + - "ls" + +run_unit_testing: + stage: unit_testing + image: iopsys/code-analysis:0.1 + allow_failure: true + script: + - "make test" + +run_dynamic_code_analysis: + stage: dynamic_code_analysis + image: iopsys/code-analysis:0.1 + allow_failure: true + script: + - "make test_coverage" + +run_api_testing: + stage: api_testing + image: iopsys/code-analysis:0.1 + allow_failure: true + script: + - "ls" + \ No newline at end of file diff --git a/docker/code-analysis/Dockerfile b/docker/code-analysis/Dockerfile index 8c8cabe..c4a6854 100644 --- a/docker/code-analysis/Dockerfile +++ b/docker/code-analysis/Dockerfile @@ -6,7 +6,7 @@ LABEL run="docker run -it --entrypoint /bin/bash --rm -v ${PWD}:/opt/work code-a # docker build -t code-analysis . # docker images -# docker tag <image id> iopsys/code-analysis:0.x +# docker tag <image id> iopsys/code-analysis:0.1 # docker push iopsys/code-analysis:0.x @@ -15,6 +15,7 @@ RUN \ # general tools git \ cmake \ + curl \ wget \ build-essential \ lcov \ @@ -41,7 +42,6 @@ RUN \ flawfinder - # Install dependent libraries RUN \ apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ @@ -59,6 +59,20 @@ RUN rm -rf /var/lib/apt/lists/* RUN mkdir /opt/dev RUN mkdir /etc/config +# install node +ENV NODE_VERSION=12.14.1 +RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash +ENV NVM_DIR=/root/.nvm +RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} +ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" +RUN node --version +RUN npm --version + +# install tap-junit +RUN npm i -g tap-junit + # Install JSON-C RUN \ @@ -122,7 +136,61 @@ RUN \ git checkout 44b32937a062ec4ffc9f7355841dc94ab6efa50f && \ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" . && \ make && \ - make install + sudo make install + +# nlohmann +RUN \ + cd /opt/dev && \ + git clone https://github.com/nlohmann/json.git && \ + cd json && \ + git checkout be61ad147000be4802173d0d118fd1b8109b4668 && \ + mkdir build && \ + cd build && \ + cmake .. && \ + cmake --build . && \ + sudo make install + +# json-schema-validator-cpp +RUN \ + cd /opt/dev && \ + git clone https://github.com/pboettch/json-schema-validator.git json-schema-validator-cpp && \ + cd json-schema-validator-cpp && \ + git checkout 3ec0e69a0bce7524f12a865b153b71d0d7ef2484 && \ + mkdir build && \ + cd build && \ + cmake .. -DBUILD_SHARED_LIBS=ON && \ + make && \ + sudo make install && \ + sudo ldconfig + + +# iopsys json-schema-validator +RUN \ + cd /opt/dev && \ + git clone https://dev.iopsys.eu/iopsys/json-schema-validator.git && \ + cd json-schema-validator && \ + git checkout devel && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE:String="Release" . && \ + make && \ + sudo make install && \ + sudo ldconfig + +# tap +RUN \ + cd /opt/dev && \ + git clone https://github.com/zorgnax/libtap.git && \ + cd libtap && \ + make && \ + sudo make install && \ + sudo ldconfig + +# git ubus-api-validator +RUN \ + cd /opt/dev && \ + git clone https://dev.iopsys.eu/iopsys/ubus-api-validator.git && \ + cd ubus-api-validator && \ + make && \ + sudo make install #install cpd WORKDIR /home/user @@ -136,3 +204,14 @@ WORKDIR /opt/work # Prepare supervisor RUN mkdir -p /var/log/supervisor COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Prepare JSON Schemas +RUN mkdir -p /usr/share/rpcd/schemas +RUN mkdir -p /usr/share/rpcd/definitions + +RUN node --version +RUN npm --version + +# Start entrypoint +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/code-analysis/entrypoint.sh b/docker/code-analysis/entrypoint.sh new file mode 100755 index 0000000..b7a547d --- /dev/null +++ b/docker/code-analysis/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -x + +# Start supervisor +/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf -l /var/log/supervisord.log -j /var/run/supervisord.pid + +#Start bash to enable an interactive session +/bin/bash diff --git a/docker/code-analysis/supervisord.conf b/docker/code-analysis/supervisord.conf index 648e140..77ce644 100644 --- a/docker/code-analysis/supervisord.conf +++ b/docker/code-analysis/supervisord.conf @@ -1,5 +1,5 @@ [supervisord] -nodaemon=true +nodaemon=false [program:ubusd] command=/bin/bash -c "/usr/sbin/ubusd" -- GitLab