Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fcad6de
remove appvoyer
chillaq Nov 25, 2025
65c246a
Create pipeline dotnet-client
chillaq Nov 25, 2025
d91c75f
remove pipeline
chillaq Nov 25, 2025
d269d50
Create pipeline dotnet-client-repo
chillaq Nov 25, 2025
2d85c9a
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
fc9949e
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
4291917
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
375dfa1
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
14ba4dc
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
0341724
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
5fb81a9
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
1003a59
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
f1de19f
Update pipeline dotnet-client-repo
chillaq Nov 25, 2025
1ce5660
Create inputset dotnet-client
chillaq Nov 25, 2025
d0c8911
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
4964d55
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
f2045f0
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
86fef91
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
354b534
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
b9da369
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
f10301c
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
88c33ab
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
e725e5c
Update pipeline dotnet-client-repo
chillaq Nov 26, 2025
10a52a9
Update pipeline dotnet-client-repo
chillaq Nov 27, 2025
90e32cb
Update pipeline dotnet-client-repo
chillaq Nov 27, 2025
615e9d4
Update pipeline dotnet-client-repo
chillaq Nov 27, 2025
6b077ee
Update pipeline dotnet-client-repo
chillaq Nov 27, 2025
6f96919
Update pipeline dotnet-client-repo
chillaq Nov 27, 2025
252a949
Update pipeline dotnet-client-repo
chillaq Nov 27, 2025
11f5a96
Update pipeline dotnet-client-repo
chillaq Nov 27, 2025
deb5646
Update pipeline dotnet-client-repo
chillaq Dec 1, 2025
6324be0
Update pipeline dotnet-client-repo
chillaq Dec 1, 2025
a56684b
Merge pull request #305 from splitio/harness-pipeline
chillaq Dec 1, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
/Splitio.Redis/bin
/Splitio.Redis/obj
/src/Splitio/bin
/src/Splitio/obj
/src/Splitio/obj
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
inputSet:
name: dotnet-client
identifier: dotnetclient
orgIdentifier: PROD
projectIdentifier: Harness_Split
pipeline:
identifier: dotnetclientrepo
properties:
ci:
codebase:
build:
type: PR
spec:
number: <+trigger.prNumber>
319 changes: 319 additions & 0 deletions .harness/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
pipeline:
name: dotnet-client-repo
identifier: dotnetclientrepo
projectIdentifier: Harness_Split
orgIdentifier: PROD
tags: {}
properties:
ci:
codebase:
connectorRef: fmegithubharnessgitops
repoName: dotnet-client
build: <+input>
stages:
- stage:
name: Build and Test
identifier: Build_and_Test
description: ""
type: CI
spec:
cloneCodebase: true
caching:
enabled: true
override: true
platform:
os: Windows
arch: Amd64
runtime:
type: Cloud
spec:
size: flex
execution:
steps:
- step:
type: Run
name: Setup NET SDK
identifier: Setup_NET_SDK
spec:
shell: Powershell
command: |-
# Install .NET SDK (adjust version as needed)
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1"
.\dotnet-install.ps1 -Channel 9.0 -InstallDir "C:\dotnet"
$env:PATH = "C:\dotnet;$env:PATH"
dotnet --version
nuget install redis-64 -excludeversion -source http://www.nuget.org/api/v2/
Redis-64\tools\redis-server.exe --service-install
Redis-64\tools\redis-server.exe --service-start
- step:
type: Run
name: Restore Dependencies
identifier: Restore_Dependencies
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet restore
- step:
type: Run
name: Install SonarQube
identifier: Install_SonarQube
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet tool install --tool-path c:\dotnet -v diag dotnet-sonarscanner
dotnet tool list -g
- step:
type: Run
name: SonarQube Begin Analysis
identifier: SonarQube_Begin_Analysis
spec:
shell: Powershell
command: |-
ls C:\dotnet
$env:PATH = "C:\dotnet;C:\dotnet\tools;$env:PATH"
dotnet-sonarscanner begin `
/k:"dotnet-client" `
/d:sonar.host.url="https://sonar.harness.io/" `
/d:sonar.token="<+secrets.getValue("sonarqube-token")>" `
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" `
/d:sonar.coverage.exclusions="**/*Tests*/**,**/bin/**,**/obj/**" `
/d:sonar.exclusions="**/bin/**,**/obj/**,**/*.dll,**/*.pdb" `
/d:sonar.sourceEncoding="UTF-8"
- step:
type: Run
name: Build
identifier: Build
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet build --configuration Release --no-restore
- step:
type: Run
name: Run tests with coverage
identifier: Run_tests_with_coverage
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet test .\tests\Splitio-tests\Splitio-tests.csproj `
-c Release `
-f net9.0 `
--no-build `
--collect:"XPlat Code Coverage" `
--results-directory:"./TestResults" `
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- step:
type: Run
name: SonarQube End Analysis
identifier: SonarQube_End_Analysis
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet sonarscanner end /d:sonar.token="<+secrets.getValue("sonarqube-token")>"
- step:
type: Run
name: Post Quality Gate
identifier: Post_Quality_Gate
spec:
shell: Powershell
command: |-
$scriptContent = @'
param(
[Parameter(Mandatory=$true)]
[string]$GitHubToken,

[Parameter(Mandatory=$true)]
[string]$GitHubRepo, # Format: "owner/repo"

[Parameter(Mandatory=$true)]
[string]$CommitSha,

[Parameter(Mandatory=$true)]
[string]$SonarProjectKey,

[Parameter(Mandatory=$true)]
[string]$SonarToken,

[Parameter(Mandatory=$true)]
[string]$SonarUrl # e.g., "https://sonarcloud.io" or your SonarQube server
)

