Skip to content

Commit dfc8ac1

Browse files
committed
Turn test job into matrix for Linux and Windows
Signed-off-by: Martynas Gurskas <[email protected]>
1 parent f4fc89b commit dfc8ac1

File tree

4 files changed

+59
-26
lines changed

4 files changed

+59
-26
lines changed

.github/workflows/cpp.yml

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,82 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
build-scaffolding:
13+
run-tests:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
# TODO: remove this when the workflow is stable
17+
fail-fast: false
18+
19+
matrix:
20+
# Ubuntu-20.04 is being used here on purpose instead of ubuntu-latest due to a bug with clang and libstdc++
21+
# https://github.com/actions/runner-images/issues/8659
22+
os: [ubuntu-20.04, windows-latest]
23+
build_type: [Release]
24+
cpp_compiler: [g++, clang++, cl]
25+
exclude:
26+
- os: windows-latest
27+
cpp_compiler: g++
28+
- os: windows-latest
29+
cpp_compiler: clang++
30+
- os: ubuntu-20.04
31+
cpp_compiler: cl
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
36+
- name: Set reusable strings
37+
id: strings
38+
shell: bash
39+
run: |
40+
echo "build-output-dir=${{ github.workspace }}/cpp-tests/build" >> "$GITHUB_OUTPUT"
41+
echo "build-source-dir=${{ github.workspace }}/cpp-tests" >> "$GITHUB_OUTPUT"
42+
43+
- name: Install additional dependencies
44+
shell: bash
45+
run: |
46+
if [ "$RUNNER_OS" == "Linux" ]; then
47+
sudo apt update && sudo apt install -y valgrind
48+
fi
49+
50+
- name: Configure CMake
51+
run: >
52+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
53+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
54+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
55+
-S ${{ steps.strings.outputs.build-source-dir }}
56+
- name: Build
57+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
58+
59+
- name: Run tests
60+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
61+
run: ctest --build-config ${{ matrix.build_type }}
62+
63+
build-scaffolding-lib:
1464
runs-on: ubuntu-latest
1565
container:
1666
image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0
1767
steps:
1868
- uses: actions/checkout@v3
19-
- name: Build scaffolding
69+
70+
- name: Build scaffolding library
2071
shell: bash
2172
env:
2273
# Github sets HOME to /github/home and breaks dependencies in Docker image..
2374
# https://github.com/actions/runner/issues/863
2475
HOME: /root
2576
run: |
2677
source ~/.bashrc
27-
./build_bindgen.sh
28-
./build_scaffolding.sh
78+
./build_scaffolding_lib.sh
2979
- uses: actions/upload-artifact@v3
3080
with:
3181
name: scaffolding_lib
3282
path: cpp-tests/build/libuniffi_fixtures.so
3383

34-
run-tests:
35-
runs-on: ubuntu-latest
36-
container:
37-
image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0
38-
steps:
39-
- uses: actions/checkout@v3
40-
- name: Run tests
41-
shell: bash
42-
env:
43-
HOME: /root
44-
run: |
45-
source ~/.bashrc
46-
./build_bindgen.sh
47-
./test_bindings.sh
48-
4984
test-scaffolding-go:
5085
runs-on: ubuntu-latest
5186
container:
5287
image: ghcr.io/nordsecurity/uniffi-bindgen-cpp-test-runner:v0.3.0
53-
needs: build-scaffolding
88+
needs: build-scaffolding-lib
5489
steps:
5590
- uses: actions/checkout@v3
5691
with:
@@ -71,7 +106,7 @@ jobs:
71106
runs-on: ubuntu-latest
72107
container:
73108
image: ghcr.io/nordsecurity/uniffi-bindgen-cs-test-runner:v0.1.0
74-
needs: build-scaffolding
109+
needs: build-scaffolding-lib
75110
steps:
76111
- uses: actions/checkout@v3
77112
with:

build_bindgen.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

build_scaffolding.sh renamed to build_scaffolding_lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
set -euxo pipefail
33

4+
cargo build --release --package uniffi-bindgen-cpp
5+
46
mkdir -p cpp-tests/build
57
cd cpp-tests/build
68
cmake -DCMAKE_BUILD_TYPE=Debug ..

fixtures/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "1.0.0"
44
edition = "2021"
55

66
[lib]
7-
crate-type = ["cdylib", "lib"]
7+
crate-type = ["cdylib", "lib", "staticlib"]
88

99
[dependencies]
1010
uniffi-example-arithmetic = { git = "https://github.com/NordSecurity/uniffi-rs.git", tag = "v0.3.1+v0.25.0" }

0 commit comments

Comments
 (0)