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 20dbbd3
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 69 deletions.
171 changes: 103 additions & 68 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 20dbbd3

Please sign in to comment.