Skip to content

Commit

Permalink
Merge pull request #343 from mtconnect/main-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wsobel authored Oct 20, 2023
2 parents 0cffec0 + 112b841 commit 7d9534a
Show file tree
Hide file tree
Showing 234 changed files with 6,029 additions and 56,167 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ ChangeLog
# conanfile.py # need this
Dockerfile
Glossary*.pdf
LICENSE.TXT
README.md
terms.tex

*.log
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
name: Build Docker image

env:
VERSION: 2.0.0.8
PLATFORMS: linux/amd64,linux/arm64

# when to run workflow
on:
# # run on push or pull request events for the master branch
# push:
# branches: [ master ]
# branches: [ main ]
# pull_request:
# branches: [ master ]
# branches: [ main ]

# allows you to run this workflow manually from the actions tab
workflow_dispatch:
Expand All @@ -41,10 +40,8 @@ jobs:
steps:
# checks-out your repository under $GITHUB_WORKSPACE
# see https://github.com/actions/checkout
- uses: actions/checkout@v3
with:
ref: v${{ env.VERSION }}
# ref: master
- name: Checkout Agent
uses: actions/checkout@v3

# the QEMU emulator lets us build for arm processors also
# see https://github.com/docker/setup-qemu-action
Expand Down Expand Up @@ -72,7 +69,7 @@ jobs:
# docker hub user/repo:tag
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/agent:latest
${{ secrets.DOCKERHUB_USERNAME }}/agent:${{ env.VERSION }}
${{ secrets.DOCKERHUB_USERNAME }}/agent:${{ github.ref_name }}
# push to docker hub
push: true
191 changes: 191 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Build, Test, and Draft Releae for static and dynamic versions of the
# MTConnect Agent on Windows, Mac OS, and Linux.
#
# The Windows x86 and x86_64 builds create ZIP packages and attach them to
# a draft release when the commit is tagged.
#
# Secret required for Release:
# RELEASE_GITHUB_TOKEN - Release token created by admin in Settings / Developer Settings / Personal access tokens /
# Find-grained tokens
# The token must be renewed every 90 days.

name: Build MTConnect C++ Agent

on:
# Enable automated build once verified
pull_request:
paths-ignore: ["**/*.md", "LICENSE.txt", ".gitignore"]
branches: [ "main", "main-dev" ]

push:
paths-ignore: ["**/*.md", "LICENSE.txt", ".gitignore"]
branches: [ "main", "main-dev" ]
tags:
- "v*.*.*"

# Allow manually run workflows
workflow_dispatch:

jobs:
build_windows:
runs-on: windows-2019
name: "Windows 2019 Arch: ${{ matrix.arch }}, Shared: ${{ matrix.shared }}"
strategy:
matrix:
arch: ["x86", "amd64"]
shared: ["True", "False"]
include:
- arch: "x86"
profile: "vs32"
- arch: "amd64"
profile: "vs64"
- shared: "True"
profile: "vs64shared"
exclude:
- arch: "x86"
shared: "True"

steps:
- name: Setup conan and zip directories
run: |
ruby -e @"
base = ENV['GITHUB_WORKSPACE'].gsub('\\', '/').
gsub(/\/[a-zA-Z]+$/, '')
puts %{ZIP_DIR=#{base}}
puts %{CONAN_HOME=#{base}/conan2}
"@ >> $env:GITHUB_ENV
echo "CTEST_OUTPUT_ON_FAILURE=TRUE" >> $env:GITHUB_ENV
- name: Print Directories
run: |
echo $CONAN_HOME
echo $ZIP_DIR
echo $CTEST_OUTPUT_ON_FAILURE
- name: Checkout Agent
uses: actions/checkout@v3

- name: Cache conan packages
id: cache
uses: actions/cache@v3
with:
path: ${{ env.CONAN_HOME }}
key: ${{ runner.os }}-build-${{ matrix.profile }}-${{ hashFiles('**/conanfile.py') }}

- name: Install Conan
uses: turtlebrowser/[email protected]

- name: Initialize VS Dev Env
uses: seanmiddleditch/gha-setup-vsdevenv@master
with:
arch: ${{ matrix.arch }}
host_arch: ${{ matrix.arch }}

- name: Setup Conan
if: steps.cache.outputs.cache-hit != 'true'
run: |
conan profile detect -f
- name: Cleanup Prior Build
if: steps.cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
conan remove mtconnect_agent -c
- name: Build and Test C++ Agent
run: |
set CTEST_OUTPUT_ON_FAILURE=TRUE
conan create . --build=missing -pr conan/profiles/${{ matrix.profile }} -o with_docs=False -o cpack=True -o cpack_destination=${{ env.ZIP_DIR }} -o shared=${{ matrix.shared }}
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.shared == 'False' }}
with:
name: Version ${{ github.ref_name }}
draft: true
files: |
${{ env.ZIP_DIR }}/agent*.zip
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}

build_linux:
runs-on: ubuntu-latest
name: "Ubuntu Latest, Shared: ${{ matrix.shared }}"
strategy:
matrix:
shared: ["True", "False"]

steps:
- name: Install dependencies
shell: bash
run: |
sudo apt install -y build-essential cmake gcc-11 g++-11 python3 autoconf automake
- name: Checkout Agent
uses: actions/checkout@v3

- name: Cache conan packages
id: cache
uses: actions/cache@v3
with:
path: ~/.conan2
key: ${{ runner.os }}-build-${{ matrix.shared }}-${{ hashFiles('**/conanfile.py') }}

- name: Install Conan
uses: turtlebrowser/[email protected]

