Skip to content

Commit

Permalink
🔖 (v1.4.0): Merge branch 'release/v1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Mar 15, 2023
2 parents 5a49826 + d96020a commit 64abbdc
Show file tree
Hide file tree
Showing 316 changed files with 9,409 additions and 6,262 deletions.
5 changes: 2 additions & 3 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
./extern
./cmake
./targets
./_build
./_build_unit_tests
./_build_cmake_tools
./_build*
*external*
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ CheckOptions:
value: true
- key: readability-magic-numbers.IgnoredIntegerValues
value: "1;2;3;4;10;100;1000;60;80;3600;9600;57600;115200;128;255;1000000"
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: "1;2;3;4;10;100;1000;"
- key: readability-identifier-length.IgnoredVariableNames
value: "^(fs|c|ms|fh|t|bd|s|hz|id|[abcijkxyz])$"
- key: readability-identifier-length.IgnoredParameterNames
Expand Down
69 changes: 69 additions & 0 deletions .github/actions/check_version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Leka - LekaOS
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

name: "Get os/firmware version"
description: ""

inputs:
firmware_hex_path:
description: "Path to Firmware hex file"
required: true

os_bin_path:
description: "Path to LekaOS bin file"
required: true

runs:
using: "composite"
steps:
- name: Get version from firmware hex
id: get_version_from_firmware_hex
shell: bash
run: |
python ${{ github.action_path }}/get_version_from_firmware_hex.py ${{ inputs.firmware_hex_path }}
- name: Get version from OS bin
id: get_version_from_os_bin
shell: bash
run: |
python ${{ github.action_path }}/get_version_from_os_bin.py ${{ inputs.os_bin_path }}
- name: Compare firmware version with firmware file
id: compare_firmware_version_with_firmware_file
shell: bash
run: |
python ${{ github.action_path }}/compare_with_file_name.py ${{ inputs.firmware_hex_path }} ${{ env.FIRMWARE_VERSION_FILE }}
- name: Compare OS version with OS file
id: compare_os_version_with_os_file
shell: bash
run: |
python ${{ github.action_path }}/compare_with_file_name.py ${{ inputs.os_bin_path }} ${{ env.OS_VERSION_FILE }}
- name: Compare versions from files with os_version
id: compare_versions_from_files_with_os_version
shell: bash
run: |
python ${{ github.action_path }}/compare_with_os_version.py config/os_version ${{ env.FIRMWARE_VERSION_FILE }} ${{ env.OS_VERSION_FILE }}
- name: Generate version comparison report
id: generate_version_comparison_report
shell: bash
run: |
${{ github.action_path }}/generate_report.sh
- name: Publish version
uses: marocchino/sticky-pull-request-comment@v2
with:
header: publish_version
message: |
# :bookmark: Version comparison
${{ env.VERSION_COMPARISON_OUTPUT }}
- name: Check versions are all identical
id: check_versions_are_all_identical
shell: bash
run: |
${{ github.action_path }}/check_versions_are_all_identical.sh
23 changes: 23 additions & 0 deletions .github/actions/check_version/check_versions_are_all_identical.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Leka - LekaOS
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

shopt -s xpg_echo

if [ $OS_VERSION_FILE_ARE_SAME != "True" ]; then
exit 1
fi

if [ $OS_VERSION_ARE_SAME != "True" ]; then
exit 1
fi

if [ $FIRMWARE_VERSION_FILE_ARE_SAME != "True" ]; then
exit 1
fi

if [ $FIRMWARE_VERSION_ARE_SAME != "True" ]; then
exit 1
fi

exit 0
46 changes: 46 additions & 0 deletions .github/actions/check_version/compare_with_file_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3

# Leka - LekaOS
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

import sys
import argparse
import utils


#
# MARK: - argparse
#


parser = argparse.ArgumentParser(
description="Check filename contains version number"
)

parser.add_argument("file_path", type=str,
help="path of file to compare with version")
parser.add_argument("version", type=str, help="version to compare with")

args = parser.parse_args()


#
# MARK: - Main
#


def main():
are_version_same: bool = args.version in args.file_path

if "Firmware" in args.file_path:
utils.addToEnvironement(
f"FIRMWARE_VERSION_FILE_ARE_SAME={are_version_same}")
elif "LekaOS" in args.file_path:
utils.addToEnvironement(f"OS_VERSION_FILE_ARE_SAME={are_version_same}")

return 0


if __name__ == "__main__":
sys.exit(main())
62 changes: 62 additions & 0 deletions .github/actions/check_version/compare_with_os_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3

# Leka - LekaOS
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

import sys
import argparse
import utils


#
# MARK: - argparse
#


parser = argparse.ArgumentParser(
description="Check os & firmware version are equal to os_version config"
)

parser.add_argument(
"version_config_path", type=str, help="version config filepath"
)
parser.add_argument("firmware_version", type=str, help="firmware_version")
parser.add_argument("os_version", type=str, help="os_version")

args = parser.parse_args()


#
# MARK: - Functions
#


def checkVersionsAreEquals(config_version: str, actual_version: str) -> bool:
return config_version in actual_version


#
# MARK: - Main
#


