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

implement build version info #29

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
37 changes: 0 additions & 37 deletions .azure/nightly-release.yml

This file was deleted.

35 changes: 25 additions & 10 deletions .azure/templates/build-insight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ steps:
- script: python -m pip install --upgrade pip
displayName: 'Update pip'

# Generate build_info.py
- bash: |
GIT_HASH_SHORT=$(git rev-parse --short HEAD)

echo "CYCLONEDDS_INSIGHT_GIT_HASH_SHORT = \"$GIT_HASH_SHORT\"" > src/build_info.py
echo "CYCLONEDDS_INSIGHT_GIT_BRANCH = \"${GIT_BRANCH}\"" >> src/build_info.py
displayName: Generate build_info.py

# Get Version
- bash: |
version=$(python src/version.py)
echo "###vso[task.setvariable variable=version;]$version"
displayName: Capture Version
name: versionStep

# Build CycloneDDS
- bash: |
mkdir -p deps
Expand All @@ -39,7 +54,7 @@ steps:
cmake --build . --config Release --target install --parallel
name: cyclonedds_build
displayName: Build CycloneDDS

# Build CycloneDDS-Python
- bash: |
cd deps
Expand Down Expand Up @@ -79,29 +94,29 @@ steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'iscc.exe setup.iss /DTheAppVersion=0.0.0'
script: 'iscc.exe setup.iss /DTheAppVersion=$(VERSION)'
condition: eq(variables['Agent.OS'], 'Windows_NT')
name: cyclonedds_insight_build_win_setup
displayName: Build CycloneDDS-Insight
- task: PublishPipelineArtifact@1
condition: eq(variables['Agent.OS'], 'Windows_NT')
inputs:
targetPath: dist/cyclonedds-insight-0.0.0-windows-x64.exe
artifactName: cyclonedds-insight-0.0.0-windows-x64
targetPath: dist/cyclonedds-insight-$(version)-windows-x64.exe
artifactName: cyclonedds-insight-$(version)-windows-x64

# Linux Bundle
- bash: |
set -e -x
cd dist
tar -czf cyclonedds-insight-0.0.0-linux-x64.tar.gz "CycloneDDS Insight"
tar -czf cyclonedds-insight-${VERSION}-linux-x64.tar.gz "CycloneDDS Insight"
name: cyclonedds_insight_build_lnx_tgz
displayName: Build CycloneDDS-Insight-Tgz
condition: eq(variables['Agent.OS'], 'Linux')
- task: PublishPipelineArtifact@1
condition: eq(variables['Agent.OS'], 'Linux')
inputs:
targetPath: dist/cyclonedds-insight-0.0.0-linux-x64.tar.gz
artifactName: cyclonedds-insight-0.0.0-linux-x64
targetPath: dist/cyclonedds-insight-$(version)-linux-x64.tar.gz
artifactName: cyclonedds-insight-$(version)-linux-x64

