PMP2-385 Add UTC time as a new setting #196
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
libhnz_branch: | |
description: 'Branch to use for libhnz' | |
required: true | |
default: 'main' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
env: | |
SONAR_SCANNER_VERSION: 5.0.1.3006 # Find the latest version in the "Windows" link on this page: | |
# https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/ | |
SONAR_SERVER_URL: "https://sonarcloud.io" | |
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
- name: Cache SonarQube packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Download and set up sonar-scanner | |
env: | |
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip | |
run: | | |
mkdir -p $HOME/.sonar | |
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} | |
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | |
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH | |
- name: Download and set up build-wrapper | |
env: | |
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip | |
run: | | |
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} | |
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ | |
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH | |
- name: Download and install Fledge | |
env: | |
FLEDGE_REPO_URL: "https://github.com/fledge-iot/fledge/archive/refs/heads/develop.zip" | |
run: | | |
curl -sSLo fledge-pkg.zip ${{ env.FLEDGE_REPO_URL }} | |
unzip -o fledge-pkg.zip -d $HOME | |
mv $HOME/fledge-develop $HOME/fledge | |
cd $HOME/fledge | |
sudo apt-get update | |
sudo apt-get install libcurl4-openssl-dev | |
sudo $HOME/fledge/requirements.sh | |
sudo make install | |
sudo mkdir -p /usr/include/fledge/rapidjson/ | |
find $HOME/fledge/C/common/ -name '*.h' -exec sudo cp -prv '{}' '/usr/include/fledge/' ';' | |
find $HOME/fledge/C/plugins/ -name '*.h' -exec sudo cp -prv '{}' '/usr/include/fledge/' ';' | |
find $HOME/fledge/C/services/ -name '*.h' -exec sudo cp -prv '{}' '/usr/include/fledge/' ';' | |
find $HOME/fledge/C/tasks/ -name '*.h' -exec sudo cp -prv '{}' '/usr/include/fledge/' ';' | |
find $HOME/fledge/C/thirdparty/Simple-Web-Server/ -name '*.hpp' -exec sudo cp -prv '{}' '/usr/include/fledge' ';' | |
sudo cp -prv $HOME/fledge/C/thirdparty/rapidjson/include/rapidjson/* /usr/include/fledge/rapidjson/ | |
sudo mkdir -p /usr/lib/fledge/ | |
sudo cp -prv /usr/local/fledge/lib/* /usr/lib/fledge/ | |
- name: Download and install libhnz | |
env: | |
LIBHNZ_REPO_URL: "https://github.com/fledge-power/libhnz.git" | |
LIBHNZ_BRANCH: ${{ github.event.inputs.libhnz_branch || 'main' }} | |
run: | | |
cd $HOME | |
git clone ${{ env.LIBHNZ_REPO_URL }} | |
cd $HOME/libhnz | |
git checkout ${{ env.LIBHNZ_BRANCH }} | |
cd $HOME/libhnz/src/hnz | |
./compilation.sh | |
- name: Download and install Google Unit Test framework | |
run: | | |
sudo apt-get install libgtest-dev | |
cd /usr/src/gtest | |
sudo cmake CMakeLists.txt | |
sudo make | |
sudo apt-get install libgmock-dev | |
- name: Download and install gcovr | |
run: | | |
sudo apt-get install gcovr | |
- name: Run build-wrapper | |
run: | | |
chmod +x mkversion | |
export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib | |
export LIB_HNZ=$HOME/libhnz | |
mkdir build | |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Coverage | |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release | |
cd build | |
make | |
make hnz_coverage_sonar | |
- name: Run sonar-scanner | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" --define sonar.organization="fledge-power" --define sonar.projectKey="fledge-power_fledge-south-hnz" --define sonar.inclusions="src/*,include/*" --define sonar.coverageReportPaths="build/hnz_coverage_sonar-sonarqube.xml" |