Skip to content

Commit 4bd939d

Browse files
authored
Fixes for deb build and CI (#18)
* 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
1 parent f705575 commit 4bd939d

File tree

6 files changed

+80
-45
lines changed

6 files changed

+80
-45
lines changed

.editorconfig

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ indent_style = tab
3434
end_of_line = crlf
3535

3636
[*.{xml,xslt}]
37-
indent_size = 2
37+
indent_size = 2
38+
39+
[CMakeLists.txt]
40+
indent_size = 2
41+
insert_final_newline = true
42+
trim_trailing_whitespace = true

.github/workflows/c-cpp.yml

+41-26
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
name: C/C++ CI
1+
name: Build and test C++ bennu and deb for pybennu
22

33
on:
44
pull_request:
5-
branches: [ "main" ]
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
610

711
jobs:
812
build:
9-
1013
runs-on: ubuntu-20.04
11-
1214
steps:
1315
- name: checkout the repo
14-
uses: actions/checkout@v3
15-
- name: get tags
16-
run: git fetch --tags
16+
uses: actions/checkout@v4
17+
- name: Install build dependencies
18+
run: |
19+
sudo apt-get update
20+
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
21+
sudo gem install fpm
1722
- name: configure bennu
1823
run: |
19-
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
2024
mkdir build
2125
cd build/
2226
cmake ../
@@ -53,29 +57,40 @@ jobs:
5357
grep "load-power:999" probe.out
5458
echo -e "help\nexit" | bennu-brash >brash.out 2>&1
5559
grep "SCEPTRE Field-Device" brash.out
56-
- name: package bennu
60+
bennu-watcherd --help
61+
bennu-simulink-provider --help
62+
bennu-field-deviced --help
63+
bennu-simulink-provider-helics --help
64+
- name: build deb for bennu
5765
run: |
5866
cd build/
5967
sudo make package
60-
- name: package pybennu
68+
cp ./*.deb ../bennu.deb
69+
- name: build deb for pybennu
6170
run: |
62-
sudo apt-get install --no-install-recommends -y python3-pip python3-wheel
63-
sudo gem install fpm
6471
cd src/pybennu
65-
make deb > deb.log 2>&1
66-
#make dist > dist.log 2>&1
67-
- name: archive artifacts
68-
uses: actions/upload-artifact@v3
72+
sudo make deb
73+
cp ./dist/*.deb ../../pybennu.deb
74+
- name: archive deb artifacts
75+
uses: actions/upload-artifact@v4
6976
with:
70-
name: bennu artifacts
77+
name: bennu-deb-artifacts
78+
if-no-files-found: error
7179
path: |
72-
*.log
73-
build/*.deb
74-
src/pybennu/dist/*
75-
- name: release bennu and pybennu
80+
bennu.deb
81+
pybennu.deb
82+
- name: deb file metadata
7683
run: |
77-
cp build/*.deb build/bennu.deb
78-
cp src/pybennu/dist/*.deb src/pybennu/dist/pybennu.deb
79-
curl -F package=@build/bennu.deb https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/
80-
curl -F package=@src/pybennu/dist/pybennu.deb https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/
81-
84+
dpkg-deb --info ./bennu.deb
85+
dpkg-deb --info ./pybennu.deb
86+
- name: check bennu deb installs
87+
run: |
88+
sudo dpkg -i bennu.deb
89+
- name: check pybennu deb installs
90+
run: |
91+
sudo dpkg -i pybennu.deb
92+
- name: release debs to apt repo
93+
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')
94+
run: |
95+
curl -F [email protected] https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/
96+
curl -F [email protected] https://${{ secrets.GEMFURY }}@push.fury.io/sceptre/

CMakeLists.txt

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
cmake_minimum_required (VERSION 3.8.0 FATAL_ERROR)
1+
cmake_minimum_required (VERSION 3.12.0 FATAL_ERROR)
22

3-
# Get the latest tag of the working branch
4-
execute_process(
5-
COMMAND git describe --abbrev=0
6-
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
7-
OUTPUT_VARIABLE bennu_TAG
8-
OUTPUT_STRIP_TRAILING_WHITESPACE
9-
)
10-
11-
# Get the latest tag and abbreviated commit hash of the working branch
3+
# Get the abbreviated commit hash of the working branch
124
execute_process(
135
COMMAND git rev-parse --short HEAD
146
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
15-
OUTPUT_VARIABLE bennu_TAG_HASH
7+
OUTPUT_VARIABLE bennu_SHORT_HASH
168
OUTPUT_STRIP_TRAILING_WHITESPACE
179
)
1810

19-
project(bennu VERSION ${bennu_TAG} LANGUAGES C CXX)
11+
# CMake requires semantic versions with integer components
12+
# Set it to something static so stuff works
13+
set(bennu_VERSION "6.0.0")
14+
15+
# Add commit hash to the version for use by the Deb package builder
16+
# Example: 6.0.0.f7055755
17+
set(bennu_VERSION_WITH_COMMIT "${bennu_VERSION}.${bennu_SHORT_HASH}")
18+
19+
project(bennu
20+
VERSION "${bennu_VERSION}"
21+
DESCRIPTION "SCEPTRE ICS Modeling and Simulation Package"
22+
HOMEPAGE_URL "https://github.com/sandialabs/sceptre-bennu"
23+
LANGUAGES C CXX
24+
)
2025

2126
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2227
message(STATUS "Setting build type to 'Release' as none was specified.")

cmake/CpackConfig.cmake

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
# Generate deb package
2+
# CPack DEB documentation: https://cmake.org/cmake/help/latest/cpack_gen/deb.html
3+
# Debian archive description: https://www.debian.org/doc/debian-policy/ch-archive.html
4+
# Debian archive metadata: https://www.debian.org/doc/debian-policy/ch-controlfields.html
5+
26
string(TIMESTAMP timestamp "%Y%m%d_%H-%M-%S")
37
set(CPACK_GENERATOR "DEB")
48
set(CPACK_STRIP_FILES TRUE)
59
set(CPACK_DEBIAN_PACKAGE_NAME bennu)
6-
set(CPACK_DEBIAN_PACKAGE_VERSION ${bennu_TAG_HASH})
7-
set(CPACK_DEBIAN_PACKAGE_ARCHITECHTURE amd64)
8-
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sandia National Laboratories <[email protected]")
10+
11+
# "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."
12+
# NOTE: "bennu_VERSION_WITH_COMMIT" gets set in the top-level CMakeLists.txt file
13+
set(CPACK_DEBIAN_PACKAGE_VERSION ${bennu_VERSION_WITH_COMMIT})
14+
15+
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
16+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sandia National Laboratories <[email protected]>")
917
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libasio-dev, libboost-date-time-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev")
1018
set(CPACK_DEBIAN_PACKAGE_SECTION misc)
11-
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "SCEPTRE ICS Modeling and Simulation Package")
19+
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})
1220
set(CPACK_PACKAGE_FILE_NAME "bennu-${CPACK_DEBIAN_PACKAGE_VERSION}_amd64_${timestamp}")
21+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CMAKE_PROJECT_HOMEPAGE_URL})
22+
1323
include(CPack)

src/pybennu/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TIMESTAMP = $(shell date +%Y%m%d_%H-%M-%S)
4040
PACKAGE_SECTION = python
4141
PACKAGE_PRIORITY = extra
4242
PACKAGE_COMPRESSION = bzip2
43-
PACKAGE_FULL_VERSION:=$(shell git rev-parse --short HEAD)
43+
PACKAGE_FULL_VERSION := 6.0.0.$(shell git rev-parse --short HEAD)
4444
PACKAGE_NAME = pybennu
4545
PACKAGE_FILENAME = $(PACKAGE_NAME)_$(PACKAGE_FULL_VERSION)_amd64_$(TIMESTAMP).deb
4646
PACKAGE_VENDOR = SNL

src/pybennu/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def run(self):
153153
# https://peps.python.org/pep-0440/
154154
# TODO: move to pyproject.toml, use setuptools_scm to do version handling
155155
# https://github.com/pypa/setuptools_scm
156-
version = '0.0.0',
156+
version = '6.0.0',
157157
description = 'bennu python providers and utilities',
158158
url = 'https://github.com/sandialabs/sceptre-bennu.git',
159159
author = 'Sandia National Laboratories',

0 commit comments

Comments
 (0)