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/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index f51e2c7..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,7 +0,0 @@ -# React SDK - -## What did you accomplish? - -## How do we test the changes introduced in this PR? - -## Extra Notes diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml deleted file mode 100644 index 6fc6399..0000000 --- a/.github/workflows/ci-cd.yml +++ /dev/null @@ -1,135 +0,0 @@ -name: ci - -on: - push: - branches: - - '**' - pull_request: - branches: - - main - - development - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true - -permissions: - contents: read - id-token: write - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: Set up Node.js - uses: actions/setup-node@v6 - with: - node-version: 'lts/*' - cache: 'npm' - - - name: npm ci - run: npm ci - - - name: npm check - run: npm run check - - - name: npm test - run: npm run test - - - name: npm build - run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build - - - name: Set VERSION env - run: echo "VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV - - - name: Store assets - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development') - uses: actions/upload-artifact@v5 - with: - name: assets - path: umd/ - retention-days: 1 - - upload-stage: - name: Upload assets - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'push' && github.ref == 'refs/heads/development' - strategy: - matrix: - environment: - - stage - include: - - environment: stage - account_id: "079419646996" - bucket: split-public-stage - - steps: - - name: Download assets - uses: actions/download-artifact@v6 - with: - name: assets - path: umd - - - name: Display structure of assets - run: ls -R - working-directory: umd - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ matrix.account_id }}:role/gha-public-assets-role - aws-region: us-east-1 - - - name: Upload to S3 - run: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS - env: - BUCKET: ${{ matrix.bucket }} - SOURCE_DIR: ./umd - DEST_DIR: sdk - ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public - - upload-prod: - name: Upload assets - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - strategy: - matrix: - environment: - - prod - include: - - environment: prod - account_id: "825951051969" - bucket: split-public - - steps: - - name: Download assets - uses: actions/download-artifact@v6 - with: - name: assets - path: umd - - - name: Display structure of assets - run: ls -R - working-directory: umd - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ matrix.account_id }}:role/gha-public-assets-role - aws-region: us-east-1 - - - name: Upload to S3 - run: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS - env: - BUCKET: ${{ matrix.bucket }} - SOURCE_DIR: ./umd - DEST_DIR: sdk - ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public diff --git a/.github/workflows/update-notice-year.yml b/.github/workflows/update-notice-year.yml deleted file mode 100644 index 7043f6f..0000000 --- a/.github/workflows/update-notice-year.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Update Notice 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 NOTICE - uses: jacobtomlinson/gha-find-replace@v3 - with: - find: ${{ env.PREVIOUS }} - replace: ${{ env.CURRENT }} - include: "NOTICE" - 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 Notice Year" -a - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - title: Update Notice Year - branch: update-notice diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient.yaml new file mode 100644 index 0000000..cd5d5ca --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient.yaml @@ -0,0 +1,186 @@ +pipeline: + name: react-client-repo + identifier: reactclient + projectIdentifier: Harness_Split + orgIdentifier: PROD + tags: {} + properties: + ci: + codebase: + connectorRef: fmegithubharnessgitops + repoName: react-client + build: <+input> + stages: + - stage: + name: Check-Test-Build-Upload + identifier: Check_Test_Build_Upload + description: "" + type: CI + spec: + cloneCodebase: true + caching: + enabled: true + override: true + paths: [] + buildIntelligence: + enabled: false + execution: + steps: + - step: + type: Run + name: npm ci + identifier: npm_ci + spec: + connectorRef: dockerhub + image: node:lts + shell: Bash + command: npm ci + - step: + type: Run + name: npm run check + identifier: npm_run_check + spec: + connectorRef: dockerhub + image: node:lts + shell: Bash + command: npm run check + - step: + type: Run + name: npm run test + identifier: npm_run_test + spec: + connectorRef: dockerhub + image: node:lts + shell: Bash + command: npm run test -- --maxWorkers=2 + resources: + limits: + memory: 4Gi + cpu: "2" + - step: + type: Run + name: npm run build + identifier: npm_run_build + spec: + connectorRef: dockerhub + image: node:lts + shell: Bash + command: BUILD_BRANCH=<+codebase.branch> npm run build + - step: + type: Run + name: SonarQube Scan + identifier: SonarQube_Scan + spec: + connectorRef: dockerhub + image: sonarsource/sonar-scanner-cli + shell: Bash + command: | + set -euo pipefail + + COMMON_ARGS=" + -Dsonar.host.url=https://sonar.harness.io + -Dsonar.token=$SONAR_TOKEN + -Dsonar.projectKey=react-client + -Dsonar.sources=src + -Dsonar.tests=src/__tests__ + -Dsonar.exclusions=**/node_modules/**,**/umd/**,**/es/**,**/lib/**,src/__tests__/** + -Dsonar.scanner.skipJreProvisioning=true + -Dsonar.scanner.skipSystemTruststore=true + " + + if [ "<+codebase.prNumber>" != "" ] && [ "<+codebase.prNumber>" != "null" ]; then + echo "Pull Request Analysis" + sonar-scanner \ + $COMMON_ARGS \ + -Dsonar.pullrequest.key=<+codebase.prNumber> \ + -Dsonar.pullrequest.branch=<+codebase.sourceBranch> \ + -Dsonar.pullrequest.base=<+codebase.targetBranch> + else + echo "Branch Analysis" + sonar-scanner \ + $COMMON_ARGS \ + -Dsonar.branch.name=<+codebase.branch> + fi + envVariables: + SONAR_TOKEN: <+secrets.getValue("sonarqube-token")> + timeout: 10m + - step: + type: Run + name: Post Quality Gate + identifier: Post_Quality_Gate + spec: + connectorRef: dockerhub + image: python:3 + shell: Bash + command: |- + #!/bin/bash + set -e + + SONAR_TOKEN="<+secrets.getValue("sonarqube-token")>" + SONAR_URL="https://sonar.harness.io" + SONAR_PROJECT_KEY="react-client" + GITHUB_TOKEN="<+secrets.getValue("github-devops-token")>" + GITHUB_REPO="react-client" + COMMIT_SHA="<+codebase.commitSha>" + + STATUS_JSON=$(curl -sf \ + -H "Authorization: Bearer ${SONAR_TOKEN}" \ + "${SONAR_URL}/api/qualitygates/project_status?projectKey=${SONAR_PROJECT_KEY}") + + QG_STATUS=$(echo "$STATUS_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['projectStatus']['status'])") + + case "$QG_STATUS" in + OK) GH_STATE="success"; DESCRIPTION="Quality gate passed" ;; + ERROR) GH_STATE="failure"; DESCRIPTION="Quality gate failed" ;; + WARN) GH_STATE="success"; DESCRIPTION="Quality gate passed with warnings" ;; + *) GH_STATE="pending"; DESCRIPTION="Quality gate status unknown" ;; + esac + + TARGET_URL="${SONAR_URL}/dashboard?id=${SONAR_PROJECT_KEY}" + + curl -sf -X POST \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Content-Type: application/json" \ + -d "{\"state\":\"${GH_STATE}\",\"description\":\"${DESCRIPTION}\",\"context\":\"sonarqube/quality-gate\",\"target_url\":\"${TARGET_URL}\"}" \ + "https://api.github.com/repos/splitio/${GITHUB_REPO}/statuses/${COMMIT_SHA}" + + echo "Posted SonarQube quality gate status: ${GH_STATE}" + - parallel: + - step: + type: Run + name: upload dev assets to CDN + identifier: upload_dev_assets_to_CDN + spec: + connectorRef: dockerhub + image: amazon/aws-cli:2.31.5 + shell: Bash + command: aws s3 sync ./umd s3://split-public-stage/sdk --acl public-read --follow-symlinks --cache-control max-age=31536000,public + envVariables: + AWS_DEFAULT_REGION: us-east-1 + when: + stageStatus: Success + condition: <+trigger.event> == "PUSH" && <+trigger.branch> == "development" + - step: + type: Run + name: upload prod assets to CDN + identifier: upload_prod_assets_to_CDN + spec: + connectorRef: dockerhub + image: amazon/aws-cli:2.31.5 + shell: Bash + command: aws s3 sync ./umd s3://split-public/sdk --acl public-read --follow-symlinks --cache-control max-age=31536000,public + envVariables: + AWS_DEFAULT_REGION: us-east-1 + when: + stageStatus: Success + condition: <+trigger.event> == "PUSH" && <+trigger.branch> == "main" + infrastructure: + type: KubernetesDirect + spec: + connectorRef: "<+codebase.branch == \"main\" ? \"use1prod1cd\" : \"use1stage1cd\">" + namespace: harness-delegate + serviceAccountName: "<+codebase.branch == \"main\" ? \"use1-prod-1-public-assets\" : \"use1-stage-1-public-assets\">" + automountServiceAccountToken: false + nodeSelector: {} + os: Linux diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient/input_sets/reactclient_push.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient/input_sets/reactclient_push.yaml new file mode 100644 index 0000000..d768ae6 --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient/input_sets/reactclient_push.yaml @@ -0,0 +1,14 @@ +inputSet: + name: reactclient_push + identifier: reactclient_push + orgIdentifier: PROD + projectIdentifier: Harness_Split + pipeline: + identifier: reactclient + properties: + ci: + codebase: + build: + type: branch + spec: + branch: <+trigger.branch> diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient/input_sets/reactclientinputset.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient/input_sets/reactclientinputset.yaml new file mode 100644 index 0000000..34a0290 --- /dev/null +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/reactclient/input_sets/reactclientinputset.yaml @@ -0,0 +1,14 @@ +inputSet: + name: reactclientinputset + identifier: reactclientinputset + orgIdentifier: PROD + projectIdentifier: Harness_Split + pipeline: + identifier: reactclient + properties: + ci: + codebase: + build: + type: PR + spec: + number: <+trigger.prNumber>