From f4cbb744e036bacdb5234a2a3a725ed4838d5ba6 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Wed, 5 Aug 2026 17:27:34 -0300 Subject: [PATCH 1/3] Added harness ci --- .../pipelines/go_toolkit_ci.yaml | 136 ++++++++++++++++++ .../input_sets/go_toolkit_ci_pr.yaml | 14 ++ .../input_sets/go_toolkit_ci_push.yaml | 14 ++ sonar-project.properties | 6 + 4 files changed, 170 insertions(+) create mode 100644 .harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci.yaml create mode 100644 .harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_pr.yaml create mode 100644 .harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_push.yaml create mode 100644 sonar-project.properties diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci.yaml new file mode 100644 index 0000000..711fe4f --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci.yaml @@ -0,0 +1,136 @@ +pipeline: + name: go_toolkit_ci + identifier: go_toolkit_ci + projectIdentifier: Harness_Split + orgIdentifier: PROD + tags: {} + properties: + ci: + codebase: + connectorRef: fmegithubrunnersci + repoName: go-toolkit + build: <+input> + depth: 0 + stages: + - stage: + name: CI + identifier: CI + type: CI + spec: + cloneCodebase: true + caching: + enabled: true + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: + size: flex + execution: + steps: + - step: + identifier: test + name: Run Tests + type: Run + spec: + connectorRef: dockerhub + image: golang:1.18 + shell: Bash + # Tests connect to localhost:6379. Harness Cloud Background steps run + # in a separate container (not localhost). Run redis-server inside this + # container so tests share the real localhost — matches GHA `services:`. + command: |- + apt-get update -qq && apt-get install -y -qq --no-install-recommends redis-server + redis-server --daemonize yes + for i in $(seq 1 30); do + redis-cli ping 2>/dev/null | grep -q PONG && { echo "Redis is up"; break; } + echo "Waiting for Redis... ($i/30)"; sleep 1 + done + go mod tidy + go test -coverprofile=coverage.out -count=1 -race ./... + - step: + identifier: sonarqube_analysis + name: SonarQube Analysis + type: Run + spec: + connectorRef: dockerhub + image: golang:1.18 + shell: Bash + command: |- + apt-get update -qq && apt-get install -y -qq --no-install-recommends unzip + export SONAR_SCANNER_VERSION=6.2.1.4610 + curl -sSLo sonar-scanner.zip "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux-x64.zip" + unzip -q sonar-scanner.zip + export PATH="$(pwd)/sonar-scanner-${SONAR_SCANNER_VERSION}-linux-x64/bin:$PATH" + + SONAR_EXTRA_ARGS="" + if [ "<+codebase.build.type>" = "PR" ]; then + SONAR_EXTRA_ARGS="-Dsonar.pullrequest.key=<+codebase.prNumber> \ + -Dsonar.pullrequest.branch=<+codebase.sourceBranch> \ + -Dsonar.pullrequest.base=<+codebase.targetBranch>" + elif [ "<+codebase.branch>" != "main" ]; then + SONAR_EXTRA_ARGS="-Dsonar.branch.name=<+codebase.branch>" + fi + + sonar-scanner \ + -Dsonar.host.url="https://sonar.harness.io/" \ + -Dsonar.token="${SONAR_TOKEN}" \ + -Dsonar.projectName=go-toolkit \ + -Dsonar.projectKey=go-toolkit \ + -Dsonar.exclusions='**/*_test.go,**/vendor/**,**/testdata/*' \ + -Dsonar.go.coverage.reportPaths=coverage.out \ + -Dsonar.links.ci="https://github.com/splitio/go-toolkit/actions" \ + -Dsonar.links.scm="https://github.com/splitio/go-toolkit" \ + ${SONAR_EXTRA_ARGS} + envVariables: + SONAR_TOKEN: <+secrets.getValue("sonarqube-token")> + - step: + identifier: post_quality_gate + name: Post Quality Gate + type: Run + spec: + connectorRef: dockerhub + image: golang:1.18 + shell: Bash + command: |- + REPORT_FILE=".scannerwork/report-task.txt" + if [ ! -f "$REPORT_FILE" ]; then + echo "ERROR: $REPORT_FILE not found." + exit 1 + fi + CE_TASK_URL=$(grep "ceTaskUrl" "$REPORT_FILE" | cut -d'=' -f2-) + + MAX_RETRIES=30; RETRY_INTERVAL=10; TASK_STATUS="PENDING" + for i in $(seq 1 $MAX_RETRIES); do + echo "Attempt $i/$MAX_RETRIES - checking analysis task..." + TASK_RESPONSE=$(curl -s -u "${SONAR_TOKEN}:" "$CE_TASK_URL") + TASK_STATUS=$(echo "$TASK_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['task']['status'])" 2>/dev/null || echo "UNKNOWN") + echo "Task status: $TASK_STATUS" + [ "$TASK_STATUS" = "SUCCESS" ] || [ "$TASK_STATUS" = "FAILED" ] || [ "$TASK_STATUS" = "CANCELLED" ] && break + sleep $RETRY_INTERVAL + done + if [ "$TASK_STATUS" != "SUCCESS" ]; then + echo "Analysis task did not complete: $TASK_STATUS"; exit 1 + fi + + ANALYSIS_ID=$(echo "$TASK_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['task']['analysisId'])") + QG_RESPONSE=$(curl -s -u "${SONAR_TOKEN}:" "https://sonar.harness.io/api/qualitygates/project_status?analysisId=${ANALYSIS_ID}") + QG_STATUS=$(echo "$QG_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin)['projectStatus']['status'])") + echo "Quality Gate Status: $QG_STATUS" + + case "$QG_STATUS" in + OK) GH_STATE="success"; DESC="Quality gate passed" ;; + ERROR) GH_STATE="failure"; DESC="Quality gate failed" ;; + WARN) GH_STATE="success"; DESC="Quality gate passed with warnings" ;; + *) GH_STATE="failure"; DESC="Quality gate status: $QG_STATUS" ;; + esac + + curl -s -X POST \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/splitio/go-toolkit/statuses/<+codebase.commitSha>" \ + -d "{\"state\":\"${GH_STATE}\",\"description\":\"${DESC}\",\"context\":\"sonarqube/quality-gate\",\"target_url\":\"https://sonar.harness.io/dashboard?id=go-toolkit\"}" + envVariables: + SONAR_TOKEN: <+secrets.getValue("sonarqube-token")> + GITHUB_TOKEN: <+secrets.getValue("fme-github-netrc-token")> diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_pr.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_pr.yaml new file mode 100644 index 0000000..1eb8122 --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_pr.yaml @@ -0,0 +1,14 @@ +inputSet: + name: go_toolkit_ci_pr + identifier: go_toolkit_ci_pr + orgIdentifier: PROD + projectIdentifier: Harness_Split + pipeline: + identifier: go_toolkit_ci + properties: + ci: + codebase: + build: + type: PR + spec: + number: <+trigger.prNumber> diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_push.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_push.yaml new file mode 100644 index 0000000..53e5a0a --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_toolkit_ci/input_sets/go_toolkit_ci_push.yaml @@ -0,0 +1,14 @@ +inputSet: + name: go_toolkit_ci_push + identifier: go_toolkit_ci_push + orgIdentifier: PROD + projectIdentifier: Harness_Split + pipeline: + identifier: go_toolkit_ci + properties: + ci: + codebase: + build: + type: branch + spec: + branch: <+trigger.branch> diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..9007290 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,6 @@ +sonar.projectKey=go-toolkit +sonar.projectName=go-toolkit +sonar.exclusions=**/*_test.go,**/vendor/**,**/testdata/* +sonar.go.coverage.reportPaths=coverage.out +sonar.links.ci=https://github.com/splitio/go-toolkit/actions +sonar.links.scm=https://github.com/splitio/go-toolkit From 8fc72d423c33e8c2abbaa75c0ba1c14641ef3d20 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 6 Aug 2026 11:59:52 -0300 Subject: [PATCH 2/3] chore: empty commit to test Harness CI triggers AI-Session-Id: 36550759-52cb-4898-b8d0-822823731f26 AI-Tool: claude-code AI-Model: unknown From 2aee9aac2ea2e4effc212054da8fe77d8eb9d706 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 6 Aug 2026 12:55:42 -0300 Subject: [PATCH 3/3] Updated sse tests --- sse/sse_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sse/sse_test.go b/sse/sse_test.go index df6f2b3..473039c 100644 --- a/sse/sse_test.go +++ b/sse/sse_test.go @@ -59,7 +59,7 @@ func TestSSE(t *testing.T) { fmt.Fprintf(w, "data: %s\n\n", `{"id":"YCh53QfLxO:0:0","data":"some","timestamp":1591911770828}`) flusher.Flush() - time.Sleep(2 * time.Second) + time.Sleep(5 * time.Second) })) defer ts.Close()