From 20dbbd3ed189b7fef700108fb52ac66ed528e0e1 Mon Sep 17 00:00:00 2001 From: Martynas Gurskas Date: Fri, 22 Mar 2024 11:17:39 +0200 Subject: [PATCH] Turn test job into matrix for Linux and Windows Signed-off-by: Martynas Gurskas --- .github/workflows/cpp.yml | 171 +++++++++++++++++++++++--------------- fixtures/Cargo.toml | 2 +- 2 files changed, 104 insertions(+), 69 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index c63be02..8ab29f1 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -10,80 +10,115 @@ env: CARGO_TERM_COLOR: always jobs: - build-scaffolding: - runs-on: ubuntu-latest - container: - image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0 - steps: - - uses: actions/checkout@v3 - - name: Build scaffolding - shell: bash - env: - # Github sets HOME to /github/home and breaks dependencies in Docker image.. - # https://github.com/actions/runner/issues/863 - HOME: /root - run: | - source ~/.bashrc - ./build_bindgen.sh - ./build_scaffolding.sh - - uses: actions/upload-artifact@v3 - with: - name: scaffolding_lib - path: cpp-tests/build/libuniffi_fixtures.so - run-tests: - runs-on: ubuntu-latest - container: - image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0 - steps: - - uses: actions/checkout@v3 - - name: Run tests - shell: bash - env: - HOME: /root - run: | - source ~/.bashrc - ./build_bindgen.sh - ./test_bindings.sh + runs-on: ${{ matrix.os }} + strategy: + # TODO: remove this when the workflow is stable + fail-fast: false + + matrix: + # Ubuntu-20.04 is being used here on purpose instead of ubuntu-latest due to a bug with clang and libstdc++ + # https://github.com/actions/runner-images/issues/8659 + os: [ubuntu-20.04, windows-latest] + build_type: [Release] + cpp_compiler: [g++, clang++, cl] + exclude: + - os: windows-latest + cpp_compiler: g++ + - os: windows-latest + cpp_compiler: clang++ + - os: ubuntu-20.04 + cpp_compiler: cl - test-scaffolding-go: - runs-on: ubuntu-latest - container: - image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0 - needs: build-scaffolding steps: - uses: actions/checkout@v3 - with: - submodules: recursive - - uses: actions/download-artifact@v3 - with: - name: scaffolding_lib - path: cpp-tests/build/ - - name: Test scaffolding Go + + - name: Set reusable strings + id: strings shell: bash - env: - HOME: /root run: | - source ~/.bashrc - ./test_scaffolding_go.sh + echo "build-output-dir=${{ github.workspace }}/cpp-tests/build" >> "$GITHUB_OUTPUT" + echo "build-source-dir=${{ github.workspace }}/cpp-tests" >> "$GITHUB_OUTPUT" - test-scaffolding-cs: - runs-on: ubuntu-latest - container: - image: ghcr.io/nordsecurity/uniffi-bindgen-cs-test-runner:v0.1.0 - needs: build-scaffolding - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - uses: actions/download-artifact@v3 - with: - name: scaffolding_lib - path: cpp-tests/build/ - - name: Test scaffolding C# + - name: Install additional dependencies shell: bash - env: - HOME: /root run: | - source ~/.bashrc - ./test_scaffolding_cs.sh + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt update && sudo apt install -y valgrind + fi + + - name: Configure CMake + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ steps.strings.outputs.build-source-dir }} + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Run tests + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: ctest --build-config ${{ matrix.build_type }} + + # build-scaffolding: + # runs-on: ubuntu-latest + # container: + # image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0 + # steps: + # - uses: actions/checkout@v3 + # - name: Build scaffolding + # shell: bash + # env: + # # Github sets HOME to /github/home and breaks dependencies in Docker image.. + # # https://github.com/actions/runner/issues/863 + # HOME: /root + # run: | + # source ~/.bashrc + # ./build_bindgen.sh + # ./build_scaffolding.sh + # - uses: actions/upload-artifact@v3 + # with: + # name: scaffolding_lib + # path: cpp-tests/build/libuniffi_fixtures.so + + # test-scaffolding-go: + # runs-on: ubuntu-latest + # container: + # image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0 + # needs: build-scaffolding + # steps: + # - uses: actions/checkout@v3 + # with: + # submodules: recursive + # - uses: actions/download-artifact@v3 + # with: + # name: scaffolding_lib + # path: cpp-tests/build/ + # - name: Test scaffolding Go + # shell: bash + # env: + # HOME: /root + # run: | + # source ~/.bashrc + # ./test_scaffolding_go.sh + # + # test-scaffolding-cs: + # runs-on: ubuntu-latest + # container: + # image: ghcr.io/nordsecurity/uniffi-bindgen-cs-test-runner:v0.1.0 + # needs: build-scaffolding + # steps: + # - uses: actions/checkout@v3 + # with: + # submodules: recursive + # - uses: actions/download-artifact@v3 + # with: + # name: scaffolding_lib + # path: cpp-tests/build/ + # - name: Test scaffolding C# + # shell: bash + # env: + # HOME: /root + # run: | + # source ~/.bashrc + # ./test_scaffolding_cs.sh diff --git a/fixtures/Cargo.toml b/fixtures/Cargo.toml index 097ed1d..958d813 100644 --- a/fixtures/Cargo.toml +++ b/fixtures/Cargo.toml @@ -4,7 +4,7 @@ version = "1.0.0" edition = "2021" [lib] -crate-type = ["cdylib", "lib"] +crate-type = ["cdylib", "lib", "staticlib"] [dependencies] uniffi-example-arithmetic = { git = "https://github.com/NordSecurity/uniffi-rs.git", tag = "v0.3.1+v0.25.0" }