Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7ff05a7
first attempt conan ci job
lia-viam Sep 23, 2024
b04fc36
remove git
lia-viam Sep 23, 2024
f34e007
Merge branch 'main' into feature/conan-builds-ci
lia-viam Sep 24, 2024
95f407e
comment out repo owner
lia-viam Sep 24, 2024
c5bc9a6
global install
lia-viam Sep 24, 2024
be04812
always set build = missing
lia-viam Sep 24, 2024
6f1720e
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk
lia-viam Sep 27, 2024
bfefaaa
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk
lia-viam Oct 4, 2024
5cd781e
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk
lia-viam Oct 4, 2024
b545146
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk
lia-viam Oct 7, 2024
e632515
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk
lia-viam Oct 9, 2024
0737d3d
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk
lia-viam Oct 10, 2024
ad61335
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk
lia-viam Oct 21, 2024
18fd299
add workflow trigger for conan job on conan changes
lia-viam Oct 21, 2024
9bc4590
add debug line
lia-viam Oct 22, 2024
08bbba3
remove debug print
lia-viam Oct 22, 2024
e8ac51c
update conanfile to propagate
lia-viam Oct 22, 2024
a6c82c9
remove broken conditional logic
lia-viam Oct 22, 2024
9421a42
remove unneeded transitive
lia-viam Oct 23, 2024
0d9b535
revert some conanfile changes
lia-viam Oct 28, 2024
fb88ff0
fix subprocess call to work on linux too
lia-viam Oct 28, 2024
1d71f74
generate test package with ninja for comparison with cmake version
lia-viam Oct 30, 2024
236e221
refine requires and transitivity
lia-viam Oct 30, 2024
8e14240
Merge branch 'main' of github.com:viamrobotics/viam-cpp-sdk into fix/…
lia-viam Oct 30, 2024
ff28e8d
set env in test package conanfile
lia-viam Oct 30, 2024
3af8de1
add clarifying comment
lia-viam Oct 31, 2024
6e9b4d0
clean up requires and remove transitive_libs
lia-viam Oct 31, 2024
569863b
try to use last successful action for workflow dispatch
lia-viam Oct 31, 2024
69858fb
update comment
lia-viam Oct 31, 2024
f784390
document configure steps
lia-viam Oct 31, 2024
26695f0
document Popen env passing
lia-viam Oct 31, 2024
a49f0aa
Merge branch 'main' into fix/conan-ci
lia-viam Nov 4, 2024
72b9af2
Merge branch 'main' into fix/conan-ci
lia-viam Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions .github/workflows/conan.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: Test conan packages

on:
# Run weekdays at 11:15pm UTC, and specify below to only run if there's been new commits
# Runs for PRs that directly change conan code, and weekdays at 11:15pm UTC.
# Additional logic in the prepare job below makes it so scheduled builds only run
# on new commits.
schedule:
- cron: "15 11 * * 1-5"
workflow_dispatch:
pull_request:
paths:
- conanfile.py
- test_package/conanfile.py

jobs:
prepare:
Expand All @@ -13,17 +19,24 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Get new commit count
id: new_commit_count
shell: bash
run: echo "commit_count=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_OUTPUT

- name: Cancelling scheduled build with no new commits
uses: andymckay/[email protected]
- name: Get current git info
if: github.event_name == 'schedule'
id: git_info
run: |
echo "current_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "current_branch=$(git branch --show-current)" >> $GITHUB_OUTPUT
- name: Get last successful commit
if: github.event_name == 'schedule'
id: last_successful_commit
uses: nrwl/last-successful-commit-action@v1
with:
branch: ${{ steps.git_info.outputs.current_branch }}
workflow_id: conan.yml
- name: Cancel scheduled build with no new commits
uses: nrwl/last-successful-commit-action@v1
if: |
steps.new_commit_count.outputs.commit_count == '0' &&
github.event_name == 'schedule'
github.event_name == 'schedule' &&
steps.git_info.outputs.current_commit == steps.last_successful_commit.outputs.commit_hash

