Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create workflow #6

Merged
merged 12 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 45 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
timeout-minutes: 45

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install clang dev
run: sudo apt install libclang-dev

# - name: Set up GCC
# uses: egor-tensin/setup-gcc@v1
# with:
# version: 11
# platform: x64

- name: Install latest cmake and ninja
uses: lukka/get-cmake@latest

- name: Install Conan package manager
uses: turtlebrowser/get-conan@main
with:
version: 2.5.0

- name: Create default Conan profile
run: conan profile detect

- name: Replace default Conan profile
run: cp conan_profile/default ~/.conan2/profiles/default

- name: Install
run: ./project.py --install

- name: Build
run: ./project.py --build

- name: Run
run: ./project.py --run
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(BUILD_SHARED_LIBS FALSE)
set(CMAKE_EXE_LINKER_FLAGS '-static')

set(PROJECT_SOURCES
src/main.cpp
Expand All @@ -28,4 +27,3 @@ find_package(Qt6 COMPONENTS Widgets REQUIRED)

target_link_libraries(${PROJECT_NAME} libpqxx::pqxx)
target_link_libraries(${PROJECT_NAME} Qt6::Widgets)
target_link_libraries(${PROJECT_NAME} "/home/dal/.conan2/p/b/qt52cf5a760f2fd/p/plugins/platforms/libqxcb.a")
2 changes: 1 addition & 1 deletion CMakeUserPresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"conan": {}
},
"include": [
"conan2/build/Release/generators/CMakePresets.json"
"conanfiles/build/Release/generators/CMakePresets.json"
]
}
12 changes: 12 additions & 0 deletions conan_profile/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux

[conf]
tools.system.package_manager:mode=install
tools.system.package_manager:sudo=True
14 changes: 12 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from conan import ConanFile
from conan.tools.cmake import cmake_layout
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.build import check_min_cppstd


class ExampleRecipe(ConanFile):
Expand All @@ -10,6 +11,15 @@ class ExampleRecipe(ConanFile):
def requirements(self):
self.requires("qt/6.7.1")
self.requires("libpqxx/7.9.1")

def validate(self):
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, "17")

def layout(self):
cmake_layout(self)
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
86 changes: 86 additions & 0 deletions project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python3

import subprocess
import argparse
from pathlib import Path


def system_call(command: str):
if subprocess.call(command, shell=True, executable='/bin/bash') != 0:
exit(1)


def delete_if_exist(path: Path):
if path.exists():
print(f'Delete {path}')
system_call(f'rm -rf {path}')


class Project:
def __init__(self):
self.root: Path = Path(__file__).parent
self.name: str = self.root.name

def install(self):
print(f'---INSTALL {self.name}---')
system_call(f'conan install -of ./conanfiles -pr:h=./conan_profile/default -pr:b=./conan_profile/default --build=missing ./')

def build(self):
self.install()
print(f'---BUILD {self.name}---')
system_call(f'conan build -of ./conanfiles ./')

def run(self):
print(f'---RUN {self.name}---')
binary = self.root / 'conanfiles/build/Release/sqlExplorer -platform offscreen'
command = f'timeout 5 {binary}'
output = subprocess.call(command, shell=True, executable='/bin/bash')

# Success if "timeout" did exit by timing out (code 124)
if output == 124:
exit(0)
else:
exit(1)

def clear(self, clear_conan: bool = False):
# rm -rf ./build ./conanfiles
print(f'---CLEAR {self.name}---')
delete_if_exist(self.root / 'CMakeUserPresets.json')
delete_if_exist(self.root / 'build')
delete_if_exist(self.root / 'conanfiles')

if clear_conan:
system_call('conan remove -c "*"')


def main():
parser = argparse.ArgumentParser(description='Project build script')

parser.add_argument('--install', action='store_true', help='Install dependencies')
parser.add_argument('--build', action='store_true', help='Build project')
parser.add_argument('--run', action='store_true', help='Run project')
parser.add_argument('--clear', action='store_true', help='Clear project')
parser.add_argument('--clear-all', action='store_true', help='Clear project and conan cache')

args = parser.parse_args()

app = Project()

if args.clear:
app.clear()

if args.clear_all:
app.clear(clear_conan=True)

if args.install:
app.install()

if args.build:
app.build()

if args.run:
app.run()


if __name__ == '__main__':
main()
Loading