def main():
config_version = utils.getDataFromFile(
args.version_config_path).replace("\n", "")

is_firmware_version_correct = checkVersionsAreEquals(
config_version, args.firmware_version)

is_os_version_correct = checkVersionsAreEquals(
config_version, args.os_version)

utils.addToEnvironement(
f"FIRMWARE_VERSION_ARE_SAME={is_firmware_version_correct}")
utils.addToEnvironement(f"OS_VERSION_ARE_SAME={is_os_version_correct}")

return 0


if __name__ == "__main__":
sys.exit(main())
48 changes: 48 additions & 0 deletions .github/actions/check_version/generate_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Leka - LekaOS
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

shopt -s xpg_echo

OUTPUT_OS_VERSION="`(echo $OS_VERSION_FILE)`"
OUTPUT_FIRMWARE_VERSION="`(echo $FIRMWARE_VERSION_FILE)`"

if [ $OS_VERSION_FILE_ARE_SAME = "True" ]; then
OUTPUT_OS_VERSION_SAME_AS_FILE="✔️"
else
OUTPUT_OS_VERSION_SAME_AS_FILE=""
fi

if [ $OS_VERSION_ARE_SAME = "True" ]; then
OUTPUT_OS_VERSION_SAME_AS_OS_VERSION_CONFIG="✔️"
else
OUTPUT_OS_VERSION_SAME_AS_OS_VERSION_CONFIG=""
fi

if [ $FIRMWARE_VERSION_FILE_ARE_SAME = "True" ]; then
OUTPUT_FIRMWARE_VERSION_SAME_AS_FILE="✔️"
else
OUTPUT_FIRMWARE_VERSION_SAME_AS_FILE=""
fi

if [ $FIRMWARE_VERSION_ARE_SAME = "True" ]; then
OUTPUT_FIRMWARE_VERSION_SAME_AS_OS_VERSION_CONFIG="✔️"
else
OUTPUT_FIRMWARE_VERSION_SAME_AS_OS_VERSION_CONFIG=""
fi

#
# MARK: - markdown output
#

echo "Creating markdown output"

echo 'VERSION_COMPARISON_OUTPUT<<EOF_VERSION_COMPARISON_OUTPUT' >> $GITHUB_ENV

echo -n "| | Version | Same as filename | Same as os_version |\n" >> $GITHUB_ENV
echo -n "|:---------------------------------:|:--------------------------:|:----------------:|:--------------------:|\n" >> $GITHUB_ENV
echo -n "| **os** |\`$OUTPUT_OS_VERSION\` |$OUTPUT_OS_VERSION_SAME_AS_FILE |$OUTPUT_OS_VERSION_SAME_AS_OS_VERSION_CONFIG |\n" >> $GITHUB_ENV
echo -n "| **firmware**<br>(bootloader + os) |\`$OUTPUT_FIRMWARE_VERSION\`|$OUTPUT_FIRMWARE_VERSION_SAME_AS_FILE|$OUTPUT_FIRMWARE_VERSION_SAME_AS_OS_VERSION_CONFIG|\n" >> $GITHUB_ENV


echo 'EOF_VERSION_COMPARISON_OUTPUT' >> $GITHUB_ENV
92 changes: 92 additions & 0 deletions .github/actions/check_version/get_version_from_firmware_hex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python3

# Leka - LekaOS
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

import sys
import argparse
import utils

#
# MARK: - argparse
#


parser = argparse.ArgumentParser(
description="Get version from firmware hex file")

parser.add_argument("firmware_hex_path", type=str,
help="path of firmware hex file")

args = parser.parse_args()


#
# MARK: - Functions
#


def getLineOfVersion() -> str:
START_OS_MARKER = ":020000040804EE\n"

firmware_raw = utils.getDataFromFile(args.firmware_hex_path)

pos_os_start = firmware_raw.find(START_OS_MARKER)
pos_line_previous_version_line = firmware_raw.find(
"\n", pos_os_start + len(START_OS_MARKER) + 1
)
pos_version_start_line = firmware_raw.find(
"\n", pos_line_previous_version_line)
pos_version_end_line = firmware_raw.find("\n", pos_version_start_line + 1)

return firmware_raw[pos_version_start_line:pos_version_end_line]


def getFirmwareVersionRaw() -> str:
START_VERSION_MARKER = 18
VERSION_SIZE = 16

version_line = getLineOfVersion()

version_raw = version_line[
START_VERSION_MARKER: START_VERSION_MARKER + VERSION_SIZE
]

return version_raw


def getFirmwareVersion() -> str:
raw = getFirmwareVersionRaw()

major = int(raw[0:2], 16)
minor = int(raw[2:4], 16)
revision = int(
raw[6:8] + raw[4:6], 16
)
build = int(
raw[14:16]
+ raw[12:14]
+ raw[10:12]
+ raw[8:10],
16,
)

version = f"{major}.{minor}.{revision}+{build}"
return version


#
# MARK: - Main
#


def main():
firmware_version = getFirmwareVersion()
utils.addToEnvironement(f"FIRMWARE_VERSION_FILE={firmware_version}")

return 0


if __name__ == "__main__":
sys.exit(main())
Loading

0 comments on commit 64abbdc

Please sign in to comment.