Move scripts into dedicated directory

Now also using scripts/check.sh for Travis CI directly
This commit is contained in:
Martin Jäger
2021-05-18 08:47:26 +02:00
parent 84541d4311
commit 955eb0edb1
7 changed files with 7 additions and 13 deletions
+39
View File
@@ -0,0 +1,39 @@
@ECHO OFF
:: This file performs continuous integration checks and should be run before pushing new commits
echo "---------- Trailing whitespace check -------------"
:: check uncommitted changes
git diff --check HEAD
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
:: check all commits starting from initial commit
for /F %i in ('"git rev-list --max-parents=0 HEAD"') do git diff --check %i..HEAD
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
echo "---------- Running compile check -------------"
platformio run -e mppt_2420_lc -e mppt_1210_hus -e mppt_2420_hc -e pwm_2420_lus
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
echo "---------- Running unit-tests -------------"
platformio test -e unit_test
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
echo "---------- Running static code checks -------------"
platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
echo "---------- All tests passed -------------"
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
#
# This file performs continuous integration checks and should be run before pushing new commits
#
echo "---------- Trailing whitespace check -------------"
# check uncommitted changes
git diff --check HEAD
if [ $? != 0 ]; then
exit 1;
fi
# check all commits starting from initial commit
git diff --check `git rev-list --max-parents=0 HEAD`..HEAD
if [ $? != 0 ]; then
exit 1;
fi
echo "---------- Running compile check -------------"
platformio run -e mppt_2420_lc -e mppt_1210_hus -e mppt_2420_hc -e pwm_2420_lus
if [ $? != 0 ]; then
exit 1;
fi
echo "---------- Running unit-tests -------------"
platformio test -e unit_test
if [ $? != 0 ]; then
exit 1;
fi
echo "---------- Running static code checks -------------"
platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
if [ $? != 0 ]; then
exit 1;
fi
echo "---------- All tests passed -------------"
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
output_path = "info.json"
json_str = ""
main_obj = {}
temp_obj = {}
current_key = ""
name = ""
beginning_line = 0
save_lines = False
save_name = False
def append_stuff(temp_obj):
if current_key != "":
main_obj[current_key] = temp_obj.copy()
temp_obj.clear()
with open("src/data_nodes.cpp", 'r') as fd:
for (num, line) in enumerate(fd, 1):
if line =="\n":
continue
if "TS_NODE_PATH" in line:
if current_key != "":
append_stuff(temp_obj)
current_key = line.strip().split(",")[1].strip(' "')
continue
if (line.strip(" \n") == "/*{"):
save_lines = True
beginning_line = num
json_str +="{"
continue
elif (line.strip(" \n") == "}*/"):
json_str += "}"
save_lines = False
save_name = True
continue
if save_lines:
json_str += line
if save_name:
try:
name = line.strip().split(",")[1].strip(' "')
temp_obj[name] = json.loads(json_str)
except Exception as e:
print("Error while parsing block between lines {} and {}".format(beginning_line, num))
print(e)
exit(-1)
save_name = False
json_str = ""
append_stuff(temp_obj)
# add missing fields
for category in main_obj:
for node in main_obj[category]:
if not 'unit' in main_obj[category][node]:
main_obj[category][node]['unit'] = None
if not 'min' in main_obj[category][node]:
main_obj[category][node]['min'] = None
if not 'max' in main_obj[category][node]:
main_obj[category][node]['max'] = None
with open(output_path, "w", encoding='utf8') as filename:
json.dump(main_obj, filename, indent=4, ensure_ascii=False)
print("Saved file under: " + output_path)
+8
View File
@@ -0,0 +1,8 @@
# Custom settings, as referred to as "extra_script" in platformio.ini
#
# See http://docs.platformio.org/en/latest/projectconf.html#extra-script
Import("env")
env.Append( CXXFLAGS=[ "-Wno-register -fno-rtti" ] )