Skip to content

Commit

Permalink
Merge pull request #186 from RobertGawron/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
RobertGawron authored Dec 22, 2024
2 parents f97c0d5 + 09da274 commit 700ad8f
Show file tree
Hide file tree
Showing 41 changed files with 513 additions and 264 deletions.
65 changes: 57 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Build and Push Docker Image
run: |
docker build -t ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }} -f DevOps/HwDev/Docker/Dockerfile .
docker build -t ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }} -f DevOps/Dockerfile .
docker push ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }}
# Parallel Jobs: Unit Tests, Code Coverage, etc.
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: code-coverage-results
path: DevOps/HwDev/BuildArtifacts/CodeCoverage
path: DevOps/BuildArtifacts/CodeCoverage

- name: Clean up Docker containers
run: |
Expand Down Expand Up @@ -162,14 +162,63 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: docs-coverage-results
path: DevOps/HwDev/BuildArtifacts/DocsCoverage
path: DevOps/BuildArtifacts/DocsCoverage

- name: Clean up Docker containers
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml down
static-analysis:
name: Run Static Analysis
static-analysis-python:
name: Run Static Analysis (python)
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull Docker Image
run: |
docker pull ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }}
docker tag ghcr.io/robertgawron/hardwaredatalogger:${{ github.sha }} hardwaredatalogger:latest
- name: Run Docker Compose
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d
- name: Run Static Analysis
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml exec -T dev bash -c "\
set -e; \
cd /workspace/build && cmake .. && make pystatic"
- name: Upload Static Analysis (Python) Results
if: always()
uses: actions/upload-artifact@v4
with:
name: static-analysis-results-python
path: DevOps/BuildArtifacts/PythonStaticAnalysis

- name: Clean up Docker containers
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml down
static-analysis-c:
name: Run Static Analysis (cpp)
runs-on: ubuntu-latest
needs: build
steps:
Expand Down Expand Up @@ -210,9 +259,9 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: static-analysis-results
path: DevOps/HwDev/BuildArtifacts/StaticAnalysis
name: static-analysis-results-cpp
path: DevOps/BuildArtifacts/StaticAnalysis

- name: Clean up Docker containers
run: |
docker-compose -f docker-compose.yml -f docker-compose.ci.yml down
docker-compose -f docker-compose.yml -f docker-compose.ci.yml down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ add_subdirectory(Software/STM32F103RBTx/Application)
add_subdirectory(Simulation/FirmwarePCSimulator)
add_subdirectory(Test/Unit)

include(Software/StaticAnalysis.cmake)
include(Software/CStaticAnalysis.cmake)
include(Software/ClassDiagram.cmake)
include(Software/DocsCoverage.cmake)

include(Simulation/FirmwarePCSimulator/PythonStaticAnalysis.cmake)


4 changes: 3 additions & 1 deletion DevOps/HwDev/Docker/Dockerfile → DevOps/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ RUN /workspace/venv/bin/pip install --upgrade pip && \
pytest \
pytest-html \
PyQt6 \
codechecker
codechecker \
prospector \
prospector2html

# Add virtual environment binaries to the PATH
ENV PATH="/workspace/venv/bin:$PATH"
Expand Down
Empty file removed DevOps/PiDev/.keep
Empty file.
Empty file removed DevOps/PiProd/.keep
Empty file.
119 changes: 1 addition & 118 deletions DevOps/README.md
Original file line number Diff line number Diff line change
@@ -1,118 +1 @@
# Docker

## Why?
For me, using Docker in embedded systems has a key advantage: it eliminates the need for a README filled with outdated commands for setting up the development environment. In reality, such lists are rarely kept up to date (I often forget to update them myself too!). Docker solves this problem by providing a structured list of everything you need to install to get your environment up and running. But it's more than just a list - it's code, meaning it can be verified, maintained, and reused easily.

## Prerequisites

* Install Docker. For Linux it should be simple, for Windows you need WSL installed first and some Linux image for it.

## Build Docker image

The idea is that we we will build image once and mount the project files, so that if there is no need to rebuild contain,er unless you add other tools.