- name: Setup Conan
if: steps.cache.outputs.cache-hit != 'true'
run: |
conan profile detect -f
- name: Cleanup Prior Build
if: steps.cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
conan remove mtconnect_agent -c
- name: Build and Test C++ Agent
shell: bash
run: |
export CTEST_OUTPUT_ON_FAILURE=TRUE
conan create . --build=missing -pr conan/profiles/gcc -o shared=${{ matrix.shared }} -o with_docs=False
build_macos:
runs-on: macos-latest
name: "MacOS Latest, Shared: ${{ matrix.shared }}"
strategy:
matrix:
shared: ["True", "False"]

steps:
- name: Checkout Agent
uses: actions/checkout@v3

- name: Cache conan packages
id: cache
uses: actions/cache@v3
with:
path: ~/.conan2
key: ${{ runner.os }}-build-${{ matrix.shared }}-${{ hashFiles('**/conanfile.py') }}

- name: Install Conan
uses: turtlebrowser/[email protected]

- name: Setup Conan
if: steps.cache.outputs.cache-hit != 'true'
run: |
conan profile detect -f
- name: Cleanup Prior Build
if: steps.cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
conan remove mtconnect_agent -c
- name: Build and Test C++ Agent
shell: bash
run: |
export CTEST_OUTPUT_ON_FAILURE=TRUE
conan create . --build=missing -pr conan/profiles/macos -o shared=${{ matrix.shared }} -o with_docs=False
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Release
*.gz
test/agent.log*
build/
test_package/build
cmake-build-debug/**
cmake-build-release/**
.idea/**
Expand Down
55 changes: 38 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 2)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 2)
set(AGENT_VERSION_RC "_RC5")
set(AGENT_VERSION_BUILD 7)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2017 and C++ feature checking and FetchContent
# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)

set(USE_FOLDERS ON)
Expand All @@ -14,10 +14,11 @@ if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

option(AGENT_ENABLE_UNITTESTS "Enables the agent's unit tests" ON)
option(SHARED_AGENT_LIB "Generate shared agent library. Conan options: shared" OFF)
option(DEVELOPMENT "Used for development, includes tests as a subdirectory instead of a package" OFF)
set(AGENT_PREFIX "" CACHE STRING "Prefix for the name of the agent and the agent library: suggested 'mtc'")
set(INSTALL_GTEST OFF FORCE)

set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/mtconnect")

message(INFO " Shared build: ${SHARED_AGENT_LIB}")

Expand Down Expand Up @@ -73,27 +74,47 @@ include(cmake/ClangTidy.cmake)
# Add our projects
add_subdirectory(agent_lib)
add_subdirectory(agent)
if(AGENT_ENABLE_UNITTESTS)
enable_testing()
add_subdirectory(test)
endif()

include(cmake/ide_integration.cmake)

if(DEVELOPMENT)
message(STATUS "Including test package as part of the build for development")
enable_testing()
add_subdirectory(test_package test)
endif()

create_clangformat_target()

include(GNUInstallDirs)

if(NOT MSVC)
set(CMAKE_INSTALL_DATADIR "share/mtconnect")
set(CMAKE_INSTALL_SYSCONFDIR "etc/mtconnect")
else()
set(CMAKE_INSTALL_DATADIR ".")
set(CMAKE_INSTALL_SYSCONFDIR "bin")
endif()

# For Visual Studio generators it is now possible (since V3.6) to set a default startup project.
# We will set this to the agent_test project.
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT agent)

install(FILES README.md LICENSE.TXT DESTINATION ".")
install(DIRECTORY schemas/ DESTINATION "schemas")
install(DIRECTORY simulator/ DESTINATION "simulator")
install(DIRECTORY styles/ DESTINATION "styles")
install(DIRECTORY tools/ DESTINATION "tools")
install(DIRECTORY demo/ DESTINATION "demo")
install(FILES simulator/agent.cfg DESTINATION "bin")

install(FILES README.md LICENSE.TXT TYPE DATA COMPONENT Required)
install(DIRECTORY schemas TYPE DATA COMPONENT Data)
install(DIRECTORY simulator TYPE DATA COMPONENT Tools)
install(DIRECTORY styles TYPE DATA COMPONENT Data)
install(DIRECTORY tools TYPE DATA COMPONENT Tools)
install(DIRECTORY demo TYPE DATA COMPONENT Demo)
install(DIRECTORY docker TYPE DATA COMPONENT Demo)

set(CPACK_COMPONENT_Demo_DESCRIPTION "Demo files for the Mazak and Okuma digital twin")
set(CPACK_COMPONENT_Data_DESCRIPTION "Data files for schemas and styles to be served by the agent")
set(CPACK_COMPONENT_Tools_DESCRIPTION "Scripts for to support running and simulating adapter behavior")
set(CPACK_COMPONENT_Required_DESCRIPTION "Requied distribution files")
set(CPACK_COMPONENT_Development_DESCRIPTION "Supporting files for developing using the agent library")
set(CPACK_COMPONENT_Runtime_DESCRIPTION "Files required for running of the agent")

set(CPACK_COMPONENT_Required_REQUIRED 1)
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
set(CPACK_PACKAGE_VERSION "${AGENT_VERSION_MAJOR}.${AGENT_VERSION_MINOR}.${AGENT_VERSION_PATCH}.${AGENT_VERSION_BUILD}${AGENT_VERSION_RC}")
set(CPACK_PACKAGE_VERSION_MAJOR ${AGENT_VERSION_MAJOR})
Expand Down
Loading

0 comments on commit 7d9534a

Please sign in to comment.