From a1723e2031c54cceaed096b9e29a8765a55450dc Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Tue, 28 Jul 2026 14:37:02 -0300 Subject: [PATCH 1/2] Added harness ci --- .../Harness_Split/pipelines/go_client_ci.yaml | 143 ++++++++++++++++++ .../input_sets/go_client_ci_pr.yaml | 14 ++ .../input_sets/go_client_ci_push.yaml | 14 ++ 3 files changed, 171 insertions(+) create mode 100644 .harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci.yaml create mode 100644 .harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci/input_sets/go_client_ci_pr.yaml create mode 100644 .harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci/input_sets/go_client_ci_push.yaml diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci.yaml new file mode 100644 index 0000000..ead27b7 --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci.yaml @@ -0,0 +1,143 @@ +pipeline: + name: go_client_ci + identifier: go_client_ci + projectIdentifier: Harness_Split + orgIdentifier: PROD + tags: {} + properties: + ci: + codebase: + connectorRef: fmegithubrunnersci + repoName: go-client + build: <+input> + sparseCheckout: [] + 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: run_tests + name: Run Tests + type: Run + spec: + connectorRef: dockerhub + image: golang:1.18 + shell: Bash + # Tests in splitio/client/ hardcode localhost:6379, mirroring the GHA + # `services: redis` behavior. On Harness Cloud a Background step runs as + # a separate container (unreachable at localhost), so we start redis-server + # inside this container instead — same technique as split_synchronizer_ci. + 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: Sh + 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" + + VERSION="$(grep 'Version =' splitio/version.go | awk '{print $4}' | tr -d '"')" + + 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" ] && [ "<+codebase.branch>" != "development" ]; then + SONAR_EXTRA_ARGS="-Dsonar.branch.name=<+codebase.branch>" + fi + + sonar-scanner \ + -Dsonar.host.url="https://sonar.harness.io/" \ + -Dsonar.token="${SONAR_TOKEN}" \ + -Dsonar.projectVersion="${VERSION}" \ + $SONAR_EXTRA_ARGS + envVariables: + SONAR_TOKEN: <+secrets.getValue("sonarqube-token")> + SONAR_HOST_URL: https://sonar.harness.io + - step: + identifier: post_quality_gate + name: Post Quality Gate + type: Run + spec: + connectorRef: dockerhub + image: golang:1.18 + shell: Sh + command: | + REPORT_FILE=".scannerwork/report-task.txt" + if [ ! -f "$REPORT_FILE" ]; then + echo "ERROR: $REPORT_FILE not found." + exit 1 + fi + cat "$REPORT_FILE" + 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 successfully: $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}") + echo "Quality Gate response: $QG_RESPONSE" + 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-client/statuses/<+codebase.commitSha>" \ + -d "{\"state\":\"${GH_STATE}\",\"description\":\"${DESC}\",\"context\":\"sonarqube/quality-gate\",\"target_url\":\"https://sonar.harness.io/dashboard?id=go-client\"}" + + echo "Posted GitHub status: $GH_STATE - $DESC" + 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_client_ci/input_sets/go_client_ci_pr.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci/input_sets/go_client_ci_pr.yaml new file mode 100644 index 0000000..0e7b349 --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci/input_sets/go_client_ci_pr.yaml @@ -0,0 +1,14 @@ +inputSet: + name: go_client_ci_pr + identifier: go_client_ci_pr + orgIdentifier: PROD + projectIdentifier: Harness_Split + pipeline: + identifier: go_client_ci + properties: + ci: + codebase: + build: + type: PR + spec: + number: <+trigger.prNumber> diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci/input_sets/go_client_ci_push.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci/input_sets/go_client_ci_push.yaml new file mode 100644 index 0000000..39b381e --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/go_client_ci/input_sets/go_client_ci_push.yaml @@ -0,0 +1,14 @@ +inputSet: + name: go_client_ci_push + identifier: go_client_ci_push + orgIdentifier: PROD + projectIdentifier: Harness_Split + pipeline: + identifier: go_client_ci + properties: + ci: + codebase: + build: + type: branch + spec: + branch: <+trigger.branch> From b7afee967604b731de7760cf476fb4254a3d5499 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Tue, 28 Jul 2026 15:21:31 -0300 Subject: [PATCH 2/2] Removed files --- .github/CODEOWNERS | 1 - .github/dependabot.yaml | 10 ---- .github/pull_request_template.md | 7 --- .github/workflows/ci.yml | 65 ----------------------- .github/workflows/update-license-year.yml | 45 ---------------- 5 files changed, 128 deletions(-) delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/dependabot.yaml delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/update-license-year.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 9e31981..0000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @splitio/sdk diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml deleted file mode 100644 index 075ff53..0000000 --- a/.github/dependabot.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -version: 2 - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - reviewers: - - "splitio/sdk" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 7c68ad9..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,7 +0,0 @@ -# GO SDK - -## What did you accomplish? - -## How do we test the changes introduced in this PR? - -## Extra Notes diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 1debdf9..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: ci -on: - push: - branches-ignore: - - none - pull_request: - branches: - - development - - main - -jobs: - test: - name: Run Tests - runs-on: ubuntu-latest - services: - redis: - image: redis - ports: - - 6379:6379 - steps: - - name: Checkout code - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: Set up Go version - uses: actions/setup-go@v6 - with: - go-version: '1.18.0' - - - name: Go mod - run: go mod tidy - - - name: Execute tests - run: go test -coverprofile=coverage.out -count=1 -race ./... - - - name: Set VERSION env - run: echo "VERSION=$(cat splitio/version.go | grep 'Version =' | awk '{print $4}' | tr -d '"')" >> $GITHUB_ENV - - - name: SonarQube Scan (Push) - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development') - uses: SonarSource/sonarqube-scan-action@v6 - env: - SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - projectBaseDir: . - args: > - -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} - -Dsonar.projectVersion=${{ env.VERSION }} - - - name: SonarQube Scan (Pull Request) - if: github.event_name == 'pull_request' - uses: SonarSource/sonarqube-scan-action@v6 - env: - SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - projectBaseDir: . - args: > - -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} - -Dsonar.projectVersion=${{ env.VERSION }} - -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} - -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} - -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} diff --git a/.github/workflows/update-license-year.yml b/.github/workflows/update-license-year.yml deleted file mode 100644 index 114c594..0000000 --- a/.github/workflows/update-license-year.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Update License Year - -on: - schedule: - - cron: "0 3 1 1 *" # 03:00 AM on January 1 - -permissions: - contents: write - pull-requests: write - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: Set Current year - run: "echo CURRENT=$(date +%Y) >> $GITHUB_ENV" - - - name: Set Previous Year - run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV" - - - name: Update LICENSE - uses: jacobtomlinson/gha-find-replace@v3 - with: - find: ${{ env.PREVIOUS }} - replace: ${{ env.CURRENT }} - include: "LICENSE.txt" - regex: false - - - name: Commit files - run: | - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - git commit -m "Updated License Year" -a - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 - with: - token: ${{ secrets.GITHUB_TOKEN }} - title: Update License Year - branch: update-license