### Run the Docker image

In the main directory (HardwareDataLogger) run the command to build the image.

Build the docker image:

docker-compose build dev

Start the Docker image:

docker-compose up -d --remove-orphans

Log into the Docker image:

docker-compose exec dev bash

Additionally at the end of work:

docker-compose down --remove-orphans

## Runing stuff

## Builds the firmware

make code

## Run tests

make test

## Run static analysis

cd /workspace/build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_STANDARD=17 .. && make static

# Run code coverage

cmake -DCMAKE_BUILD_TYPE=Debug .. && make -j23 && make test -j23 && make coverage

# Run docs coverage

make docs

# Run UML generation

make uml

## Running Include what you use

cd build

for INCLUDE_WHAT_YOU_USE:

CC="clang-10" CXX="clang++-10" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ../Software

for all the rest:

cmake ..


# Building and running Firmware PC Simulation

* Launch Docker as explained in the previous steps.
* Build the firmware in the PC variant:

cd /workspace/build/ && cmake .. && make -j24

* Start the simulation:

cd /workspace/Simulation/FirmwarePCSimulator/ && python3 main.py

* all at once:

cd /workspace/build/ && cmake .. && make -j24 && cd /workspace/Simulation/FirmwarePCSimulator/ && python3 main.py


### Troubleshooting:
The simulation is a desktop application that runs in Docker. Docker needs to be configured to display the simulation window. To test this, you can temporarily install some X11 applications and run them:

apt-get update && apt-get install -y x11-apps
xclock

If a small window with a clock is visible, it means everything is set up correctly.

Note: If using Windows, [MobaXterm](https://mobaxterm.mobatek.net/download-home-edition.html) (or another tool capable of displaying X11 windows) is required. The Visual Studio terminal will not work.

# Pytest

cd /workspace/build/ && cmake .. && make -j24

cd /workspace/Test/System
python3 -m venv /workspace/venv
pytest test_display.py -s --html=report.html


after:
cd /workspace/build/ && cmake .. && make -j24 && cd /workspace/Test/System && pytest test_display.py -s --html=report.html



cd /workspace/build/ && cmake .. && make -j24 && cd /workspace/Test/System && pytest test_pulse_counter.py -s --html=report.html





[Setup Manual](../Documentation/Manuals/SetupDockerContainers.md)
38 changes: 38 additions & 0 deletions Documentation/Manuals/SetupDockerContainers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Why?

For me, using Docker in embedded systems has a key advantage: it eliminates the need for a README filled with outdated commands for setting up the development environment. In reality, such lists are rarely kept up to date (I often forget to update them myself too!). Docker solves this problem by providing a structured list of everything you need to install to get your environment up and running. But it's more than just a list - it's code, meaning it can be verified, maintained, and reused easily.

## Prerequisites

* Install Docker. For Linux, this should be straightforward. For Windows, you need to install WSL first and set up a Linux image.

## Docker Image for Firmware Development

### Build the Image

In the main directory (HardwareDataLogger), run the following command to build the image:

```
docker-compose build dev
```

### Running the Docker Image

Start the Docker image:

```
docker-compose up -d --remove-orphans
```

Log into the Docker image:

```
docker-compose exec dev bash
```

When finished, shut down the Docker container:

```
docker-compose down --remove-orphans
```

50 changes: 50 additions & 0 deletions Documentation/Manuals/SetupFirmwareDevelopment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## Prerequisites

[Install Docker and log into the container.](./SetupDockerContainers.md)

## Run Unit Tests

```
cmake ..
make test
```

## Run Static Analysis

```
cd /workspace/build && \
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_STANDARD=17 .. && \
make static
```

## Run Code Coverage

```
cmake -DCMAKE_BUILD_TYPE=Debug .. && \
make -j23 && \
make test -j23 && \
make coverage
```

## Run Docs Coverage

```
cmake ..
make docs
```

## Run UML Generation

```
cmake ..
make uml
```

## Running "Include What You Use"

```
cd build
CC="clang-10" CXX="clang++-10" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use ../Software
```

Loading

0 comments on commit 700ad8f

Please sign in to comment.