Skip to content

Commit

Permalink
use docker
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGawron committed Dec 11, 2024
1 parent 043a20c commit daaedf6
Show file tree
Hide file tree
Showing 18 changed files with 291 additions and 151 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/build-firmware.yml

This file was deleted.

156 changes: 156 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: CI Pipeline

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
run-c-static-analysis:
name: Run C Static Analysis
runs-on: ubuntu-latest
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: Build and Start Docker Compose
run: |
docker-compose up -d --build
- name: Run C Static Analysis
run: |
docker-compose exec -T app bash -c "dos2unix /workspace/ContinuousIntegration/run_c_static_code_analysis.sh && bash /workspace/ContinuousIntegration/run_c_static_code_analysis.sh"
- name: Copy C Analysis Reports to Host
run: |
docker cp app:/workspace/build/C_Lint_ReportApplicationOnly.txt .
docker cp app:/workspace/build/C_Lint_ReportFull.txt .
- name: Archive C Analysis Reports
uses: actions/upload-artifact@v3
with:
name: c-lint-reports
path: |
C_Lint_ReportApplicationOnly.txt
C_Lint_ReportFull.txt
- name: Clean Up Containers
run: |
docker-compose down
run-python-static-analysis:
name: Run Python Static Analysis
runs-on: ubuntu-latest
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: Build and Start Docker Compose
run: |
docker-compose up -d --build
- name: Run Python Static Analysis
run: |
docker-compose exec -T app bash -c "dos2unix /workspace/ContinuousIntegration/run_python_static_code_analysis.sh && bash /workspace/ContinuousIntegration/run_python_static_code_analysis.sh"
- name: Copy Python Analysis Reports to Host
run: |
docker cp app:/workspace/build/python_lint_report ./python_lint_report
- name: Archive Python Analysis Reports
uses: actions/upload-artifact@v3
with:
name: python-lint-reports
path: python_lint_report

- name: Clean Up Containers
run: |
docker-compose down
run-shell-static-analysis:
name: Run Shell Static Analysis
runs-on: ubuntu-latest
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: Build and Start Docker Compose
run: |
docker-compose up -d --build
- name: Run Shell Static Analysis
run: |
docker-compose exec -T app bash -c "dos2unix /workspace/ContinuousIntegration/run_shellscripts_static_code_analysis.sh && bash /workspace/ContinuousIntegration/run_shellscripts_static_code_analysis.sh"
- name: Copy Shell Analysis Report to Host
run: |
docker cp app:/workspace/build/Shell_Script_Lint_Report.txt Shell_Script_Lint_Report.txt
- name: Archive Shell Analysis Report
uses: actions/upload-artifact@v3
with:
name: shell-lint-report
path: Shell_Script_Lint_Report.txt

- name: Clean Up Containers
run: |
docker-compose down
build-firmware:
name: Build Firmware
runs-on: ubuntu-latest
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: Build and Start Docker Compose
run: |
docker-compose up -d --build
- name: Build Firmware
run: |
docker-compose exec -T app bash -c "cd /workspace/build && cmake ../Software/Firmware/ && make -j$(nproc)"
- name: Copy Firmware Files to Host
run: |
docker cp app:/workspace/build/IonizationChamber.cdb .
docker cp app:/workspace/build/IonizationChamber.lk .
docker cp app:/workspace/build/IonizationChamber.ihx .
docker cp app:/workspace/build/IonizationChamber.map .
- name: Archive Firmware Build Artifacts
uses: actions/upload-artifact@v3
with:
name: firmware-build-artifacts
path: |
IonizationChamber.cdb
IonizationChamber.lk
IonizationChamber.ihx
IonizationChamber.map
- name: Clean Up Containers
run: |
docker-compose down
26 changes: 0 additions & 26 deletions .github/workflows/docs-generation.yml

This file was deleted.

60 changes: 0 additions & 60 deletions .github/workflows/static-code-analysis.yml

This file was deleted.

3 changes: 0 additions & 3 deletions ContinuousIntegration/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions ContinuousIntegration/run_generate_docs.sh

This file was deleted.

3 changes: 0 additions & 3 deletions ContinuousIntegration/run_python_static_code_analysis.sh

This file was deleted.

This file was deleted.

File renamed without changes.
3 changes: 3 additions & 0 deletions DevOps/ContinuousIntegration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ContinuousIntegration

This folder contains scripts used by GitHub Continuous Integration. It is recommended to run these scripts locally before submitting a pull request.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# shellcheck disable=SC1091
source /workspace/venv/bin/activate

flake8 --format=html --htmldir=python_lint_report /workspace/Software/DataAcquisition/ /workspace/Simulation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

shellcheck /workspace/ContinuousIntegration/*.sh | tee Shell_Script_Lint_Report.txt
64 changes: 64 additions & 0 deletions DevOps/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Use an official Ubuntu as a base image
FROM ubuntu:20.04 AS build

# Set environment variables to prevent interaction during installation
ENV DEBIAN_FRONTEND=noninteractive

# Install git, build tools, and dependencies
RUN apt-get update && apt-get install -y \
git \
build-essential \
cmake \
pkg-config \
libusb-1.0-0-dev \
&& rm -rf /var/lib/apt/lists/*

# Install stm8flash
RUN git clone https://github.com/vdudouyt/stm8flash.git
RUN cd stm8flash && make -j$(nproc)

# Use another Ubuntu image for runtime
FROM ubuntu:20.04 AS runtime

# Set environment variables to prevent interaction during installation
ENV DEBIAN_FRONTEND=noninteractive

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libusb-1.0-0 \
sdcc \
build-essential \
cmake \
git \
make \
pkg-config \
libusb-1.0-0-dev \
screen \
doxygen \
uncrustify \
python3-pip \
poppler-utils \
cppcheck \
r-base-core \
shellcheck \
dos2unix \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y \
python3-venv \
&& rm -rf /var/lib/apt/lists/*

# Copy the stm8flash binary from the build stage
COPY --from=build /stm8flash/stm8flash /usr/bin/

# Install flake8 in a Python virtual environment
RUN python3 -m venv /workspace/venv && \
/workspace/venv/bin/pip install --upgrade pip && \
/workspace/venv/bin/pip install flake8 flake8-html pyserial

# Create workspace directory and set it as the working directory
RUN mkdir -p /workspace/build
WORKDIR /workspace/build

# Command to run the container
CMD ["bash"]
Loading

0 comments on commit daaedf6

Please sign in to comment.