diff --git a/.github/actions/setup-conan-action/action.yml b/.github/actions/setup-conan-action/action.yml index c3c43972..f1d3d329 100644 --- a/.github/actions/setup-conan-action/action.yml +++ b/.github/actions/setup-conan-action/action.yml @@ -6,7 +6,14 @@ runs: - name: Setup venv run: | python3 -m venv venv - source venv/bin/activate + if [ "$RUNNER_OS" == "Linux" ]; then + source venv/bin/activate + elif [ "$RUNNER_OS" == "Windows" ]; then + venv/bin/activate.bat + else + echo "$RUNNER_OS not supported" + exit 1 + fi echo "VIRTUAL_ENV=${VIRTUAL_ENV}" >> $GITHUB_ENV echo "${VIRTUAL_ENV}/bin" >> $GITHUB_PATH shell: bash @@ -16,7 +23,7 @@ runs: - name: Install conan latest run: pip3 install conan --upgrade shell: bash - - name: Fix path + - name: Fix path on Linux run: | echo "/home/runner/.local/bin" >> $GITHUB_PATH shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c82ad1d..1c03d5fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,69 +11,68 @@ env: jobs: build_x86_Linux: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. 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 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-conan-action - name: Conan install + if: matrix.os == 'ubuntu-latest' run: | + if [ "$RUNNER_OS" == "Linux" ]; then + export conan_profile=linux + elif [ "$RUNNER_OS" == "Windows" ]; then + export conan_profile=windows + else + echo "$RUNNER_OS not supported" + exit 1 + fi mkdir -p ${{github.workspace}}/build cd ${{github.workspace}}/build - conan install ../conan/conanfile_linux.txt -of=./ -pr:b ../conan/profile_linux_x86_64.txt -pr:h ../conan/profile_linux_x86_64.txt --build=missing -s build_type=${{env.BUILD_TYPE}} + conan install ../conan/conanfile_${conan_profile}.txt -of=./ -pr:b ../conan/profile_${conan_profile}_x86_64.txt -pr:h ../conan/profile_${conan_profile}_x86_64.txt --build=missing -s build_type=${{env.BUILD_TYPE}} - name: Install Gcovr - run: sudo apt install gcovr + if: matrix.os == 'ubuntu-latest' + run: - 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}} -DCODE_COVERAGE=ON -DBUILD_UNIT_TESTS=ON + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + export coverage=ON + elif [ "$RUNNER_OS" == "Windows" ]; then + export coverage=OFF + else + echo "$RUNNER_OS not supported" + exit 1 + fi + cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCODE_COVERAGE=${coverage} -DBUILD_UNIT_TESTS=ON - 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 coverage_xml + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + make coverage_xml + elif [ "$RUNNER_OS" == "Windows" ]; then + make test + else + echo "$RUNNER_OS not supported" + exit 1 + fi - name: Upload artifacts uses: actions/upload-artifact@v4 + if: matrix.os == 'ubuntu-latest' with: name: coverage path: build/coverage_xml.xml - build_x86_Windows: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup-conan-action - - - name: Conan install - run: | - mkdir -p ${{github.workspace}}/build - cd ${{github.workspace}}/build - conan install ../conan/conanfile_windows.txt -of=./ -pr:b ../conan/profile_windows_x86_64.txt -pr:h ../conan/profile_windows_x86_64.txt --build=missing -s build_type=${{env.BUILD_TYPE}} - - - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UNIT_TESTS=ON - - - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Test - working-directory: ${{github.workspace}}/build - run: make test - build_NuttX: runs-on: ubuntu-latest env: