Skip to content

Commit

Permalink
Fixes for deb build and CI (#18)
Browse files Browse the repository at this point in the history
* Fix invalid version string for the bennu .deb

- Ensure .deb has a properly formatted version
- Set version for everything in cmake to 6.0.0 (not intended to change, just a placeholder)
- Add GitHub URL to package metadata
- Fix architecture variable
- Fix warning with old tags command

* refactoring CI for bennu C++ build

* apply version fix to pybennu deb as well

* WIP on CI

* more CI tweaks

* sudo is needed

* split into separate steps, upload artifacts earlier
  • Loading branch information
GhostofGoes authored Feb 9, 2024
1 parent f705575 commit 4bd939d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 45 deletions.
7 changes: 6 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ indent_style = tab
end_of_line = crlf

[*.{xml,xslt}]
indent_size = 2
indent_size = 2

[CMakeLists.txt]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
67 changes: 41 additions & 26 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
name: C/C++ CI
name: Build and test C++ bennu and deb for pybennu

on:
pull_request:
branches: [ "main" ]
branches:
- main
push:
branches:
- main

jobs:
build:

runs-on: ubuntu-20.04

steps:
- name: checkout the repo
uses: actions/checkout@v3
- name: get tags
run: git fetch --tags
uses: actions/checkout@v4
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y build-essential cmake g++ gcc libasio-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev libfreetype6-dev libssl-dev libzmq5-dev python3-pip python3-wheel
sudo gem install fpm
- name: configure bennu
run: |
sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential cmake g++ gcc libasio-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev libfreetype6-dev libssl-dev libzmq5-dev
mkdir build
cd build/
cmake ../
Expand Down Expand Up @@ -53,29 +57,40 @@ jobs:
grep "load-power:999" probe.out
echo -e "help\nexit" | bennu-brash >brash.out 2>&1
grep "SCEPTRE Field-Device" brash.out
- name: package bennu
bennu-watcherd --help
bennu-simulink-provider --help
bennu-field-deviced --help
bennu-simulink-provider-helics --help
- name: build deb for bennu
run: |
cd build/
sudo make package
- name: package pybennu
cp ./*.deb ../bennu.deb
- name: build deb for pybennu
run: |
sudo apt-get install --no-install-recommends -y python3-pip python3-wheel
sudo gem install fpm
cd src/pybennu
make deb > deb.log 2>&1
#make dist > dist.log 2>&1
- name: archive artifacts
uses: actions/upload-artifact@v3
sudo make deb
cp ./dist/*.deb ../../pybennu.deb
- name: archive deb artifacts
uses: actions/upload-artifact@v4
with:
name: bennu artifacts
name: bennu-deb-artifacts
if-no-files-found: error
path: |
*.log
build/*.deb
src/pybennu/dist/*
- name: release bennu and pybennu
bennu.deb
pybennu.deb
- name: deb file metadata
run: |
cp build/*.deb build/bennu.deb
cp src/pybennu/dist/*.deb src/pybennu/dist/pybennu.deb
curl -F package=@build/bennu.deb https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/
curl -F package=@src/pybennu/dist/pybennu.deb https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/
dpkg-deb --info ./bennu.deb
dpkg-deb --info ./pybennu.deb
- name: check bennu deb installs
run: |
sudo dpkg -i bennu.deb
- name: check pybennu deb installs
run: |
sudo dpkg -i pybennu.deb
- name: release debs to apt repo
if: (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) || (github.event_name == 'push' && github.ref == 'refs/heads/main')
run: |
curl -F [email protected] https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/
curl -F [email protected] https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/
29 changes: 17 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
cmake_minimum_required (VERSION 3.8.0 FATAL_ERROR)
cmake_minimum_required (VERSION 3.12.0 FATAL_ERROR)

# Get the latest tag of the working branch
execute_process(
COMMAND git describe --abbrev=0
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE bennu_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the latest tag and abbreviated commit hash of the working branch
# Get the abbreviated commit hash of the working branch
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE bennu_TAG_HASH
OUTPUT_VARIABLE bennu_SHORT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

project(bennu VERSION ${bennu_TAG} LANGUAGES C CXX)
# CMake requires semantic versions with integer components
# Set it to something static so stuff works
set(bennu_VERSION "6.0.0")

# Add commit hash to the version for use by the Deb package builder
# Example: 6.0.0.f7055755
set(bennu_VERSION_WITH_COMMIT "${bennu_VERSION}.${bennu_SHORT_HASH}")

project(bennu
VERSION "${bennu_VERSION}"
DESCRIPTION "SCEPTRE ICS Modeling and Simulation Package"
HOMEPAGE_URL "https://github.com/sandialabs/sceptre-bennu"
LANGUAGES C CXX
)

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
Expand Down
18 changes: 14 additions & 4 deletions cmake/CpackConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Generate deb package
# CPack DEB documentation: https://cmake.org/cmake/help/latest/cpack_gen/deb.html
# Debian archive description: https://www.debian.org/doc/debian-policy/ch-archive.html
# Debian archive metadata: https://www.debian.org/doc/debian-policy/ch-controlfields.html

string(TIMESTAMP timestamp "%Y%m%d_%H-%M-%S")
set(CPACK_GENERATOR "DEB")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_DEBIAN_PACKAGE_NAME bennu)
set(CPACK_DEBIAN_PACKAGE_VERSION ${bennu_TAG_HASH})
set(CPACK_DEBIAN_PACKAGE_ARCHITECHTURE amd64)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sandia National Laboratories <[email protected]")

# "This variable may contain only alphanumerics (A-Za-z0-9) and the characters . + - ~ (full stop, plus, hyphen, tilde) and should start with a digit. If CPACK_DEBIAN_PACKAGE_RELEASE is not set then hyphens are not allowed."
# NOTE: "bennu_VERSION_WITH_COMMIT" gets set in the top-level CMakeLists.txt file
set(CPACK_DEBIAN_PACKAGE_VERSION ${bennu_VERSION_WITH_COMMIT})

set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sandia National Laboratories <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libasio-dev, libboost-date-time-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev")
set(CPACK_DEBIAN_PACKAGE_SECTION misc)
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "SCEPTRE ICS Modeling and Simulation Package")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_FILE_NAME "bennu-${CPACK_DEBIAN_PACKAGE_VERSION}_amd64_${timestamp}")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CMAKE_PROJECT_HOMEPAGE_URL})

include(CPack)
2 changes: 1 addition & 1 deletion src/pybennu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TIMESTAMP = $(shell date +%Y%m%d_%H-%M-%S)
PACKAGE_SECTION = python
PACKAGE_PRIORITY = extra
PACKAGE_COMPRESSION = bzip2
PACKAGE_FULL_VERSION:=$(shell git rev-parse --short HEAD)
PACKAGE_FULL_VERSION := 6.0.0.$(shell git rev-parse --short HEAD)
PACKAGE_NAME = pybennu
PACKAGE_FILENAME = $(PACKAGE_NAME)_$(PACKAGE_FULL_VERSION)_amd64_$(TIMESTAMP).deb
PACKAGE_VENDOR = SNL
Expand Down
2 changes: 1 addition & 1 deletion src/pybennu/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def run(self):
# https://peps.python.org/pep-0440/
# TODO: move to pyproject.toml, use setuptools_scm to do version handling
# https://github.com/pypa/setuptools_scm
version = '0.0.0',
version = '6.0.0',
description = 'bennu python providers and utilities',
url = 'https://github.com/sandialabs/sceptre-bennu.git',
author = 'Sandia National Laboratories',
Expand Down

0 comments on commit 4bd939d

Please sign in to comment.