Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PointerAlignment: Left
# 8. Namespace Indentation
# Google Style default is false, matching:
# Uncrustify: indent_namespace=false
IndentNamespace: false
NamespaceIndentation: None

# 9. Case Label Indentation
# Google Style default is to indent `case` labels.
Expand All @@ -59,6 +59,5 @@ AlignOperands: Align
# These are generally handled by Google's requirement for braces, even for single statements.
AllowShortBlocksOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
...
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
Expand Down
311 changes: 166 additions & 145 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,145 +1,166 @@
name: Build, Lint & Coverage

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
BUILD_TYPE: Release

jobs:
# Linting job with MegaLinter
megalinter:
name: MegaLinter
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0

- name: MegaLinter
uses: oxsecurity/megalinter/flavors/c_cpp@v10.1.0
env:
VALIDATE_ALL_CODEBASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable specific linters
DISABLE_LINTERS: SPELL_CSPELL
# Fail on errors (set to false if you want warnings only)
DISABLE_ERRORS: false

- name: Archive MegaLinter reports
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: megalinter-reports
path: |
megalinter-reports
mega-linter.log

# Build, test and coverage job
build-and-test:
name: Build, Test & Coverage
runs-on: ubuntu-latest
needs: megalinter
if: success() || failure()

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libcap-dev \
lcov \
cpputest

- name: Set up Python for gcovr
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
with:
python-version: '3.11'

- name: Install gcovr
run: pip install gcovr

- name: Configure CMake
run: |
cmake -S ${{github.workspace}}/source \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DOpENer_PLATFORM:STRING="POSIX" \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DOpENer_TRACES:BOOL=OFF \
-DOpENer_TESTS:BOOL=ON \
-DCPPUTEST_HOME:PATH=/usr

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure

- name: Generate coverage reports
run: |
# Generate HTML report for human viewing
gcovr --html-details --output coverage-report.html

# Generate Cobertura XML for tools/badges
gcovr --cobertura --output coverage.xml

# Generate text summary for console
gcovr --print-summary > coverage-summary.txt

# Print summary to console
echo "Coverage Summary:"
cat coverage-summary.txt

- name: Upload coverage reports
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: coverage-report
path: |
coverage-report.html
coverage-report.*.html
coverage.xml
coverage-summary.txt

- name: Create coverage summary comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
const summary = fs.readFileSync('coverage-summary.txt', 'utf8');
const comment = `## 📊 Coverage Report\n\n\`\`\`\n${summary}\n\`\`\`\n\nDownload the [detailed HTML report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) from the artifacts.`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});

- name: Generate coverage badge
if: github.ref == 'refs/heads/master'
run: |
# Extract coverage percentage
COVERAGE=$(gcovr --print-summary | grep 'lines:' | awk '{print $2}')
echo "COVERAGE_PERCENTAGE=$COVERAGE" >> $GITHUB_ENV
echo "Coverage: $COVERAGE"

- name: Upload build artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: build-artifacts
path: ${{github.workspace}}/build
---
name: Build, Lint & Coverage

on: # yamllint disable-line rule:truthy
push:
branches: ["master"]
pull_request:
branches: ["master"]

env:
BUILD_TYPE: Release

jobs:
# Linting job with MegaLinter
megalinter:
name: MegaLinter
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
persist-credentials: false

- name: MegaLinter
uses: oxsecurity/megalinter/flavors/c_cpp@f2fe8c1cba37091848df3e524066c8c23ef353ed
env:
VALIDATE_ALL_CODEBASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Disable specific linters
DISABLE_LINTERS: SPELL_CSPELL
# Fail on errors (set to false if you want warnings only)
DISABLE_ERRORS: false

- name: Archive MegaLinter reports
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: megalinter-reports
path: |
megalinter-reports
mega-linter.log

# Build, test and coverage job
build-and-test:
name: Build, Test & Coverage
permissions:
contents: read
issues: write
runs-on: ubuntu-latest
needs: megalinter
if: success() || failure()

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
persist-credentials: false

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libcap-dev \
lcov \
cpputest

- name: Set up Python for gcovr
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
with:
python-version: "3.11"

- name: Install gcovr
run: pip install gcovr

- name: Configure CMake
run: |
cmake -S ${{github.workspace}}/source \
-B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DOpENer_PLATFORM:STRING="POSIX" \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DOpENer_TRACES:BOOL=OFF \
-DOpENer_TESTS:BOOL=ON \
-DCPPUTEST_HOME:PATH=/usr

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure

- name: Generate coverage reports
run: |
# Generate HTML report for human viewing
gcovr --html-details --output coverage-report.html

# Generate Cobertura XML for tools/badges
gcovr --cobertura --output coverage.xml

# Generate text summary for console
gcovr --print-summary > coverage-summary.txt

# Print summary to console
echo "Coverage Summary:"
cat coverage-summary.txt

- name: Upload coverage reports
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: coverage-report
path: |
coverage-report.html
coverage-report.*.html
coverage.xml
coverage-summary.txt

- name: Create coverage summary comment
if: github.event_name == 'pull_request'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
with:
script: |
const fs = require('fs');
const summary = fs.readFileSync('coverage-summary.txt', 'utf8');
const runUrl = [
context.serverUrl,
context.repo.owner,
context.repo.repo,
'actions',
'runs',
context.runId,
].join('/');
const comment = [
'## 📊 Coverage Report\n\n',
'```\n',
summary,
'\n```\n\nDownload the [detailed HTML report](',
runUrl,
') from the artifacts.',
].join('');

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});

- name: Generate coverage badge
if: github.ref == 'refs/heads/master'
run: |
# Extract coverage percentage
COVERAGE=$(gcovr --print-summary | grep 'lines:' | awk '{print $2}')
echo "COVERAGE_PERCENTAGE=$COVERAGE" >> "$GITHUB_ENV"
echo "Coverage: $COVERAGE"

- name: Upload build artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: build-artifacts
path: ${{github.workspace}}/build
Loading