@@ -17,20 +17,36 @@ jobs:
1717
1818 build :
1919 name : Build & Test
20- runs-on : macos-14
20+ runs-on : macos-14 # Use macOS 14 (Sonoma) runner
21+
2122 steps :
22- - uses : actions/checkout@v4
23+ # Step 1: Check out the repository code
24+ - name : Checkout repository
25+ uses : actions/checkout@v4
26+
27+ # Step 2: Set up Homebrew package manager
2328 - name : Set up Homebrew
2429 id : set-up-homebrew
2530 uses : Homebrew/actions/setup-homebrew@master
26- - name : Install packages
27- run : >
28- bash ./.github/workflows/brew.sh
29- - name : Build libraries
30- run : >
31- bash ./.github/workflows/build.sh
32- - name : Select Xcode
33- run : sudo xcode-select -switch /Applications/Xcode_15.2.app && /usr/bin/xcodebuild -version
31+
32+ # Step 3: Install required dependencies using Homebrew
33+ - name : Install dependencies
34+ run : bash ./.github/workflows/brew.sh
35+
36+ # Step 4: Build project external libraries
37+ - name : Build C++ Libraries
38+ run : bash ./.github/workflows/build.sh
39+
40+ # Step 5: Configure Xcode version
41+ - name : Select Xcode version
42+ run : |
43+ sudo xcode-select -switch /Applications/Xcode_15.2.app
44+ /usr/bin/xcodebuild -version
45+ # Run XCode tests with specific configurations:
46+ # - Builds and runs the test suite
47+ # - Generates code coverage reports
48+ # - Uses PostgreSQL and libpqxx external dependencies
49+ # - Outputs results in JUnit format
3450 - name : Run tests
3551 run : >
3652 CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
@@ -40,21 +56,30 @@ jobs:
4056 -resultBundlePath TestResult/
4157 -enableCodeCoverage YES
4258 -derivedDataPath "${RUNNER_TEMP}/Build/DerivedData"
43- HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/" \
44- LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/" \
59+ GCC_GENERATE_TEST_COVERAGE_FILES=YES
60+ GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES
61+ CLANG_COVERAGE_MAPPING=YES
62+ CLANG_COVERAGE_MAPPING_LINKER_ARGS=YES
63+ DEBUG_INFORMATION_FORMAT="dwarf-with-dsym"
64+ BUILD_LIBRARY_FOR_DISTRIBUTION=NO
65+ HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/"
66+ LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/"
4567 OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib/pkgconfig -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14 -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pgxs -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pkgconfig"
46- clean build test
68+ clean build test
4769 | xcpretty -r junit && exit ${PIPESTATUS[0]}
4870 - name : Convert coverage report to sonarqube format
4971 run : >
5072 bash ./.github/workflows/xccov-to-sonarqube-generic.sh *.xcresult/ > sonarqube-generic-coverage.xml
73+ # Artifact will be available only for 1 day, this is because
74+ # it's only used to pass test data to SonarCloud only
5175 - name : Upload coverage report
5276 uses : actions/upload-artifact@v4
5377 with :
5478 path : sonarqube-generic-coverage.xml
5579 retention-days : 1 # Artifact will be available only for 5 days.
80+
5681 sonar-scan :
57- name : Sonar scan
82+ name : SonarCloud Scan
5883 runs-on : ubuntu-latest
5984 needs : build
6085 steps :
@@ -63,39 +88,52 @@ jobs:
6388 with :
6489 ref : ${{ github.HEAD_REF }}
6590 fetch-depth : 0
66- - name : Check compiler version
91+ - name : Check compiler version, for debugging
6792 run : |
6893 g++ --version
6994 cmake --version
70- - name : Build libraries
95+ - name : Build C++ Libraries
7196 run : >
7297 bash ./.github/workflows/build.sh
73- - name : Set up Python 3.8 for gcovr
98+ - name : Install Python 3.12 for gcovr
7499 uses : actions/setup-python@v5
75100 with :
76- python-version : 3.8
77- - name : install gcovr 5.0
101+ python-version : 3.12
102+ # Gcovr provides a utility for managing the use of the GNU gcov utility and generating
103+ # summarized code coverage results. This command is inspired by the Python coverage.py
104+ # package, which provides a similar utility for Python.
105+ # https://pypi.org/project/gcovr/
106+ - name : Install gcovr
78107 run : |
79- pip install gcovr==5.0 # 5.1 is not supported by sonarcloud
80- - name : Install sonar-scanner and build-wrapper
81- uses : SonarSource/sonarcloud-github-c-cpp@v3
108+ pip install gcovr==8.3
109+ # SonarQube Server and Cloud (formerly SonarQube and SonarCloud) is a widely used static
110+ # analysis solution for continuous code quality and security inspection.
111+ # This action now supports and is the official entrypoint for scanning C++ projects via GitHub actions.
112+ # https://github.com/SonarSource/sonarqube-scan-action
113+ - name : Install Build Wrapper
114+ uses :
SonarSource/sonarqube-scan-action/[email protected] 115+ # This step installs the SonarQube build wrapper, which is necessary for analyzing C/C++ projects.
116+
117+ # Downloads all artifacts generated by previous steps in the workflow
82118 - name : Download all workflow run artifacts
83119 uses : actions/download-artifact@v4
84- - name : Unpack Artifact
85- run : >
86- ls -l ./
120+
121+ # Configures the CMake build system, specifying the source directory and build directory, and setting the build type
87122 - name : Configure CMake
88- # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
89- # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
90123 run : cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
124+
125+ # Runs the build wrapper to capture build commands and outputs them to the specified directory. Then builds the project using CMake
91126 - name : Run build-wrapper
92127 run : |
93128 build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
94- - name : Run sonar-scanner
129+
130+ # Performs the SonarQube scan using the scan action. Uses captured build commands for analysis and requires GitHub and SonarQube tokens for authentication
131+ - name : SonarQube Scan
132+ uses :
SonarSource/[email protected] 95133 env :
96134 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
97- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
98- run : |
99- sonar-scanner \
100- --define sonar.cfamily.build-wrapper-output ="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
101- -Dsonar .coverageReportPaths=artifact/sonarqube-generic-coverage.xml
135+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
136+ with :
137+ args : >
138+ --define sonar.cfamily.compile-commands ="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
139+ --define sonar .coverageReportPaths=artifact/sonarqube-generic-coverage.xml
0 commit comments