Skip to content

Commit

Permalink
odr test package (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand authored May 26, 2024
1 parent ada534d commit d9d6862
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: build_test

on:
workflow_dispatch:
push:
branches:
- main
Expand Down Expand Up @@ -88,15 +89,21 @@ jobs:
${{ matrix.config.os }}-${{ matrix.config.compiler }}-
- name: conan install
run: conan install ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} --build=missing
run: conan install ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }} --build missing
- name: conan source
run: conan source ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }}
- name: conan build
run: conan build ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }}
- name: conan export
run: conan export ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }}
- name: conan export-pkg
run: conan export-pkg ${{ matrix.package.conanfile }} --version ${{ matrix.package.version }}

# test_package
- name: conan test
run: |
test_conanfile=$(dirname ${{ matrix.package.conanfile }})/test_package/conanfile.py
conan test $test_conanfile ${{ matrix.package.package_version }} --build missing
- name: conan upload
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
run: conan upload "*" --check --confirm --remote odr
7 changes: 6 additions & 1 deletion recipes/odrcore/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,9 @@ def package(self):
cmake.install()

def package_info(self):
self.cpp_info.libs = ["odr"]
if Version(self.version) <= "1.0.0":
self.cpp_info.libs = ["odrlib"]
elif Version(self.version) <= "2.0.0":
self.cpp_info.libs = ["odr-static"]
else:
self.cpp_info.libs = ["odr"]
7 changes: 7 additions & 0 deletions recipes/odrcore/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)

find_package(odrcore REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE odrcore::odrcore)
26 changes: 26 additions & 0 deletions recipes/odrcore/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
5 changes: 5 additions & 0 deletions recipes/odrcore/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <iostream>

int main() {
return 0;
}

0 comments on commit d9d6862

Please sign in to comment.