build_macos:
if: github.repository_owner == 'viamrobotics'
Expand Down
28 changes: 15 additions & 13 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ def set_version(self):
self.version = re.search("set\(CMAKE_PROJECT_VERSION (.+)\)", content).group(1).strip()

def configure(self):
# If we're building static then build the world as static, otherwise
# stuff will probably break.
# If you want your shared build to also build the world as shared, you
# can invoke conan with -o "&:shared=False" -o "*:shared=False",
# possibly with --build=missing or --build=cascade as desired,
# but this is probably not necessary.
if not self.options.shared:
self.options["*"].shared = False
if self.options.shared:
# See https://github.com/conan-io/conan-center-index/issues/25107
self.options["grpc"].secure = True

# From some experiments it seems that the shared-ness of these packages
# should match that of the SDK recipe. Failure to do so can cause linker
# errors while compiling, or static initialization errors at runtime for modules.
for lib in ["grpc", "protobuf", "abseil"]:
self.options[lib].shared = True

def requirements(self):
self.requires('boost/[>=1.74.0]', transitive_headers=True)
Expand All @@ -49,8 +50,8 @@ def requirements(self):
self.requires('grpc/[>=1.48.4]', transitive_headers=True)
self.requires('protobuf/[>=3.17.1]', transitive_headers=True)

self.requires('xtensor/[>=0.24.3]', transitive_headers=True)
self.requires('abseil/[>=20230125.3]')
self.requires('xtensor/[>=0.24.3]')
self.requires('abseil/[>=20230125.3]', transitive_libs=True)

def build_requirements(self):
if self.options.offline_proto_generation:
Expand Down Expand Up @@ -83,13 +84,13 @@ def package(self):

def package_info(self):
self.cpp_info.components["viam_rust_utils"].libs = ["viam_rust_utils"]

self.cpp_info.components["viamsdk"].libs = ["viamsdk"]

for component in ["viamsdk", "viamapi"]:
self.cpp_info.components[component].set_property("cmake_target_name", "viam-cpp-sdk::{}".format(component))
self.cpp_info.components[component].set_property("pkg_config_name", "viam-cpp-sdk-lib{}".format(component))
self.cpp_info.components[component].requires = ["grpc::grpc++", "protobuf::libprotobuf"]
self.cpp_info.components[component].requires = ["grpc::grpc++"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components[component].system_libs = ["pthread"]

Expand All @@ -114,11 +115,12 @@ def package_info(self):
"viamapi",
"boost::headers",
"boost::log",
"grpc::grpc++_reflection",
"protobuf::libprotobuf",
"xtensor::xtensor",

"viam_rust_utils",
"abseil::absl_strings",
"grpc::grpc++_reflection"
])

self.cpp_info.components["viamsdk"].frameworks = ["Security"]
8 changes: 6 additions & 2 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from conan.errors import ConanException
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
from conan.tools.env import VirtualRunEnv

class viamCppSdkTest(ConanFile):
settings = "os", "compiler", "build_type", "arch"
Expand All @@ -25,11 +26,14 @@ def test(self):
if can_run(self):
sock = "fake-socket-path"

cmd = os.path.join(self.cpp.build.bindir, f"example_module {sock}")
cmd = os.path.join(self.cpp.build.bindir, "example_module")

# the ConanFile run method is a wrapper around Popen, but it only returns the retcode.
# A properly intialized module waits indefinitely on a signal, so we have to use Popen manually.
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, text=True)
# Use VirtualRunEnv to perform the equivalent of passing env="conanrun" to self.run, so that
# shared builds have a properly set LD_LIBRARY_PATH among other things.
env = VirtualRunEnv(self).vars()
proc = subprocess.Popen([cmd, sock], stdout=subprocess.PIPE, text=True, env=env)

out = None

Expand Down
Loading