Skip to content

Commit

Permalink
Turn test job into matrix for Linux and Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Martynas Gurskas <[email protected]>
  • Loading branch information
Lipt0nas committed Mar 22, 2024
1 parent f4fc89b commit aa481dc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 24 deletions.
73 changes: 54 additions & 19 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,77 @@ env:
CARGO_TERM_COLOR: always

jobs:
build-scaffolding:
run-tests:
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

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/cpp-tests/build" >> "$GITHUB_OUTPUT"
echo "build-source-dir=${{ github.workspace }}/cpp-tests" >> "$GITHUB_OUTPUT"
- name: Install additional dependencies
shell: bash
run: |
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-lib:
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

- name: Build scaffolding library
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
./build_scaffolding_lib.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
test-scaffolding-go:
runs-on: ubuntu-latest
container:
Expand Down
4 changes: 0 additions & 4 deletions build_bindgen.sh

This file was deleted.

2 changes: 2 additions & 0 deletions build_scaffolding.sh → build_scaffolding_lib.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -euxo pipefail

cargo build --release --package uniffi-bindgen-cpp

mkdir -p cpp-tests/build
cd cpp-tests/build
cmake -DCMAKE_BUILD_TYPE=Debug ..
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit aa481dc

Please sign in to comment.