# Function to get SonarQube quality gate status
function Get-SonarQualityGate {
param($ProjectKey, $Token, $ServerUrl)

$headers = @{
'Authorization' = "Bearer $Token"
'Content-Type' = 'application/json'
}

try {
# Get project status
$statusUrl = "$ServerUrl/api/qualitygates/project_status?projectKey=$ProjectKey"
$response = Invoke-RestMethod -Uri $statusUrl -Headers $headers -Method Get

return $response.projectStatus
}
catch {
Write-Error "Failed to get SonarQube quality gate status: $($_.Exception.Message)"
return $null
}
}

# Function to post status to GitHub
function Post-GitHubStatus {
param($Token, $Repo, $Sha, $State, $Description, $Context, $TargetUrl)

$headers = @{
'Authorization' = "token $Token"
'Accept' = 'application/vnd.github.v3+json'
'Content-Type' = 'application/json'
}

$body = @{
state = $State
description = $Description
context = $Context
target_url = $TargetUrl
} | ConvertTo-Json
Write-Host $Sha
$url = "https://api.github.com/repos/splitio/$Repo/statuses/$Sha"

try {
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Post -Body $body
Write-Host "✅ Successfully posted status to GitHub" -ForegroundColor Green
return $response
}
catch {
Write-Error "Failed to post status to GitHub: $($_.Exception.Message)"
return $null
}
}

# Main execution
Write-Host "🔍 Fetching SonarQube quality gate status..." -ForegroundColor Blue

$qualityGate = Get-SonarQualityGate -ProjectKey $SonarProjectKey -Token $SonarToken -ServerUrl $SonarUrl

if ($null -eq $qualityGate) {
Write-Error "Failed to retrieve quality gate status"
exit 1
}

# Determine GitHub status based on SonarQube quality gate
$githubState = switch ($qualityGate.status) {
"OK" { "success" }
"ERROR" { "failure" }
"WARN" { "success" } # You might want to change this to "failure" based on your requirements
default { "pending" }
}

$description = switch ($qualityGate.status) {
"OK" { "✅ Quality gate passed" }
"ERROR" { "❌ Quality gate failed" }
"WARN" { "⚠️ Quality gate passed with warnings" }
default { "🔄 Quality gate status unknown" }
}

# Add conditions details if available
if ($qualityGate.conditions) {
$failedConditions = $qualityGate.conditions | Where-Object { $_.status -eq "ERROR" }
if ($failedConditions.Count -gt 0) {
$description += " ($($failedConditions.Count) condition(s) failed)"
}
}

# Construct target URL
$targetUrl = "$SonarUrl/dashboard?id=$SonarProjectKey"

