diff --git a/.github/workflows/build_binary.yml b/.github/workflows/build_binary.yml index 85392a0..eec0035 100644 --- a/.github/workflows/build_binary.yml +++ b/.github/workflows/build_binary.yml @@ -42,16 +42,26 @@ jobs: - name: 'Build' id: 'build' run: | - cmake --build build --config Release + cmake --build build --config Release --target all . build/env.sh echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_OUTPUT - - name: 'Upload artifacts' + - name: 'Upload artifacts (lib)' uses: actions/upload-artifact@v4 with: - name: libcpp_bindings_linux_x86_64 - path: build/libcpp_bindings_linux.so* + if-no-files-found: error + name: libcpp_bindings_linux + path: build/libcpp_bindings_linux.so + + - name: 'Upload artifacts (tests)' + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + name: cpp_bindings_linux_tests + path: | + build/libcpp_bindings_linux.so* + build/cpp_bindings_linux_tests - name: 'Check tag' id: 'check-tag' @@ -71,14 +81,25 @@ jobs: package_version: ${{ steps.build.outputs.PACKAGE_VERSION }} is_valid_package_version: ${{ steps.check-tag.outputs.IS_VALID_PACKAGE_VERSION }} - trigger-publish: - name: 'Trigger Publish' + test-unit-cpp: + name: 'Run: Test Unit C++' needs: ['build-binary'] - uses: ./.github/workflows/publish_jsr.yml + uses: './.github/workflows/test_unit_cpp.yml' + with: + artifact-name: cpp_bindings_linux_tests + + permissions: + contents: read + checks: write + + publish-jsr: + name: 'Run: Publish JSR' + needs: ['build-binary', 'test-unit-cpp'] + uses: './.github/workflows/publish_jsr.yml' with: publish: ${{ needs.build-binary.outputs.is_valid_package_version == 'true' }} version: ${{ needs.build-binary.outputs.package_version }} - artifact-name: libcpp_bindings_linux_x86_64 + artifact-name: libcpp_bindings_linux permissions: contents: read diff --git a/.github/workflows/cpp_tests.yml b/.github/workflows/cpp_tests.yml deleted file mode 100644 index cefe01e..0000000 --- a/.github/workflows/cpp_tests.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: C++ Tests - -on: - push: - branches: [ main, master ] - pull_request: - -jobs: - cpp-tests: - name: C++ tests (gcc) - runs-on: ubuntu-latest - - container: - image: fedora:43 - - env: - SERIAL_TEST_PORT: /tmp/ttyCI_A - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install build dependencies (gcc) - run: | - dnf -y update - dnf -y install cmake ninja-build gcc-c++ socat git - - - name: Configure CMake - env: - CXX: g++ - run: | - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release - - - name: Build - run: | - cmake --build build --config Release - - - name: Start virtual serial echo (socat) - run: | - socat -d -d pty,raw,echo=0,link=/tmp/ttyCI_A,mode=666 pty,raw,echo=0,link=/tmp/ttyCI_B,mode=666 & - sleep 2 - stdbuf -i0 -o0 cat < /tmp/ttyCI_B > /tmp/ttyCI_B & - sleep 1 - - - name: Run C++ unit/integration tests - working-directory: build - env: - SERIAL_TEST_PORT: /tmp/ttyCI_A - run: | - ./cpp_bindings_linux_tests --gtest_color=yes - - diff --git a/.github/workflows/publish_jsr.yml b/.github/workflows/publish_jsr.yml index b950b12..ae9d457 100644 --- a/.github/workflows/publish_jsr.yml +++ b/.github/workflows/publish_jsr.yml @@ -27,8 +27,8 @@ permissions: jobs: publish-jsr: + name: 'Publish JSR' runs-on: ubuntu-latest - steps: - name: 'Checkout repository' uses: actions/checkout@v4 diff --git a/.github/workflows/test_unit_cpp.yml b/.github/workflows/test_unit_cpp.yml new file mode 100644 index 0000000..03d8cd0 --- /dev/null +++ b/.github/workflows/test_unit_cpp.yml @@ -0,0 +1,75 @@ +name: 'Test Unit C++' +description: | + This workflow runs the unit tests. + +on: + workflow_call: + inputs: + artifact-name: + required: true + type: string + +jobs: + test-unit-cpp: + name: 'Test Unit C++' + runs-on: ubuntu-latest + env: + SERIAL_TEST_PORT_IN: /tmp/ttyCI_IN + SERIAL_TEST_PORT_OUT: /tmp/ttyCI_OUT + TEST_REPORT_NAME: 'test_report.xml' + + steps: + - name: 'Checkout repository' + uses: actions/checkout@v4 + + - name: 'Download artifact' + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: 'artifacts' + + - name: 'Install test dependencies' + run: | + sudo apt-get install -y socat + + - name: Start virtual serial echo (socat) + run: | + socat -d -d pty,raw,echo=0,link=$SERIAL_TEST_PORT_IN,mode=666 pty,raw,echo=0,link=$SERIAL_TEST_PORT_OUT,mode=666 & + sleep 2 + stdbuf -i0 -o0 cat < $SERIAL_TEST_PORT_OUT > $SERIAL_TEST_PORT_OUT & + sleep 1 + + - name: 'Run tests' + working-directory: 'artifacts' + env: + LD_LIBRARY_PATH: '${{ github.workspace }}/artifacts' + SERIAL_TEST_PORT: '${{ env.SERIAL_TEST_PORT_IN }}' + + run: | + chmod +x ./cpp_bindings_linux_tests + + ./cpp_bindings_linux_tests \ + --gtest_color=yes \ + --gtest_output=xml:$TEST_REPORT_NAME + + - name: 'Upload test report' + if: always() + uses: actions/upload-artifact@v4 + with: + name: 'test_reports' + path: 'artifacts/${{ env.TEST_REPORT_NAME }}' + + - name: 'Publish test report' + if: always() + uses: mikepenz/action-junit-report@v5 + with: + report_paths: 'artifacts/${{ env.TEST_REPORT_NAME }}' + detailed_summary: true + group_suite: true + include_passed: true + annotate_notice: true + transformers: '[{"searchValue": "${{ github.workspace }}", "replaceValue": ""}]' + check_title_template: '{{FILE_NAME}} | {{TEST_NAME}}' + + +