diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f84e5cd..83b688a 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -14,25 +14,24 @@ jobs: # You can convert this to a matrix build if you need cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: sudo apt-get update && sudo apt-get install -y valgrind - - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Test - working-directory: ${{github.workspace}}/build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: make test && make memcheck + - uses: actions/checkout@v4 + - run: sudo apt-get update && sudo apt-get install -y valgrind + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: make test && make memcheck build_windows: name: c-build-windows diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 2592723..5285ce4 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -7,10 +7,33 @@ on: types: [opened, synchronize, reopened] jobs: + build_shared_library: + strategy: + matrix: + runs-on: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.runs-on }} + steps: + - uses: actions/checkout@v4 + - name: Build DLL & Set file name windows + if: matrix.runs-on == 'windows-latest' + shell: pwsh + run: | + .\cmake_build.bat -s + echo "filename=uc_sgsim.dll" >> $env:GITHUB_ENV + - name: Build Shared Library & Set file name ubuntu + if: matrix.runs-on == 'ubuntu-latest' + run: | + sh ./cmake_build.sh -s + echo "filename=uc_sgsim.so" >> "$GITHUB_ENV" + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.runs-on }}-shared-library + path: ./uc_sgsim/c_core/${{ env.filename }} + python_test: name: py-unittest runs-on: ubuntu-latest - + needs: build_shared_library strategy: max-parallel: 5 matrix: @@ -31,10 +54,17 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Download All Artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + - run: | + mv ./uc_sgsim.so ./uc_sgsim/c_core - name: Run tests to generate coverage statistics run: | pytest -n auto --cov --cov-report xml:py_coverage.xml - uses: actions/upload-artifact@v4 + if: matrix.python-version == '3.11' with: name: python-coverage path: ./py_coverage.xml @@ -42,7 +72,7 @@ jobs: python_test_windows: name: py-unittest-windows runs-on: windows-latest - + needs: build_shared_library strategy: max-parallel: 5 matrix: @@ -62,6 +92,12 @@ jobs: pip install --upgrade pip pip install -r requirements.txt } + - name: Download All Artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + - run: | + mv ./uc_sgsim.dll ./uc_sgsim/c_core - name: Run tests to generate coverage statistics run: | pytest -n auto --cov --cov-report xml:py_coverage.xml @@ -83,7 +119,7 @@ jobs: run: | pip install gcovr==5.0 # 5.1 is not supported - name: Install sonar-scanner and build-wrapper - uses: SonarSource/sonarcloud-github-c-cpp + uses: SonarSource/sonarcloud-github-c-cpp@v2 - name: Run build-wrapper run: | mkdir build @@ -145,7 +181,7 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v4 - name: Run sonar-scanner - uses: SonarSource/sonarcloud-github-action + uses: SonarSource/sonarcloud-github-action@master with: args: > -Dsonar.projectKey=zncl2222_Stochastic_UC_SGSIM_py @@ -175,7 +211,7 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Install sonar-scanner and build-wrapper - uses: SonarSource/sonarcloud-github-c-cpp + uses: SonarSource/sonarcloud-github-c-cpp@v2 - name: Download artifacts uses: actions/download-artifact@v4 - name: Run build-wrapper diff --git a/cmake_build.bat b/cmake_build.bat index 751ce46..de646a5 100644 --- a/cmake_build.bat +++ b/cmake_build.bat @@ -5,12 +5,12 @@ cd cbuild IF /I "%1"=="-s" ( cmake -DIS_EXECUTE=OFF -G "MinGW Makefiles" .. + make + %~dp0cbuild/c_example.exe ) ELSE ( cmake -DIS_EXECUTE=ON -G "MinGW Makefiles" .. ) -make -%~dp0cbuild/c_example.exe cd .. exit /b 0 diff --git a/cmake_build.sh b/cmake_build.sh index f276452..9fd8188 100644 --- a/cmake_build.sh +++ b/cmake_build.sh @@ -20,11 +20,11 @@ cd cmake_build if [ "$is_execute" = true ]; then echo "Compile the code into an executable file !" cmake -DIS_EXECUTE=ON .. + make + make test + make memcheck else echo "Compile the code into a shared library (dynamic library) !" cmake -DIS_EXECUTE=OFF .. + make fi - -make -make test -make memcheck diff --git a/uc_sgsim/c_core/uc_sgsim.dll b/uc_sgsim/c_core/uc_sgsim.dll deleted file mode 100644 index f6f123e..0000000 Binary files a/uc_sgsim/c_core/uc_sgsim.dll and /dev/null differ diff --git a/uc_sgsim/c_core/uc_sgsim.so b/uc_sgsim/c_core/uc_sgsim.so deleted file mode 100755 index 38b8039..0000000 Binary files a/uc_sgsim/c_core/uc_sgsim.so and /dev/null differ