pull/273/head
RobertGawron 2025-06-24 19:29:42 +02:00
rodzic a2f0409d25
commit cb21e0391c
10 zmienionych plików z 71 dodań i 134 usunięć

Wyświetl plik

@ -11,34 +11,47 @@ jobs:
name: Build Docker Image
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.tag-image.outputs.image-tag }}
cache-hit: ${{ steps.cache-docker.outputs.cache-hit }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
id: cache-docker
with:
path: /tmp/.buildx-cache
key: docker-${{ hashFiles('**/Dockerfile', 'docker-compose.yml', '**/requirements.txt') }}
restore-keys: |
docker-
- name: Build Docker Image
run: docker-compose build
uses: docker/build-push-action@v3
with:
context: .
load: true
tags: ci-image:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Tag Docker Image
id: tag-image
- name: Move updated cache
run: |
IMAGE_TAG=ci-image-$(date +%s)
echo "image-tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
docker tag $(docker-compose images -q app) $IMAGE_TAG
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
if: steps.cache-docker.outputs.cache-hit != 'true'
- name: Save Docker Image
run: docker save -o image.tar ${{ steps.tag-image.outputs.image-tag }}
run: docker save -o image.tar ci-image:latest
- name: Upload Docker Image
uses: actions/upload-artifact@v4
with:
name: docker-image
path: image.tar
retention-days: 1
parallel-tasks:
name: Parallel Tasks
@ -47,7 +60,7 @@ jobs:
strategy:
matrix:
type: [c-static, python-static, firmware]
fail-fast: false # Continue other jobs if one fails
fail-fast: false
steps:
- name: Checkout Code
uses: actions/checkout@v3
@ -67,8 +80,7 @@ jobs:
run: docker load -i image.tar
- name: Start Docker Compose
run: |
docker-compose up -d --no-build
run: docker-compose up -d --no-build
- name: Run Analysis or Build
run: |

Wyświetl plik

@ -5,4 +5,5 @@ add_subdirectory(Software/Firmware/UnitTest/)
# Include the DevOps scripts (static code analysis, etc.)
include(DevOps/Cmake/DocsCoverage.cmake)
include(DevOps/Cmake/DocsCoverage.cmake)
include(DevOps/Cmake/PythonStaticAnalysis.cmake)

Wyświetl plik

@ -1 +1,2 @@
DocsCoverage/
DocsCoverage/
PythonStaticAnalysis/

Wyświetl plik

@ -1,51 +0,0 @@
# Find the required executables
find_program(DOXYGEN_EXECUTABLE doxygen)
find_program(PYTHON_EXECUTABLE python3) # Find Python3 for invoking Coverxygen
find_program(GENHTML_EXECUTABLE genhtml)
if(DOXYGEN_EXECUTABLE)
# Set the source directory and output directory for the Doxygen analysis
set(DOXYGEN_INPUT_DIR "${CMAKE_SOURCE_DIR}/Software/STM32F103RBTx/Application/")
set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/BuildArtifacts/DocsCoverage")
# Ensure the output directory exists
file(MAKE_DIRECTORY "${DOXYGEN_OUTPUT_DIR}")
# Set the paths for the Doxyfile template and the final generated Doxyfile
set(DOXYFILE_IN "${CMAKE_SOURCE_DIR}/DevOps/Scripts/Doxyfile.in")
set(DOXYFILE_OUT "${CMAKE_SOURCE_DIR}/DevOps/Scripts/Doxyfile")
# Create a template Doxyfile with CMake variables
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
# Create a custom target to run Doxygen for generating XML output (needed for Coverxygen)
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE} "${DOXYFILE_OUT}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Running Doxygen to detect missing comments and generate XML..."
VERBATIM
)
# Run Coverxygen via Python3 (if Python is available)
if(PYTHON_EXECUTABLE)
add_custom_command(TARGET docs
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} -m coverxygen --format lcov
--kind enum,enumvalue,friend,typedef,variable,function,class,struct,union,define
--xml-dir "${DOXYGEN_OUTPUT_DIR}/xml"
--src-dir "${DOXYGEN_INPUT_DIR}"
--output "${DOXYGEN_OUTPUT_DIR}/doc-coverage.info"
COMMAND ${GENHTML_EXECUTABLE} --no-function-coverage
--no-branch-coverage "${DOXYGEN_OUTPUT_DIR}/doc-coverage.info"
-o "${DOXYGEN_OUTPUT_DIR}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Generating Coverxygen documentation coverage report..."
VERBATIM
)
else()
message(WARNING "Python3 not found. Skipping Coverxygen coverage report generation.")
endif()
else()
message(WARNING "Doxygen not found. Skipping missing documentation check.")
endif()

Wyświetl plik

@ -1,24 +0,0 @@
# Define the output directories for Python static analysis and reports
set(PYTHON_ANALYZE_DIR ${CMAKE_SOURCE_DIR}/build/BuildArtifacts/PythonStaticAnalysis)
set(PYTHON_REPORT_DIR ${CMAKE_SOURCE_DIR}/DevOps/BuildArtifacts)
# Echo the variables for debugging
message(STATUS "PYTHON_ANALYZE_DIR: ${PYTHON_ANALYZE_DIR}")
message(STATUS "PYTHON_REPORT_DIR: ${PYTHON_REPORT_DIR}")
# Ensure the output directories exist
file(MAKE_DIRECTORY ${PYTHON_ANALYZE_DIR})
file(MAKE_DIRECTORY ${PYTHON_REPORT_DIR})
# Define a variable for the file path
set(PYTHON_STATIC_ANALYSIS_SCRIPT "${CMAKE_SOURCE_DIR}/DevOps/Scripts/PythonStaticAnalysis.sh")
# Add a custom target for Python static analysis
add_custom_target(pystatic
COMMAND bash -c " \
dos2unix ${PYTHON_STATIC_ANALYSIS_SCRIPT} && source ${PYTHON_STATIC_ANALYSIS_SCRIPT}"
COMMENT "Running Python static analysis with Prospector and generating reports..."
VERBATIM
)

