Skip to content

Commit db0425a

Browse files
lia-viamstuqdog
andauthored
try adding windows to the PR tests (#447)
Co-authored-by: Ethan <[email protected]>
1 parent d8853f8 commit db0425a

File tree

4 files changed

+90
-60
lines changed

4 files changed

+90
-60
lines changed

.github/workflows/test.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
description: set to true to build without clang-tidy (2x faster)
1313

1414
jobs:
15-
run-tests:
15+
test_ubuntu:
1616
if: github.repository_owner == 'viamrobotics'
1717
runs-on: ubuntu-latest
1818
container: ghcr.io/viamrobotics/cpp-base:bullseye-amd64
@@ -42,3 +42,40 @@ jobs:
4242
- name: test
4343
working-directory: build
4444
run: ../etc/docker/tests/run_test.sh
45+
test_windows:
46+
if: github.repository_owner == 'viamrobotics'
47+
runs-on: windows-latest
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
include:
52+
- target: x86_64-windows
53+
platform: windows_x86_64
54+
steps:
55+
- name: Checkout Code
56+
uses: actions/checkout@v4
57+
with:
58+
ref: ${{ needs.prepare.outputs.sha }}
59+
60+
- name: Install dependencies
61+
run: choco install -y conan git
62+
63+
- name: Build SDK
64+
shell: powershell
65+
run: |
66+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
67+
refreshenv
68+
conan profile detect
69+
conan install . --build=missing -o "&:shared=False"
70+
cmake . --preset conan-default -DVIAMCPPSDK_BUILD_EXAMPLES=ON
71+
cmake --build --preset=conan-release --target ALL_BUILD install -j 8
72+
env:
73+
CONAN_USER_HOME: c:/cache
74+
CONAN_USER_HOME_SHORT: c:/cache/conan_shortpaths
75+
76+
- name: Test examples
77+
shell: powershell
78+
run: |
79+
Start-Job -Init ([ScriptBlock]::Create("Set-Location '$pwd/build/install/bin'")) -ScriptBlock { .\simple_module.exe asdf 2>&1 > output.txt} | Wait-Job -Timeout 2 | Receive-Job
80+
if (-not $(Select-String -Pattern "Module listening" -Path ./build/install/bin/output.txt)) { throw "Module did not start listening" }
81+

src/viam/api/CMakeLists.txt

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -55,46 +55,9 @@ list(JOIN BUF_PROTO_COMPONENTS , BUF_PROTO_COMPONENTS_JOINED)
5555

5656
if (VIAMCPPSDK_USE_DYNAMIC_PROTOS)
5757

58-
# Look for the `buf` command in the usual places, and use it if
59-
# found. If we can't find it, try to download it and use that.
60-
#
61-
# TODO: File an upstream issue with `buf.build` to add
62-
# `find_package` support for it, then use it.
63-
#
64-
find_program(BUF_COMMAND buf)
65-
if (NOT BUF_COMMAND)
66-
67-
set(HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD ${CMAKE_HOST_SYSTEM_PROCESSOR})
68-
if (CMAKE_HOST_WIN32)
69-
if (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD STREQUAL "AMD64")
70-
set(HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD x86_64)
71-
elseif (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD STREQUAL "ARM64")
72-
set(HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD arm64)
73-
else()
74-
message(FATAL_ERROR "Unknown Windows platform to correct buf download URL: ${HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD}")
75-
endif()
76-
endif()
77-
78-
set(BUF_DOWNLOAD_URL https://github.com/bufbuild/buf/releases/latest/download/buf-${CMAKE_HOST_SYSTEM_NAME}-${HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD}${CMAKE_HOST_EXECUTABLE_SUFFIX})
79-
80-
file(
81-
DOWNLOAD
82-
${BUF_DOWNLOAD_URL}
83-
${CMAKE_CURRENT_BINARY_DIR}/buf_latest${CMAKE_HOST_EXECUTABLE_SUFFIX}
84-
STATUS buf_status
85-
)
86-
list(GET buf_status 0 buf_status_code)
87-
list(GET buf_status 1 buf_status_string)
88-
89-
if(NOT buf_status_code EQUAL 0)
90-
message(FATAL_ERROR "No local `buf` program found (try setting PATH?) and failed to download: ${buf_status_string} for ${BUF_DOWNLOAD_URL}")
91-
endif()
92-
93-
set(BUF_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/buf_latest${CMAKE_HOST_EXECUTABLE_SUFFIX})
94-
file(CHMOD ${BUF_COMMAND} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
95-
endif()
58+
viamcppsdk_get_buf()
9659

97-
# TODO: IDeally we could just generate to `CMAKE_CURRENT_BINARY_DIR`
60+
# TODO: Ideally we could just generate to `CMAKE_CURRENT_BINARY_DIR`
9861
# and everything would work just fine. However, that directory also
9962
# has intermediate cmake state in it, so we can't use it as a source
10063
# for a directory copy to update the static protos, as we do

src/viam/cmake/viamcppsdk_utils.cmake

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,50 @@ function(viamcppsdk_link_viam_api TARGET_LIBRARY)
2525
target_link_libraries(${TARGET_LIBRARY} ${ARGV1} "$<LINK_LIBRARY:WHOLE_ARCHIVE,viam-cpp-sdk::viamapi>")
2626
endif()
2727
endfunction()
28+
29+
# Look for the `buf` command in the usual places, and use it if
30+
# found. If we can't find it, try to download it and use that.
31+
#
32+
# TODO: File an upstream issue with `buf.build` to add
33+
# `find_package` support for it, then use it.
34+
#
35+
function(viamcppsdk_get_buf)
36+
if (BUF_COMMAND)
37+
return()
38+
endif()
39+
40+
find_program(BUF_COMMAND buf)
41+
if (BUF_COMMAND)
42+
return()
43+
endif()
44+
45+
set(HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD ${CMAKE_HOST_SYSTEM_PROCESSOR})
46+
if (CMAKE_HOST_WIN32)
47+
if (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD STREQUAL "AMD64")
48+
set(HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD x86_64)
49+
elseif (HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD STREQUAL "ARM64")
50+
set(HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD arm64)
51+
else()
52+
message(FATAL_ERROR "Unknown Windows platform to correct buf download URL: ${HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD}")
53+
endif()
54+
endif()
55+
56+
set(BUF_DOWNLOAD_URL https://github.com/bufbuild/buf/releases/latest/download/buf-${CMAKE_HOST_SYSTEM_NAME}-${HOST_SYSTEM_PROCESSOR_FOR_BUF_DOWNLOAD}${CMAKE_HOST_EXECUTABLE_SUFFIX})
57+
58+
file(
59+
DOWNLOAD
60+
${BUF_DOWNLOAD_URL}
61+
${CMAKE_CURRENT_BINARY_DIR}/buf_latest${CMAKE_HOST_EXECUTABLE_SUFFIX}
62+
STATUS buf_status
63+
)
64+
65+
list(GET buf_status 0 buf_status_code)
66+
list(GET buf_status 1 buf_status_string)
67+
68+
if(NOT buf_status_code EQUAL 0)
69+
message(FATAL_ERROR "No local `buf` program found (try setting PATH?) and failed to download: ${buf_status_string} for ${BUF_DOWNLOAD_URL}")
70+
endif()
71+
72+
set(BUF_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/buf_latest${CMAKE_HOST_EXECUTABLE_SUFFIX} CACHE INTERNAL "buf command")
73+
file(CHMOD ${BUF_COMMAND} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
74+
endfunction()

src/viam/examples/modules/complex/CMakeLists.txt

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,9 @@ set(MODULE_PROTO_OUTPUT_FILES
3636
${MODULE_PROTO_GEN_DIR}/summation.pb.h
3737
)
3838

39-
# Look for the `buf` command in the usual places, and use it if found. If we
40-
# can't find it, try to download it and use that.
41-
find_program(BUF_COMMAND buf)
42-
if (NOT BUF_COMMAND)
43-
file(
44-
DOWNLOAD
45-
https://github.com/bufbuild/buf/releases/latest/download/buf-${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}
46-
${CMAKE_CURRENT_BINARY_DIR}/buf_latest
47-
STATUS buf_status
48-
)
49-
list(GET buf_status 0 buf_status_code)
50-
list(GET buf_status 1 buf_status_string)
51-
52-
if(NOT buf_status_code EQUAL 0)
53-
message(FATAL_ERROR "No local `buf` program found (try setting PATH?) and failed to download: ${buf_status_string}")
54-
endif()
55-
56-
set(BUF_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/buf_latest)
57-
file(CHMOD ${BUF_COMMAND} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
58-
endif()
39+
# Try to find buf in the path or get it online.
40+
# See the definition of this function for logic that can be adapted to other project files.
41+
viamcppsdk_get_buf()
5942

6043
if ((NOT VIAMCPPSDK_OFFLINE_PROTO_GENERATION) AND VIAMCPPSDK_BUF_REMOTE_PLUGIN_SUPPORTED)
6144
configure_file(

0 commit comments

Comments
 (0)