Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update with CI #2

Merged
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
45 changes: 34 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
name: Build
name: Build and Analyze

on:
push:
branches:
- main

- '**'
pull_request:
branches:
- '**'

jobs:
build:
name: Build and analyze
name: Build and analyze with SonarQube
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: sonarsource/sonarqube-scan-action@v3
fetch-depth: 0 # Ensure full history for analysis

# Step 2: Install dependencies
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake build-essential pkg-config \
libglfw3-dev libgl1-mesa-dev libx11-dev libgl-dev libglm-dev

# Step 3: Generate and build the project using CMake
- name: Configure and build project
run: |
mkdir -p build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

# Step 4: Run SonarQube analysis
- name: Run SonarQube scan
uses: sonarsource/sonarqube-scan-action@v3
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# If you wish to fail your job when the Quality Gate is red, uncomment the
# following lines. This would typically be used to fail a deployment.
# - uses: sonarsource/sonarqube-quality-gate-action@master

# Optional: Enforce quality gate
# Uncomment the following lines to fail the workflow if the Quality Gate is not met
# - name: Check SonarQube quality gate
# uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
16 changes: 15 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,19 @@ sonar.projectKey=voxels
sonar.projectName=Voxel Engine
sonar.projectVersion=1.0
sonar.projectKey=arozx_voxels_d0e4bd76-3798-45bc-a3e0-f1357e3eed04

# Source file configuration
sonar.sources=src
sonar.cfamily.compile-commands=build/compile_commands.json
sonar.language=c++
sonar.cxx.includeDirectories=src,external/glad/include
sonar.cxx.file.suffixes=cpp,c,h

# Exclude build directories
sonar.exclusions=build/**

# C++ specific configurations
sonar.cxx.defines=GLFW_INCLUDE_NONE
sonar.cxx.errorRecoveryEnabled=true

# Enable compilation database
sonar.cxx.compileCommands=build/compile_commands.json
Loading