Write-Host "📊 Quality Gate Status: $($qualityGate.status)" -ForegroundColor Yellow
Write-Host "🎯 GitHub State: $githubState" -ForegroundColor Yellow
Write-Host "📝 Description: $description" -ForegroundColor Yellow

# Post status to GitHub
Write-Host "📤 Posting status to GitHub..." -ForegroundColor Blue

$result = Post-GitHubStatus -Token $GitHubToken -Repo $GitHubRepo -Sha $CommitSha -State $githubState -Description $description -Context "sonarqube/quality-gate" -TargetUrl $targetUrl

if ($null -eq $result) {
Write-Error "Failed to post status to GitHub"
exit 1
}

Write-Host "🎉 Successfully posted SonarQube quality gate status to GitHub!" -ForegroundColor Green

# Optional: Create detailed comment with quality gate details
if ($qualityGate.conditions) {
Write-Host "📋 Quality Gate Conditions:" -ForegroundColor Cyan
foreach ($condition in $qualityGate.conditions) {
$status = switch ($condition.status) {
"OK" { "✅" }
"ERROR" { "❌" }
"WARN" { "⚠️" }
default { "❓" }
}
Write-Host " $status $($condition.metricKey): $($condition.actualValue) (threshold: $($condition.errorThreshold))" -ForegroundColor White
}
}
'@
$scriptContent | Out-File -FilePath "sonar-github-status.ps1" -Encoding UTF8

.\sonar-github-status.ps1 `
-GitHubToken "<+secrets.getValue('github-devops-token')>" `
-GitHubRepo "dotnet-client" `
-CommitSha "<+codebase.commitSha>" `
-SonarProjectKey "dotnet-client" `
-SonarToken "<+secrets.getValue('sonarqube-token')>" `
-SonarUrl "https://sonar.harness.io/"
- step:
type: Run
name: Run Other Tests Net 9
identifier: Run_Other_Tests_Net_9
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet test .\tests\Splitio.Integration-tests\Splitio.Integration-tests.csproj -f net9.0 -c Release --no-build
dotnet test .\tests\Splitio.Integration-events-tests\Splitio.Integration-events-tests.csproj -f net9.0 -c Release --no-build
dotnet test .\tests\Splitio.Integration-redis-tests\Splitio.Integration-redis-tests.csproj -f net9.0 -c Release --no-build
dotnet test .\tests\Splitio.TestSupport\Splitio.TestSupport.csproj -c Release -f net9.0 --no-build
- step:
type: Run
name: Run unit tests Net 472
identifier: Run_unit_tests_Net_8
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet test .\tests\Splitio.Integration-tests\Splitio.Integration-tests.csproj -f net472 -c Release --no-build
dotnet test .\tests\Splitio.Integration-events-tests\Splitio.Integration-events-tests.csproj -f net472 -c Release --no-build
dotnet test .\tests\Splitio.Integration-redis-tests\Splitio.Integration-redis-tests.csproj -f net472 -c Release --no-build
dotnet test .\tests\Splitio.TestSupport\Splitio.TestSupport.csproj -c Release -f net472 --no-build
dotnet test .\tests\Splitio-tests\Splitio-tests.csproj -f net472 -c Release --no-build
contextType: Pipeline
- step:
type: Run
name: Create Nuget
identifier: Create_Nuget
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
if (!(Test-Path ".\nuget")) { mkdir .\nuget }
dotnet pack .\src\Splitio --configuration Release --output .\nuget
dotnet pack .\Splitio.Redis --configuration Release --output .\nuget
- step:
type: Run
name: Upload Nuget
identifier: Upload_Nuget
spec:
shell: Powershell
command: |-
$env:PATH = "C:\dotnet;$env:PATH"
dotnet nuget push '.\nuget\*.nupkg' -k $Env:API_KEY -s 'https://harness0.harness.io/pkg/l7B_kbSEQD2wjrM7PShm5w/fme-nuget/nuget/'
envVariables:
API_KEY: <+secrets.getValue("harness-ci-nuget-token")>
43 changes: 0 additions & 43 deletions appveyor.yml

This file was deleted.

Loading