Wyświetl plik

@ -75,9 +75,11 @@ RUN apt-get update && apt-get install -y \
gcovr \
clang
# Clone FFF for Unit Test
RUN git clone https://github.com/meekrosoft/fff.git /workspace/fff
RUN /workspace/venv/bin/pip install --upgrade pip && \
/workspace/venv/bin/pip install \
prospector \
vjunit
# Command to run the container
CMD ["bash"]

Wyświetl plik

@ -55,6 +55,11 @@ ctest --output-on-failure
clear && rm -rf /workspace/build/* ; cmake .. && make docs
# Python static analyse
clear && rm -rf /workspace/build/* ; cmake .. && make pystatic
# Hardware flashing
Hardware connection

Wyświetl plik

@ -0,0 +1,31 @@
# Activate the virtual environment
source /workspace/venv/bin/activate
# Set up directories for artifacts
OUTPUT_DIR="/workspace/DevOps/BuildArtifacts/PythonStaticAnalysis"
mkdir -p "$OUTPUT_DIR"
# Define input and output file paths
MEASUREMENT_ACQUISITION_JSON="$OUTPUT_DIR/SystemTests.json"
MEASUREMENT_ACQUISITION_HTML="$OUTPUT_DIR/SystemTests.html"
# Initialize exit code tracker
EXIT_CODE=0
# Run Prospector analysis
prospector --profile /workspace/DevOps/Scripts/.prospector.yaml --strictness veryhigh --doc-warnings --output-format xunit /workspace/Software/MeasurementAcquisition > "$MEASUREMENT_ACQUISITION_JSON" || EXIT_CODE=1
# vjunit is broken in original version, so we need to fix it
find /workspace/venv/ -type f -name "vjunit.py" -exec sed -i 's/children = testcase\.getchildren()/children = list(testcase)/g' {} +
# Convert JSON reports to HTML using prospector-html
vjunit -f "$MEASUREMENT_ACQUISITION_JSON" -o "$MEASUREMENT_ACQUISITION_HTML" || echo "Warning: HTML conversion failed for MeasurementAcquisition"
# Expand all tabs in the HTML reports
sed -i "/\$('.ui.accordion').accordion();/c\\
\$('.ui.accordion').accordion();\\
\$('.ui.accordion .title').addClass('active');\\
\$('.ui.accordion .content').addClass('active');" "$MEASUREMENT_ACQUISITION_HTML"
# Exit with the appropriate code
exit $EXIT_CODE

Wyświetl plik

@ -1,40 +0,0 @@
# Activate the virtual environment
source /workspace/venv/bin/activate
# Set up directories for artifacts
OUTPUT_DIR="/workspace/build/BuildArtifacts/PythonStaticAnalysis"
mkdir -p "$OUTPUT_DIR"
# Define input and output file paths
SYSTEM_JSON="$OUTPUT_DIR/SystemTests.json"
SYSTEM_HTML="$OUTPUT_DIR/SystemTests.html"
SIMULATOR_JSON="$OUTPUT_DIR/FirmwarePCSimulator.json"
SIMULATOR_HTML="$OUTPUT_DIR/FirmwarePCSimulator.html"
# Initialize exit code tracker
EXIT_CODE=0
# Run Prospector analysis
prospector --profile /workspace/DevOps/Scripts/.prospector.yaml --strictness veryhigh --doc-warnings --output-format xunit /workspace/Test/System/ > "$SYSTEM_JSON" || EXIT_CODE=1
prospector --profile /workspace/DevOps/Scripts/.prospector.yaml --strictness veryhigh --doc-warnings --output-format xunit /workspace/Simulation/FirmwarePCSimulator/ > "$SIMULATOR_JSON" || EXIT_CODE=1
# vjunit is broken in original version, so we need to fix it
find /workspace/venv/ -type f -name "vjunit.py" -exec sed -i 's/children = testcase\.getchildren()/children = list(testcase)/g' {} +
# Convert JSON reports to HTML using prospector-html
vjunit -f "$SYSTEM_JSON" -o "$SYSTEM_HTML" || echo "Warning: HTML conversion failed for SystemTests"
vjunit -f "$SIMULATOR_JSON" -o "$SIMULATOR_HTML" || echo "Warning: HTML conversion failed for FirmwarePCSimulator"
# Expand all tabs in the HTML reports
sed -i "/\$('.ui.accordion').accordion();/c\\
\$('.ui.accordion').accordion();\\
\$('.ui.accordion .title').addClass('active');\\
\$('.ui.accordion .content').addClass('active');" "$SYSTEM_HTML"
sed -i "/\$('.ui.accordion').accordion();/c\\
\$('.ui.accordion').accordion();\\
\$('.ui.accordion .title').addClass('active');\\
\$('.ui.accordion .content').addClass('active');" "$SIMULATOR_HTML"
# Exit with the appropriate code
exit $EXIT_CODE