# MacOS Bundle
- bash: |
Expand All @@ -110,12 +125,12 @@ steps:
cd dist
cp -r "CycloneDDS Insight.app" bundle && \
cd bundle
tar -czf cyclonedds-insight-0.0.0-macos-x64.tar.gz CycloneDDS\ Insight.app
tar -czf cyclonedds-insight-${VERSION}-macos-x64.tar.gz CycloneDDS\ Insight.app
name: cyclonedds_insight_build_bundle
displayName: Bundle MacOs App
condition: eq(variables['Agent.OS'], 'Darwin')
- task: PublishPipelineArtifact@1
condition: eq(variables['Agent.OS'], 'Darwin')
inputs:
targetPath: "dist/bundle/cyclonedds-insight-0.0.0-macos-x64.tar.gz"
artifactName: cyclonedds-insight-0.0.0-macos-x64
targetPath: dist/bundle/cyclonedds-insight-$(version)-macos-x64.tar.gz
artifactName: cyclonedds-insight-$(version)-macos-x64
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
cyclonedds/__library__.py
src/qrc_file.py
deps/*
build_info.py

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

***Looking for binaries?***
- The released App will be published under [Releases](https://github.com/eclipse-cyclonedds/cyclonedds-insight/releases).
- The nightly master build can be downloaded [here](https://dev.azure.com/eclipse-cyclonedds/cyclonedds-insight/_build) under "Nightly-Release" / "#Date.Nr" / "3 published".
- The latest master build can be downloaded [here](https://dev.azure.com/eclipse-cyclonedds/cyclonedds-insight/_build?definitionId=19&_a=summary&repositoryFilter=8&branchFilter=1200%2C1200%2C1200%2C1200) click on latest build / "3 published".

## Overview

Expand Down
6 changes: 5 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause


trigger: [ '*' ]
pr: [ '*' ]

variables:
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
GIT_BRANCH: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
GIT_BRANCH: $[ replace(variables['System.PullRequest.SourceBranch'], 'refs/pull/', '') ]

jobs:
- job: BuildInsight
Expand Down
11 changes: 10 additions & 1 deletion main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@
"""

import os
import sys
import platform
import importlib.util

# Load version
version_path = 'src/version.py'
spec = importlib.util.spec_from_file_location("version", version_path)
version = importlib.util.module_from_spec(spec)
sys.modules["version"] = version
spec.loader.exec_module(version)
print("CycloneDDS Insight Version:", version.CYCLONEDDS_INSIGHT_VERSION)

# CycloneDDS
cyclonedds_home = os.getenv('CYCLONEDDS_HOME')
Expand Down Expand Up @@ -87,5 +96,5 @@ app = BUNDLE(coll,
name='CycloneDDS Insight.app',
icon='./res/images/icon.icns',
bundle_identifier=None,
version='0.0.0'
version=str(version.CYCLONEDDS_INSIGHT_VERSION)
)
2 changes: 1 addition & 1 deletion setup.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; The real version will be passed by command-line call
#ifndef TheAppVersion
#define TheAppVersion "0.0.0"
#define TheAppVersion "unknown"
#endif

#define TheAppName "CycloneDDS Insight"
Expand Down
10 changes: 7 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
from models.overview_model import TreeModel, TreeNode
from models.endpoint_model import EndpointModel
from models.datamodel_model import DatamodelModel
from utils import qt_message_handler, setupLogger
from utils import qt_message_handler, setupLogger, getBuildInfoGitHashShort, getBuildInfoGitBranch
from version import CYCLONEDDS_INSIGHT_VERSION

# generated by pyside6-rcc
import qrc_file
Expand All @@ -64,7 +65,7 @@
# Print qml log messages into the python log
qInstallMessageHandler(qt_message_handler)

logging.info("Starting App ...")
logging.info(f"Starting CycloneDDS Insight Version {CYCLONEDDS_INSIGHT_VERSION} ({getBuildInfoGitHashShort()}-{getBuildInfoGitBranch()}) ...")
logging.debug(f"Application path: {APPLICATION_PATH}")
logging.debug(f"Python version: {str(sys.version)}")
logging.debug(f"Qt version: {qVersion()}")
Expand All @@ -88,7 +89,10 @@
engine.rootContext().setContextProperty("treeModel", treeModel)
engine.rootContext().setContextProperty("datamodelRepoModel", datamodelRepoModel)
engine.rootContext().setContextProperty("CYCLONEDDS_URI", os.getenv("CYCLONEDDS_URI", "<not set>"))
engine.rootContext().setContextProperty("CYCLONEDDS_INSIGHT_VERSION", "0.0.0")
engine.rootContext().setContextProperty("CYCLONEDDS_INSIGHT_VERSION", CYCLONEDDS_INSIGHT_VERSION)
engine.rootContext().setContextProperty("CYCLONEDDS_INSIGHT_GIT_HASH_SHORT", getBuildInfoGitHashShort())
engine.rootContext().setContextProperty("CYCLONEDDS_INSIGHT_GIT_BRANCH", getBuildInfoGitBranch())

qmlRegisterType(EndpointModel, "org.eclipse.cyclonedds.insight", 1, 0, "EndpointModel")

engine.load(QUrl("qrc:/src/views/main.qml"))
Expand Down
14 changes: 14 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,17 @@ def setupLogger(log_level = logging.DEBUG):

logger.addHandler(file_handler)
logger.addHandler(stream_handler)

def getBuildInfoGitHashShort() -> str:
try:
from build_info import CYCLONEDDS_INSIGHT_GIT_HASH_SHORT
return CYCLONEDDS_INSIGHT_GIT_HASH_SHORT
except ModuleNotFoundError:
return "n/a"

def getBuildInfoGitBranch() -> str:
try:
from build_info import CYCLONEDDS_INSIGHT_GIT_BRANCH
return CYCLONEDDS_INSIGHT_GIT_BRANCH
except ModuleNotFoundError:
return "n/a"
4 changes: 4 additions & 0 deletions src/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CYCLONEDDS_INSIGHT_VERSION = "0.0.0"

if __name__ == "__main__":
print(CYCLONEDDS_INSIGHT_VERSION)
2 changes: 1 addition & 1 deletion src/views/AboutWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Window {
}

Label {
text: "Version: " + CYCLONEDDS_INSIGHT_VERSION
text: "Version: " + CYCLONEDDS_INSIGHT_VERSION + " (" + CYCLONEDDS_INSIGHT_GIT_HASH_SHORT + "-" + CYCLONEDDS_INSIGHT_GIT_BRANCH + ")"
font.pixelSize: 15
horizontalAlignment: Text.AlignHCenter
}
Expand Down