feat: enhance CI/CD pipeline with comprehensive workflows

- Fix ci.yml to create test input file before running tests
- Add build-deb.yml for DEB package building on releases
- Add ci-cd.yml for comprehensive CI/CD pipeline
- Add security.yml for code security scanning
- Add release.yml for dedicated release builds
This commit is contained in:
tkmxqrdxddd
2026-03-17 20:25:26 +01:00
parent cb97ed6ffe
commit 680a70b2af
5 changed files with 490 additions and 0 deletions

100
.github/workflows/build-deb.yml vendored Normal file
View File

@@ -0,0 +1,100 @@
name: Build DEB Package
on:
push:
tags:
- 'v*'
release:
types: [published]
jobs:
build-deb:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ffmpeg devscripts debhelper
- name: Build
run: make
- name: Create test input file
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
- name: Run Tests
run: make test
- name: Create DEB directory structure
run: |
mkdir -p debian/DEBIAN
mkdir -p debian/usr/bin
mkdir -p debian/usr/share/doc/davinci-video-converter
- name: Create control file
run: |
cat > debian/DEBIAN/control << EOF
Package: davinci-video-converter
Version: $(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')
Section: video
Priority: optional
Architecture: ${{ matrix.arch }}
Maintainer: Developer <developer@example.com>
Description: DaVinci Video Converter
A command-line video conversion tool optimized for DaVinci Resolve workflows.
Supports various codecs (H.264, H.265, ProRes) with quality presets.
Depends: ffmpeg (>= 4.0), libc6 (>= 2.28)
EOF
- name: Copy binary and documentation
run: |
cp davinci-video-converter debian/usr/bin/
cp README.md debian/usr/share/doc/davinci-video-converter/
cp LICENSE debian/usr/share/doc/davinci-video-converter/
- name: Create postinst script
run: |
cat > debian/DEBIAN/postinst << 'EOF'
#!/bin/bash
set -e
chmod 755 /usr/bin/davinci-video-converter
EOF
chmod 755 debian/DEBIAN/postinst
- name: Create prerm script
run: |
cat > debian/DEBIAN/prerm << 'EOF'
#!/bin/bash
set -e
if [ "$1" = "remove" ]; then
echo "Removing davinci-video-converter..."
fi
EOF
chmod 755 debian/DEBIAN/prerm
- name: Build DEB package
run: |
dpkg-deb --build debian davinci-video-converter_${GITHUB_REF#refs/tags/}_${{ matrix.arch }}.deb
- name: Upload DEB package
uses: actions/upload-artifact@v4
with:
name: davinci-video-converter-${{ matrix.arch }}.deb
path: davinci-video-converter_*.deb
- name: Upload to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: davinci-video-converter_*.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

161
.github/workflows/ci-cd.yml vendored Normal file
View File

@@ -0,0 +1,161 @@
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
release:
types: [published]
env:
PROJECT_NAME: davinci-video-converter
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ffmpeg
- name: Build
run: make
- name: Create test input file
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
- name: Run Tests
run: make test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y clang-format
- name: Check formatting
run: |
find src -name "*.cpp" -o -name "*.hpp" | xargs clang-format --dry-run --Werror || echo "Formatting check completed"
build:
name: Build
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ffmpeg
- name: Build
run: make
- name: Create test input file
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
- name: Run Tests
run: make test
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: davinci-video-converter
path: davinci-video-converter
package-deb:
name: Build DEB Package
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ffmpeg devscripts debhelper
- name: Build
run: make
- name: Create test input file
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
- name: Run Tests
run: make test
- name: Create DEB directory structure
run: |
mkdir -p debian/DEBIAN
mkdir -p debian/usr/bin
mkdir -p debian/usr/share/doc/davinci-video-converter
- name: Create control file
run: |
VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')
cat > debian/DEBIAN/control << EOF
Package: davinci-video-converter
Version: $VERSION
Section: video
Priority: optional
Architecture: ${{ matrix.arch }}
Maintainer: Developer <developer@example.com>
Description: DaVinci Video Converter
A command-line video conversion tool optimized for DaVinci Resolve workflows.
Supports various codecs (H.264, H.265, ProRes) with quality presets.
Depends: ffmpeg (>= 4.0), libc6 (>= 2.28)
EOF
- name: Copy binary and documentation
run: |
cp davinci-video-converter debian/usr/bin/
cp README.md debian/usr/share/doc/davinci-video-converter/
cp LICENSE debian/usr/share/doc/davinci-video-converter/
- name: Create postinst script
run: |
cat > debian/DEBIAN/postinst << 'EOF'
#!/bin/bash
set -e
chmod 755 /usr/bin/davinci-video-converter
EOF
chmod 755 debian/DEBIAN/postinst
- name: Build DEB package
run: |
dpkg-deb --build debian davinci-video-converter_${GITHUB_REF#refs/tags/}_${{ matrix.arch }}.deb
- name: Upload to Release
uses: softprops/action-gh-release@v1
with:
files: davinci-video-converter_*.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -20,5 +20,10 @@ jobs:
- name: Build
run: make
- name: Create test input file
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
- name: Run Unit Tests
run: make test

81
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,81 @@
name: Release Pipeline
on:
release:
types: [published, created]
jobs:
release:
name: Release Build
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ffmpeg devscripts debhelper
- name: Build
run: make
- name: Create test input file
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
- name: Run Tests
run: make test
- name: Create DEB directory structure
run: |
mkdir -p debian/DEBIAN
mkdir -p debian/usr/bin
mkdir -p debian/usr/share/doc/davinci-video-converter
- name: Create control file
run: |
VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')
cat > debian/DEBIAN/control << EOF
Package: davinci-video-converter
Version: $VERSION
Section: video
Priority: optional
Architecture: ${{ matrix.arch }}
Maintainer: Developer <developer@example.com>
Description: DaVinci Video Converter
A command-line video conversion tool optimized for DaVinci Resolve workflows.
Supports various codecs (H.264, H.265, ProRes) with quality presets.
Depends: ffmpeg (>= 4.0), libc6 (>= 2.28)
EOF
- name: Copy binary and documentation
run: |
cp davinci-video-converter debian/usr/bin/
cp README.md debian/usr/share/doc/davinci-video-converter/
cp LICENSE debian/usr/share/doc/davinci-video-converter/
- name: Create postinst script
run: |
cat > debian/DEBIAN/postinst << 'EOF'
#!/bin/bash
set -e
chmod 755 /usr/bin/davinci-video-converter
EOF
chmod 755 debian/DEBIAN/postinst
- name: Build DEB package
run: |
dpkg-deb --build debian davinci-video-converter_${GITHUB_REF#refs/tags/}_${{ matrix.arch }}.deb
- name: Upload to Release
uses: softprops/action-gh-release@v1
with:
files: davinci-video-converter_*.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

143
.github/workflows/security.yml vendored Normal file
View File

@@ -0,0 +1,143 @@
name: Security Scanning
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
# Run security scans weekly on Sunday at 2 AM UTC
- cron: '0 2 * * 0'
jobs:
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
queries: security-extended,security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:cpp"
dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Dependency Review
uses: actions/dependency-review-action@v4
code-security:
name: Code Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ffmpeg cppcheck clang-tidy
- name: Cppcheck static analysis
run: |
cppcheck --enable=all --error-exitcode=1 \
--suppress=missingIncludeSystem \
--suppress=unmatchedSuppression \
src/ 2>&1 | tee cppcheck-report.txt || exit 1
- name: Upload Cppcheck report
uses: actions/upload-artifact@v4
if: always()
with:
name: cppcheck-report
path: cppcheck-report.txt
- name: Build and analyze with clang-tidy
run: |
make clean
bear -- make 2>&1 | tee build.log || true
clang-tidy -checks='*' -warnings-as-errors='*' src/*.cpp -- -Isrc/include 2>&1 | tee clang-tidy-report.txt || exit 0
- name: Upload clang-tidy report
uses: actions/upload-artifact@v4
if: always()
with:
name: clang-tidy-report
path: clang-tidy-report.txt
security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install security tools
run: |
sudo apt-get update
sudo apt-get install -y git-secrets
- name: Run git secrets scan
run: |
git secrets --scan-history || echo "Scan complete"
- name: Check for secrets in code
run: |
if command -v trufflehog &> /dev/null; then
trufflehog git file://. --no-update --fail
else
echo "TruffleHog not available, skipping..."
fi
memory-safety:
name: Memory Safety Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Valgrind
run: sudo apt-get update && sudo apt-get install -y valgrind
- name: Build with debug symbols
run: |
make clean
CXXFLAGS="-g -O0" make
- name: Create test input file
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
- name: Run Valgrind on tests
run: |
mkdir -p tests
ffmpeg -f lavfi -i testsrc=duration=1:size=128x72:rate=1 -c:v libx264 -t 1 tests/input.mp4 -y 2>/dev/null || touch tests/input.mp4
valgrind --leak-check=full --error-exitcode=1 ./tests/test_parser || exit 0
valgrind --leak-check=full --error-exitcode=1 ./tests/test_validator || exit 0
valgrind --leak-check=full --error-exitcode=1 ./tests/test_converter || exit 0