Skip to content

Commit

Permalink
Re-add s2p_version.cpp, renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 10, 2023
1 parent a4a41ef commit 477b71f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 91 deletions.
36 changes: 11 additions & 25 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ on:

jobs:
code_analysis:
runs-on: ubuntu-latest
runs-on: [k8s]

defaults:
run:
working-directory: cpp

env:
PACKAGES: protobuf-compiler libspdlog-dev libpcap-dev libgmock-dev
BUILD_WRAPPER_OUT_DIR: ".build_wrapper_out"
SONAR_SERVER_URL: "https://sonarcloud.io"
SONAR_PROJECT_KEY: "uweseimet_scsi2pi"
Expand All @@ -32,36 +31,23 @@ jobs:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Install additional packages
run: sudo apt install --yes $PACKAGES

- name: Set up Python for gcovr
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install gcovr
run: pip install gcovr==5.0 # 5.1 is not supported

- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2

- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir $BUILD_WRAPPER_OUT_DIR \
make -j $(nproc) coverage DEBUG=1
make -j2 coverage DEBUG=1
- name: Generate coverage data
run: gcovr --sonarqube > coverage.xml

- name: Run sonar-scanner
run: |
sonar-scanner \
--define sonar.host.url=$SONAR_SERVER_URL \
--define sonar.projectKey=$SONAR_PROJECT_KEY \
--define sonar.organization=$SONAR_ORGANIZATION \
--define sonar.cfamily.build-wrapper-output=$BUILD_WRAPPER_OUT_DIR \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.exclusions="obj/**,lib/**,bin/**,generated/**" \
--define sonar.coverage.exclusions="test/**" \
--define sonar.cpd.exclusions="test/**"
--define sonar.host.url=$SONAR_SERVER_URL \
--define sonar.projectKey=$SONAR_PROJECT_KEY \
--define sonar.organization=$SONAR_ORGANIZATION \
--define sonar.cfamily.build-wrapper-output=$BUILD_WRAPPER_OUT_DIR \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.branch.name=${{ inputs.branch }} \
--define sonar.exclusions="obj/**,lib/**,bin/**,generated/**" \
--define sonar.coverage.exclusions="test/**" \
--define sonar.cpd.exclusions="test/**"
53 changes: 0 additions & 53 deletions .github/workflows/analyze_k8s.yml

This file was deleted.

4 changes: 2 additions & 2 deletions cpp/shared/s2p_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace filesystem;
string s2p_util::GetVersionString()
{
return fmt::format("{0}.{1}{2}{3}", s2p_major_version, s2p_minor_version,
s2p_patch_version <= 0 ? "" : "." + to_string(s2p_patch_version), s2p_version_suffix);
s2p_revision <= 0 ? "" : "." + to_string(s2p_revision), s2p_suffix);
}

vector<string> s2p_util::Split(const string& s, char separator, int limit)
Expand Down Expand Up @@ -112,7 +112,7 @@ string s2p_util::Banner(string_view app)

s << "SCSI Target Emulator and SCSI Initiator Tools SCSI2Pi " << app << "\n"
<< "Version " << GetVersionString();
if (!s2p_version_suffix.empty()) {
if (!s2p_suffix.empty()) {
s << " (" << __DATE__ << ' ' << __TIME__ << ")";
}
s << "\nCopyright (C) 2016-2020 GIMONS\n"
Expand Down
14 changes: 14 additions & 0 deletions cpp/shared/s2p_version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//---------------------------------------------------------------------------
//
// SCSI target emulator and SCSI initiator tools for the Raspberry Pi
//
// Copyright (C) 2023 Uwe Seimet
//
//---------------------------------------------------------------------------

#include "s2p_version.h"

const int s2p_major_version = 0;
const int s2p_minor_version = 9;
const int s2p_revision = 0;
const std::string s2p_suffix = "-devel";
11 changes: 4 additions & 7 deletions cpp/shared/s2p_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

#include <string>

inline const int s2p_major_version = 0;

inline const int s2p_minor_version = 9;

inline const int s2p_patch_version = 0;

extern const int s2p_major_version;
extern const int s2p_minor_version;
extern const int s2p_revision;
// Version suffix, usually indicating a development version
inline const std::string s2p_version_suffix = "-devel";
extern const std::string s2p_suffix;
4 changes: 2 additions & 2 deletions cpp/shared_command/command_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ void CommandResponse::GetVersionInfo(PbVersionInfo& version_info) const
{
version_info.set_major_version(s2p_major_version);
version_info.set_minor_version(s2p_minor_version);
version_info.set_patch_version(s2p_patch_version);
version_info.set_suffix(s2p_version_suffix);
version_info.set_patch_version(s2p_revision);
version_info.set_suffix(s2p_suffix);
version_info.set_identifier("SCSI2Pi");
}

Expand Down
5 changes: 3 additions & 2 deletions cpp/test/command_response_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ TEST(CommandResponseTest, GetServerInfo)

EXPECT_EQ(s2p_major_version, info1.version_info().major_version());
EXPECT_EQ(s2p_minor_version, info1.version_info().minor_version());
EXPECT_EQ(s2p_patch_version, info1.version_info().patch_version());
EXPECT_EQ(s2p_revision, info1.version_info().patch_version());
EXPECT_EQ(level::level_string_views[get_level()], info1.log_level_info().current_log_level());
EXPECT_EQ("default_folder", info1.image_files_info().default_image_folder());
EXPECT_EQ(1234, info1.image_files_info().depth());
Expand Down Expand Up @@ -223,7 +223,8 @@ TEST(CommandResponseTest, GetVersionInfo)
response.GetVersionInfo(info);
EXPECT_EQ(s2p_major_version, info.major_version());
EXPECT_EQ(s2p_minor_version, info.minor_version());
EXPECT_EQ(s2p_patch_version, info.patch_version());
EXPECT_EQ(s2p_revision, info.patch_version());
EXPECT_EQ(s2p_suffix, info.suffix());
}

TEST(CommandResponseTest, GetLogLevelInfo)
Expand Down

0 comments on commit 477b71f

Please sign in to comment.