From 364badf9588271848d579ad365c73e0755dfd18f Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Wed, 12 Feb 2025 14:30:15 +0545 Subject: [PATCH 01/95] feat: gitworkflow --- .github/workflows/gitleaks.yaml | 45 +++++++++++++++++ .github/workflows/lint.yaml | 90 +++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 .github/workflows/gitleaks.yaml create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml new file mode 100644 index 0000000..25526a9 --- /dev/null +++ b/.github/workflows/gitleaks.yaml @@ -0,0 +1,45 @@ +name: GitLeaks Scan + +on: + push: + branches: + - '**' # Run on all branches + pull_request: # Keep PR checks for good measure + workflow_dispatch: + +jobs: + gitleaks: + name: GitLeaks Security Scan + runs-on: ubuntu-latest + permissions: + security-events: write # Required for uploading SARIF results + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required for full history scan + + - name: Run GitLeaks + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + config-path: .gitleaks.toml # Optional: Custom config file + enable-upload-artifact: true + report-format: sarif + report-path: gitleaks-report.sarif + + - name: Upload SARIF report + if: always() # Upload even if GitLeaks finds issues + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: gitleaks-report.sarif + category: gitleaks + + - name: Handle GitLeaks findings + if: failure() + run: | + echo "::warning ::GitLeaks has detected potential secrets in your codebase." + echo "Please review the SARIF report in the Security tab." \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..59973fb --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,90 @@ +name: Multi-language Lint + +on: + push: + branches: [ main, master, develop ] + pull_request: + branches: [ main, master, develop ] + +jobs: + lint: + name: Lint All Languages + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # Go Setup and Linting + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Run Go Lint + run: | + go install golang.org/x/lint/golint@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + golint ./... + go vet ./... + staticcheck ./... + + # Node.js Setup (for TypeScript, JavaScript, and template linting) + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install Node.js dependencies + run: | + npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm install -g prettier prettier-plugin-smarty prettier-plugin-mustache + npm ci + + - name: Lint TypeScript + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + run: npx eslint "**/*.{js,jsx}" --fix + + - name: Lint Smarty Templates + run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty + + - name: Lint Mustache Templates + run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache + + # Python Setup and Linting + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint mypy + + - name: Lint Python + run: | + black . --check + flake8 . + isort . --check-only + pylint **/*.py || true + mypy . + + # Report results + - name: Upload lint results + if: always() + uses: actions/upload-artifact@v4 + with: + name: lint-results + path: | + **/lint-results.* + **/pylint-report.txt + **/eslint-report.json + retention-days: 14 \ No newline at end of file From 97dabc52dda88dbfb25fdafa8b0ffe8cd2766461 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Wed, 12 Feb 2025 14:32:22 +0545 Subject: [PATCH 02/95] feat: gitworkflow --- .github/workflows/lint.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 59973fb..f1f7ea0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,10 +1,11 @@ name: Multi-language Lint on: - push: - branches: [ main, master, develop ] - pull_request: - branches: [ main, master, develop ] + push: + branches: + - '**' # Run on all branches + pull_request: # Keep PR checks for good measure + workflow_dispatch: jobs: lint: From cad59c3ddca7755a9576bc73d4ec205ea0d7603c Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Wed, 12 Feb 2025 15:13:31 +0545 Subject: [PATCH 03/95] feat: gitworkflow --- .github/workflows/gitleaks.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index 25526a9..4eff98f 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -31,15 +31,15 @@ jobs: report-format: sarif report-path: gitleaks-report.sarif - - name: Upload SARIF report - if: always() # Upload even if GitLeaks finds issues - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: gitleaks-report.sarif - category: gitleaks + # - name: Upload SARIF report + # if: always() # Upload even if GitLeaks finds issues + # uses: github/codeql-action/upload-sarif@v3 + # with: + # sarif_file: gitleaks-report.sarif + # category: gitleaks - - name: Handle GitLeaks findings - if: failure() - run: | - echo "::warning ::GitLeaks has detected potential secrets in your codebase." - echo "Please review the SARIF report in the Security tab." \ No newline at end of file + # - name: Handle GitLeaks findings + # if: failure() + # run: | + # echo "::warning ::GitLeaks has detected potential secrets in your codebase." + # echo "Please review the SARIF report in the Security tab." \ No newline at end of file From 1d87b803a15b1f3a55d27d2f4a733af84252fc6c Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 13 Feb 2025 11:05:25 +0545 Subject: [PATCH 04/95] feat: gitworkflow --- .github/workflows/lint.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index f1f7ea0..c260d7e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -27,9 +27,9 @@ jobs: run: | go install golang.org/x/lint/golint@latest go install honnef.co/go/tools/cmd/staticcheck@latest - golint ./... - go vet ./... - staticcheck ./... + golint ./cluster-status/... + go vet ./cluster-status/... + staticcheck ./cluster-status/... # Node.js Setup (for TypeScript, JavaScript, and template linting) - name: Set up Node.js From 16dbf0b170c0854a03572e47bd84a522a69e8c1d Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 13 Feb 2025 11:09:45 +0545 Subject: [PATCH 05/95] feat: gitworkflow --- .github/workflows/lint.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c260d7e..9eda99b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -25,11 +25,12 @@ jobs: - name: Run Go Lint run: | + cd cluster-status go install golang.org/x/lint/golint@latest go install honnef.co/go/tools/cmd/staticcheck@latest - golint ./cluster-status/... - go vet ./cluster-status/... - staticcheck ./cluster-status/... + golint . + go vet . + staticcheck . # Node.js Setup (for TypeScript, JavaScript, and template linting) - name: Set up Node.js From 77d1c1e6059d944c49544da73797070ae9bf1942 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 13 Feb 2025 11:28:44 +0545 Subject: [PATCH 06/95] feat: gitworkflow --- cluster-status/main.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cluster-status/main.go b/cluster-status/main.go index a4312cf..9d58c35 100644 --- a/cluster-status/main.go +++ b/cluster-status/main.go @@ -23,12 +23,17 @@ import ( "k8s.io/klog" ) +// Controller manages the processing of pods in the Kubernetes cluster. +// It uses an indexer for caching, a workqueue for processing items, +// and an informer for receiving cluster events. type Controller struct { indexer cache.Indexer queue workqueue.RateLimitingInterface informer cache.Controller } +// NewController creates a new Controller instance with the provided queue, +// indexer and informer for managing pod events in the cluster. func NewController(queue workqueue.RateLimitingInterface, indexer cache.Indexer, informer cache.Controller) *Controller { return &Controller{ informer: informer, @@ -70,10 +75,6 @@ func (c *Controller) syncToStdout(key string) error { fmt.Printf("Pod %s does not exist anymore\n", key) } else { pod := obj.(*v1.Pod) - // Note that you also have to check the uid if you have a local controlled resource, which - // is dependent on the actual instance, to detect that a Pod was recreated with the same name - // fmt.Printf("Sync/Add/Update for Pod %s Status %v \n ", pod.GetName(), pod.Status.Phase) - // fmt.Printf("Sync/Add/Update for Pod %s Status %v Label {\"status-controller-vcluster\": \"cluster-manager\"}\n", pod.GetName(), pod.Status.Phase) if pod.Labels["status-controller-vcluster"] == "cluster-manager" { for key, value := range pod.ObjectMeta.Labels { if key == "status-controller" { @@ -85,12 +86,8 @@ func (c *Controller) syncToStdout(key string) error { if containerState.Waiting != nil { waitingReason := containerState.Waiting.Reason switch waitingReason { - case "ImagePullBackOff": - case "OOMKilled": - case "ContainerConfigError": - case "CrashLoopBackOff": + case "ImagePullBackOff", "OOMKilled", "ContainerConfigError", "CrashLoopBackOff": statusString = waitingReason - break default: statusString = "Pending" } @@ -107,12 +104,10 @@ func (c *Controller) syncToStdout(key string) error { } } } - } return nil } -// handleErr checks if an error happened and makes sure we will retry later. func (c *Controller) handleErr(err error, key interface{}) { if err == nil { // Forget about the #AddRateLimited history of the key on every successful synchronization. @@ -138,6 +133,8 @@ func (c *Controller) handleErr(err error, key interface{}) { klog.Infof("Dropping pod %q out of the queue: %v", key, err) } +// Run starts the controller with the specified number of workers and runs until stopped. +// It manages the worker routines and ensures proper shutdown. func (c *Controller) Run(threadiness int, stopCh chan struct{}) { defer runtime.HandleCrash() @@ -271,7 +268,7 @@ func patchClusterStatus(name, id, status string) error { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return fmt.Errorf("Request failed with status code: %d", resp.StatusCode) + return fmt.Errorf("request failed with status code: %d", resp.StatusCode) } logrus.Info("Request successful") return nil From a67cbf1870d31f622ac81666cea8c9dcfc0201c3 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 13 Feb 2025 11:39:55 +0545 Subject: [PATCH 07/95] feat: gitworkflow --- .github/workflows/lint.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9eda99b..cbc77c8 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,15 +22,20 @@ jobs: with: go-version: '1.22' cache: true - - - name: Run Go Lint + + - name: Install Go Linting Tools run: | - cd cluster-status go install golang.org/x/lint/golint@latest go install honnef.co/go/tools/cmd/staticcheck@latest - golint . - go vet . - staticcheck . + echo "$HOME/go/bin" >> $GITHUB_PATH # Ensure installed tools are available in PATH + + - name: Run Go Lint + run: | + cd cluster-status + golint ./... + go vet ./... + staticcheck ./... + # Node.js Setup (for TypeScript, JavaScript, and template linting) - name: Set up Node.js From d4dd14f6eb305adbaa44726da57e2e18b57c3c98 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 13 Feb 2025 11:50:29 +0545 Subject: [PATCH 08/95] feat: gitworkflow --- .github/workflows/lint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index cbc77c8..ab0d6d4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -43,8 +43,10 @@ jobs: with: node-version: '20' cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json - name: Install Node.js dependencies + working-directory: cluster-ui run: | npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm install -g prettier prettier-plugin-smarty prettier-plugin-mustache From 1772ad9fafcd8179e7253a3192694862872478a8 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 13 Feb 2025 11:56:50 +0545 Subject: [PATCH 09/95] feat: gitworkflow --- .github/workflows/lint.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index ab0d6d4..34a3a8f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -49,7 +49,6 @@ jobs: working-directory: cluster-ui run: | npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm install -g prettier prettier-plugin-smarty prettier-plugin-mustache npm ci - name: Lint TypeScript @@ -63,8 +62,8 @@ jobs: - name: Lint Smarty Templates run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty - - name: Lint Mustache Templates - run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache + # - name: Lint Mustache Templates + # run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache # Python Setup and Linting - name: Set up Python From 0af56d2716711a47fc8df95c218bee360492ea4e Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 11:35:26 +0545 Subject: [PATCH 10/95] feat: gitworkflow --- .github/workflows/lint.yaml | 77 +++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 34a3a8f..f3e3508 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -37,33 +37,33 @@ jobs: staticcheck ./... - # Node.js Setup (for TypeScript, JavaScript, and template linting) - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json - - - name: Install Node.js dependencies - working-directory: cluster-ui - run: | - npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci - - - name: Lint TypeScript - run: | - npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - - name: Lint JavaScript - run: npx eslint "**/*.{js,jsx}" --fix - - - name: Lint Smarty Templates - run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty - - # - name: Lint Mustache Templates - # run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache + # # Node.js Setup (for TypeScript, JavaScript, and template linting) + # - name: Set up Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: '20' + # cache: 'npm' + # cache-dependency-path: cluster-ui/package-lock.json + + # - name: Install Node.js dependencies + # working-directory: cluster-ui + # run: | + # npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + # npm ci + + # - name: Lint TypeScript + # run: | + # npx tsc --noEmit + # npx eslint "**/*.{ts,tsx}" --fix + + # - name: Lint JavaScript + # run: npx eslint "**/*.{js,jsx}" --fix + + # - name: Lint Smarty Templates + # run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty + + # # - name: Lint Mustache Templates + # # run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache # Python Setup and Linting - name: Set up Python @@ -73,6 +73,7 @@ jobs: cache: 'pip' - name: Install Python linting tools + working-directory: cluster-service run: | python -m pip install --upgrade pip pip install flake8 black isort pylint mypy @@ -85,14 +86,14 @@ jobs: pylint **/*.py || true mypy . - # Report results - - name: Upload lint results - if: always() - uses: actions/upload-artifact@v4 - with: - name: lint-results - path: | - **/lint-results.* - **/pylint-report.txt - **/eslint-report.json - retention-days: 14 \ No newline at end of file + # # Report results + # - name: Upload lint results + # if: always() + # uses: actions/upload-artifact@v4 + # with: + # name: lint-results + # path: | + # **/lint-results.* + # **/pylint-report.txt + # **/eslint-report.json + # retention-days: 14 \ No newline at end of file From e8b1b76e1fc16de34b6bf02bc8b3f200a9315f8b Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 11:40:32 +0545 Subject: [PATCH 11/95] feat: gitworkflow --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index f3e3508..74cb3ee 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -80,7 +80,7 @@ jobs: - name: Lint Python run: | - black . --check + black . flake8 . isort . --check-only pylint **/*.py || true From e521388bc893648f498a2f986a8561d2b8e9fa6a Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 11:57:10 +0545 Subject: [PATCH 12/95] feat: gitworkflow --- .github/workflows/lint.yaml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 74cb3ee..2c0acce 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -37,33 +37,33 @@ jobs: staticcheck ./... - # # Node.js Setup (for TypeScript, JavaScript, and template linting) - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: '20' - # cache: 'npm' - # cache-dependency-path: cluster-ui/package-lock.json + # Node.js Setup (for TypeScript, JavaScript, and template linting) + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json - # - name: Install Node.js dependencies - # working-directory: cluster-ui - # run: | - # npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - # npm ci + - name: Install Node.js dependencies + working-directory: cluster-ui + run: | + npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci # - name: Lint TypeScript # run: | # npx tsc --noEmit # npx eslint "**/*.{ts,tsx}" --fix - # - name: Lint JavaScript - # run: npx eslint "**/*.{js,jsx}" --fix + - name: Lint JavaScript + run: npx eslint "**/*.{js,jsx}" --fix - # - name: Lint Smarty Templates - # run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty + - name: Lint Smarty Templates + run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty - # # - name: Lint Mustache Templates - # # run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache + # - name: Lint Mustache Templates + # run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache # Python Setup and Linting - name: Set up Python From f70df47e74e25b12b24f48034d87f1db54f975d1 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 12:02:54 +0545 Subject: [PATCH 13/95] feat: gitworkflow --- cluster-ui/eslint.config.js | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cluster-ui/eslint.config.js diff --git a/cluster-ui/eslint.config.js b/cluster-ui/eslint.config.js new file mode 100644 index 0000000..6e33e0c --- /dev/null +++ b/cluster-ui/eslint.config.js @@ -0,0 +1,53 @@ +import js from "@eslint/js"; +import globals from "globals"; + +export default [ + js.configs.recommended, + { + languageOptions: { + ecmaVersion: 2022, + sourceType: "module", + globals: { + ...globals.browser, + ...globals.node, + ...globals.es2021 + }, + }, + rules: { + // Possible Problems + "no-duplicate-imports": "error", + "no-unused-vars": "warn", + "no-console": "warn", + + // Suggestions + "curly": ["error", "multi-line"], + "default-case": "warn", + "eqeqeq": ["error", "always"], + "no-eval": "error", + "no-var": "error", + "prefer-const": "warn", + + // Layout & Formatting + "array-bracket-spacing": ["error", "never"], + "block-spacing": "error", + "brace-style": ["error", "1tbs"], + "comma-dangle": ["error", "always-multiline"], + "comma-spacing": ["error", { "before": false, "after": true }], + "indent": ["error", 2], + "quotes": ["error", "single"], + "semi": ["error", "always"], + + // ES6 + "arrow-spacing": "error", + "no-const-assign": "error", + "prefer-template": "warn", + "template-curly-spacing": ["error", "never"] + }, + + env: { + browser: true, + node: true, + es2022: true + } + } +]; \ No newline at end of file From 194f5438430e4b4830c8fcc69dcacdca91c0f0b8 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:01:44 +0545 Subject: [PATCH 14/95] feat: gitworkflow --- cluster-ui/eslint.config.js | 53 ------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 cluster-ui/eslint.config.js diff --git a/cluster-ui/eslint.config.js b/cluster-ui/eslint.config.js deleted file mode 100644 index 6e33e0c..0000000 --- a/cluster-ui/eslint.config.js +++ /dev/null @@ -1,53 +0,0 @@ -import js from "@eslint/js"; -import globals from "globals"; - -export default [ - js.configs.recommended, - { - languageOptions: { - ecmaVersion: 2022, - sourceType: "module", - globals: { - ...globals.browser, - ...globals.node, - ...globals.es2021 - }, - }, - rules: { - // Possible Problems - "no-duplicate-imports": "error", - "no-unused-vars": "warn", - "no-console": "warn", - - // Suggestions - "curly": ["error", "multi-line"], - "default-case": "warn", - "eqeqeq": ["error", "always"], - "no-eval": "error", - "no-var": "error", - "prefer-const": "warn", - - // Layout & Formatting - "array-bracket-spacing": ["error", "never"], - "block-spacing": "error", - "brace-style": ["error", "1tbs"], - "comma-dangle": ["error", "always-multiline"], - "comma-spacing": ["error", { "before": false, "after": true }], - "indent": ["error", 2], - "quotes": ["error", "single"], - "semi": ["error", "always"], - - // ES6 - "arrow-spacing": "error", - "no-const-assign": "error", - "prefer-template": "warn", - "template-curly-spacing": ["error", "never"] - }, - - env: { - browser: true, - node: true, - es2022: true - } - } -]; \ No newline at end of file From bf07000507f6087c38b629275231706941d36e14 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:07:27 +0545 Subject: [PATCH 15/95] feat: gitworkflow --- .github/workflows/lint.yaml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2c0acce..4ef96f6 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,17 +1,17 @@ name: Multi-language Lint on: - push: - branches: - - '**' # Run on all branches - pull_request: # Keep PR checks for good measure - workflow_dispatch: + push: + branches: + - '**' # Run on all branches + pull_request: # Keep PR checks for good measure + workflow_dispatch: jobs: lint: name: Lint All Languages runs-on: ubuntu-latest - + steps: - name: Checkout code uses: actions/checkout@v4 @@ -35,7 +35,7 @@ jobs: golint ./... go vet ./... staticcheck ./... - + if: success() # Only run if previous steps succeeded # Node.js Setup (for TypeScript, JavaScript, and template linting) - name: Set up Node.js @@ -48,23 +48,23 @@ jobs: - name: Install Node.js dependencies working-directory: cluster-ui run: | - npm install -g eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci - # - name: Lint TypeScript - # run: | - # npx tsc --noEmit - # npx eslint "**/*.{ts,tsx}" --fix + - name: Lint TypeScript + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix - name: Lint JavaScript + working-directory: cluster-ui run: npx eslint "**/*.{js,jsx}" --fix - name: Lint Smarty Templates + working-directory: cluster-ui run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty - # - name: Lint Mustache Templates - # run: npx prettier --check "**/*.mustache" --plugin=prettier-plugin-mustache - # Python Setup and Linting - name: Set up Python uses: actions/setup-python@v5 @@ -79,14 +79,15 @@ jobs: pip install flake8 black isort pylint mypy - name: Lint Python + working-directory: cluster-service run: | - black . + black . --check flake8 . isort . --check-only pylint **/*.py || true mypy . - # # Report results + # Report results (optional) # - name: Upload lint results # if: always() # uses: actions/upload-artifact@v4 From e8522a703808fc66cbe0e85651f7936a57cb9496 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:10:06 +0545 Subject: [PATCH 16/95] feat: gitworkflow --- .github/workflows/lint.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4ef96f6..d8de9a0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -61,9 +61,9 @@ jobs: working-directory: cluster-ui run: npx eslint "**/*.{js,jsx}" --fix - - name: Lint Smarty Templates - working-directory: cluster-ui - run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty + # - name: Lint Smarty Templates + # working-directory: cluster-ui + # run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty # Python Setup and Linting - name: Set up Python From fcad54b0b5301a8f6d8d884f8809f85bac17717c Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:14:40 +0545 Subject: [PATCH 17/95] feat: gitworkflow --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d8de9a0..49605de 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -81,7 +81,7 @@ jobs: - name: Lint Python working-directory: cluster-service run: | - black . --check + # black . --check flake8 . isort . --check-only pylint **/*.py || true From 5ecd74fbcf594e4c10db3d9d7c5158e152c6fc13 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:17:57 +0545 Subject: [PATCH 18/95] feat: gitworkflow --- .github/workflows/lint.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 49605de..0011f29 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -81,7 +81,6 @@ jobs: - name: Lint Python working-directory: cluster-service run: | - # black . --check flake8 . isort . --check-only pylint **/*.py || true From 55de372cd4da27bf273da3628cf330cd1457200f Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:21:08 +0545 Subject: [PATCH 19/95] feat: gitworkflow --- .github/workflows/lint.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 0011f29..c48fb59 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -81,7 +81,6 @@ jobs: - name: Lint Python working-directory: cluster-service run: | - flake8 . isort . --check-only pylint **/*.py || true mypy . From a3914fe78c3096852c5ca5dd052af29e6820af08 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:24:56 +0545 Subject: [PATCH 20/95] feat: gitworkflow --- .github/workflows/lint.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c48fb59..393c765 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -81,7 +81,6 @@ jobs: - name: Lint Python working-directory: cluster-service run: | - isort . --check-only pylint **/*.py || true mypy . From 7c61a40035da3b3048f9d6a8ffbae5fb137b1a31 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:30:19 +0545 Subject: [PATCH 21/95] feat: gitworkflow --- .github/workflows/lint.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 393c765..3900cc1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -76,13 +76,12 @@ jobs: working-directory: cluster-service run: | python -m pip install --upgrade pip - pip install flake8 black isort pylint mypy + pip install flake8 black isort pylint - name: Lint Python working-directory: cluster-service run: | pylint **/*.py || true - mypy . # Report results (optional) # - name: Upload lint results From 14e54d117f687784623d1899261471aa80574b75 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:33:53 +0545 Subject: [PATCH 22/95] feat: gitworkflow --- .github/workflows/lint.yaml | 59 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3900cc1..46428d8 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -23,19 +23,42 @@ jobs: go-version: '1.22' cache: true - - name: Install Go Linting Tools + - name: Install Go tools run: | - go install golang.org/x/lint/golint@latest + go install golang.org/x/tools/cmd/goimports@latest go install honnef.co/go/tools/cmd/staticcheck@latest - echo "$HOME/go/bin" >> $GITHUB_PATH # Ensure installed tools are available in PATH + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH - - name: Run Go Lint + - name: Go Format Check + working-directory: cluster-status run: | - cd cluster-status - golint ./... - go vet ./... - staticcheck ./... - if: success() # Only run if previous steps succeeded + # Check if any .go files need formatting + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + # Check if imports need organizing + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... # Node.js Setup (for TypeScript, JavaScript, and template linting) - name: Set up Node.js @@ -61,10 +84,6 @@ jobs: working-directory: cluster-ui run: npx eslint "**/*.{js,jsx}" --fix - # - name: Lint Smarty Templates - # working-directory: cluster-ui - # run: npx prettier --check "**/*.tpl" --plugin=prettier-plugin-smarty - # Python Setup and Linting - name: Set up Python uses: actions/setup-python@v5 @@ -81,16 +100,4 @@ jobs: - name: Lint Python working-directory: cluster-service run: | - pylint **/*.py || true - - # Report results (optional) - # - name: Upload lint results - # if: always() - # uses: actions/upload-artifact@v4 - # with: - # name: lint-results - # path: | - # **/lint-results.* - # **/pylint-report.txt - # **/eslint-report.json - # retention-days: 14 \ No newline at end of file + pylint **/*.py || true \ No newline at end of file From 12b620cdb21f1248fe82fc2d74c615cf040d7f64 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 14 Feb 2025 13:42:00 +0545 Subject: [PATCH 23/95] feat: gitworkflow --- cluster-status/main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cluster-status/main.go b/cluster-status/main.go index 9d58c35..1121f36 100644 --- a/cluster-status/main.go +++ b/cluster-status/main.go @@ -100,7 +100,10 @@ func (c *Controller) syncToStdout(key string) error { } } fmt.Printf("Container %s Status: %s\n", pod.Name, statusString) - patchClusterStatus(pod.Name, value, statusString) + if err := patchClusterStatus(pod.Name, value, statusString); err != nil { + klog.Errorf("Failed to patch cluster status: %v", err) + return err + } } } } @@ -215,12 +218,14 @@ func main() { // Let's suppose that we knew about a pod "mypod" on our last run, therefore add it to the cache. // If this pod is not there anymore, the controller will be notified about the removal after the // cache has synchronized. - indexer.Add(&v1.Pod{ + if err := indexer.Add(&v1.Pod{ ObjectMeta: meta_v1.ObjectMeta{ Name: "mypod", Namespace: v1.NamespaceDefault, }, - }) + }); err != nil { + klog.Errorf("Failed to add pod to indexer: %v", err) + } // Now let's start the controller stop := make(chan struct{}) From 83eeb908d0c687e9d79e0e830900f5c8b5d068e4 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 13:23:56 +0545 Subject: [PATCH 24/95] fix: documentation --- .github/workflows/lint.yaml | 237 ++++++++++++++++++++++-------------- 1 file changed, 145 insertions(+), 92 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 46428d8..96987d6 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,102 +2,155 @@ name: Multi-language Lint on: push: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' branches: - '**' # Run on all branches - pull_request: # Keep PR checks for good measure + pull_request: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' workflow_dispatch: jobs: - lint: - name: Lint All Languages + changes: runs-on: ubuntu-latest - + permissions: + pull-requests: read + outputs: + cluster-api: ${{ steps.filter.outputs.cluster-api }} + cluster-service: ${{ steps.filter.outputs.cluster-service }} + cluster-status: ${{ steps.filter.outputs.cluster-status }} + cluster-ui: ${{ steps.filter.outputs.cluster-ui }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - # Go Setup and Linting - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true - - - name: Install Go tools - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH - - - name: Go Format Check - working-directory: cluster-status - run: | - # Check if any .go files need formatting - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi - - - name: Go Imports Check - working-directory: cluster-status - run: | - # Check if imports need organizing - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 - fi - - - name: Run golangci-lint - working-directory: cluster-status - run: golangci-lint run --timeout=5m - - - name: Run staticcheck - working-directory: cluster-status - run: staticcheck ./... - - # Node.js Setup (for TypeScript, JavaScript, and template linting) - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json - - - name: Install Node.js dependencies - working-directory: cluster-ui - run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci - - - name: Lint TypeScript - working-directory: cluster-ui - run: | - npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix - - # Python Setup and Linting - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install Python linting tools - working-directory: cluster-service - run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - - - name: Lint Python - working-directory: cluster-service - run: | - pylint **/*.py || true \ No newline at end of file + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + cluster-api: + - 'cluster-api/**/*.py' + cluster-service: + - 'cluster-service/**/*.py' + cluster-status: + - 'cluster-status/**/*.go' + cluster-ui: + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + + python-lint: + needs: changes + if: | + needs.changes.outputs.cluster-api == 'true' || + needs.changes.outputs.cluster-service == 'true' + runs-on: ubuntu-latest + strategy: + matrix: + directory: [cluster-api, cluster-service] + include: + - directory: cluster-api + run-if: needs.changes.outputs.cluster-api == 'true' + - directory: cluster-service + run-if: needs.changes.outputs.cluster-service == 'true' + steps: + - uses: actions/checkout@v4 + - if: matrix.run-if + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - if: matrix.run-if + name: Install Python linting tools + working-directory: ${{ matrix.directory }} + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - if: matrix.run-if + name: Lint Python + working-directory: ${{ matrix.directory }} + run: | + pylint **/*.py || true + + go-lint: + needs: changes + if: needs.changes.outputs.cluster-status == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Install Go tools + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Go Format Check + working-directory: cluster-status + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... + + typescript-lint: + needs: changes + if: needs.changes.outputs.cluster-ui == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json + + - name: Install Node.js dependencies + working-directory: cluster-ui + run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci + + - name: Lint TypeScript + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file From f35374ad0b9f932093d62f8b13d9d482e5784b9b Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 13:29:23 +0545 Subject: [PATCH 25/95] fix: test --- cluster-status/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 75b3df7..6e68f7d 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From 2fdd6fcf6a96e0524bc1e7e2e22c834cc6d3a40e Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 13:43:30 +0545 Subject: [PATCH 26/95] fix: test --- cluster-service/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-service/Dockerfile b/cluster-service/Dockerfile index 6163e92..1d88d0f 100644 --- a/cluster-service/Dockerfile +++ b/cluster-service/Dockerfile @@ -18,4 +18,4 @@ COPY . /app # Install your app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt -CMD python main.py +CMD python main.py From f89dfee34e74e37c62ca564d9610091c9cd07c3a Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 13:55:15 +0545 Subject: [PATCH 27/95] fix: test --- .github/workflows/lint.yaml | 6 +++--- cluster-service/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 96987d6..06b7bb1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -34,11 +34,11 @@ jobs: with: filters: | cluster-api: - - 'cluster-api/**/*.py' + - 'cluster-api/**' # Changed to catch all files in cluster-api cluster-service: - - 'cluster-service/**/*.py' + - 'cluster-service/**' # Changed to catch all files in cluster-service cluster-status: - - 'cluster-status/**/*.go' + - 'cluster-status/**' # Changed to catch all files in cluster-status cluster-ui: - 'cluster-ui/**/*.{ts,tsx,js,jsx}' diff --git a/cluster-service/Dockerfile b/cluster-service/Dockerfile index 1d88d0f..637ded6 100644 --- a/cluster-service/Dockerfile +++ b/cluster-service/Dockerfile @@ -10,7 +10,7 @@ ENV PYTHONUNBUFFERED=1 # Install pip requirements COPY requirements.txt . -RUN python -m pip install -r requirements.txt +RUN python -m pip install -r requirements.txt WORKDIR /app COPY . /app From 199c419c84bc672a571274c4440fa0f2f9571022 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 13:59:22 +0545 Subject: [PATCH 28/95] fix: test --- .github/workflows/lint.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 06b7bb1..a5c5faa 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -34,11 +34,11 @@ jobs: with: filters: | cluster-api: - - 'cluster-api/**' # Changed to catch all files in cluster-api + - 'cluster-api/**' # Changed to include all files in directory cluster-service: - - 'cluster-service/**' # Changed to catch all files in cluster-service + - 'cluster-service/**' # Changed to include all files in directory cluster-status: - - 'cluster-status/**' # Changed to catch all files in cluster-status + - 'cluster-status/**/*.go' cluster-ui: - 'cluster-ui/**/*.{ts,tsx,js,jsx}' @@ -79,7 +79,7 @@ jobs: go-lint: needs: changes - if: needs.changes.outputs.cluster-status == 'true' + if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 5a6d82d9de3e7f105d9793d2240c28afd46194e4 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:06:05 +0545 Subject: [PATCH 29/95] fix: test --- .github/workflows/lint.yaml | 240 ++++++++++++++++-------------------- 1 file changed, 104 insertions(+), 136 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index a5c5faa..dd8c9f1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,13 +2,13 @@ name: Multi-language Lint on: push: + branches: + - '**' # Run on all branches paths: - 'cluster-api/**' - 'cluster-service/**' - 'cluster-status/**' - 'cluster-ui/**' - branches: - - '**' # Run on all branches pull_request: paths: - 'cluster-api/**' @@ -18,139 +18,107 @@ on: workflow_dispatch: jobs: - changes: - runs-on: ubuntu-latest - permissions: - pull-requests: read - outputs: - cluster-api: ${{ steps.filter.outputs.cluster-api }} - cluster-service: ${{ steps.filter.outputs.cluster-service }} - cluster-status: ${{ steps.filter.outputs.cluster-status }} - cluster-ui: ${{ steps.filter.outputs.cluster-ui }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - cluster-api: - - 'cluster-api/**' # Changed to include all files in directory - cluster-service: - - 'cluster-service/**' # Changed to include all files in directory - cluster-status: - - 'cluster-status/**/*.go' - cluster-ui: - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' - - python-lint: - needs: changes - if: | - needs.changes.outputs.cluster-api == 'true' || - needs.changes.outputs.cluster-service == 'true' - runs-on: ubuntu-latest - strategy: - matrix: - directory: [cluster-api, cluster-service] - include: - - directory: cluster-api - run-if: needs.changes.outputs.cluster-api == 'true' - - directory: cluster-service - run-if: needs.changes.outputs.cluster-service == 'true' - steps: - - uses: actions/checkout@v4 - - if: matrix.run-if - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - if: matrix.run-if - name: Install Python linting tools - working-directory: ${{ matrix.directory }} - run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - - - if: matrix.run-if - name: Lint Python - working-directory: ${{ matrix.directory }} - run: | - pylint **/*.py || true - - go-lint: - needs: changes - if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true - - - name: Install Go tools - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH - - - name: Go Format Check - working-directory: cluster-status - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi - - - name: Go Imports Check - working-directory: cluster-status - run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 - fi - - - name: Run golangci-lint - working-directory: cluster-status - run: golangci-lint run --timeout=5m - - - name: Run staticcheck - working-directory: cluster-status - run: staticcheck ./... - - typescript-lint: - needs: changes - if: needs.changes.outputs.cluster-ui == 'true' + lint: + name: Lint All Languages runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json - - - name: Install Node.js dependencies - working-directory: cluster-ui - run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci - - - name: Lint TypeScript - working-directory: cluster-ui - run: | - npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + - name: Checkout code + uses: actions/checkout@v4 + + # Go Setup and Linting (only for cluster-status) + - name: Set up Go + if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Install Go tools + if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Go Format Check + if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') + working-directory: cluster-status + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') + working-directory: cluster-status + run: staticcheck ./... + + # Node.js Setup (for TypeScript, JavaScript, and template linting) (only for cluster-ui) + - name: Set up Node.js + if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json + + - name: Install Node.js dependencies + if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') + working-directory: cluster-ui + run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci + + - name: Lint TypeScript + if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "*/.{ts,tsx}" --fix + + - name: Lint JavaScript + if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') + working-directory: cluster-ui + run: npx eslint "*/.{js,jsx}" --fix + + # Python Setup and Linting (only for cluster-api and cluster-service) + - name: Set up Python + if: contains(github.event.pull_request.changed_files, 'cluster-api/') || contains(github.event.push.changed_files, 'cluster-api/') || contains(github.event.pull_request.changed_files, 'cluster-service/') || contains(github.event.push.changed_files, 'cluster-service/') + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + if: contains(github.event.pull_request.changed_files, 'cluster-api/') || contains(github.event.push.changed_files, 'cluster-api/') || contains(github.event.pull_request.changed_files, 'cluster-service/') || contains(github.event.push.changed_files, 'cluster-service/') + working-directory: cluster-service + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - name: Lint Python + if: contains(github.event.pull_request.changed_files, 'cluster-api/') || contains(github.event.push.changed_files, 'cluster-api/') || contains(github.event.pull_request.changed_files, 'cluster-service/') || contains(github.event.push.changed_files, 'cluster-service/') + working-directory: cluster-service + run: | + pylint */.py || true \ No newline at end of file From 615bf4a41a7e075b48c127cbd157687a47695af3 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:29:56 +0545 Subject: [PATCH 30/95] fix: pyhton lint --- .github/workflows/lint.yaml | 240 ++++++++++++++++++++---------------- cluster-api/Dockerfile | 2 +- 2 files changed, 137 insertions(+), 105 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index dd8c9f1..82b78bb 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,13 +2,13 @@ name: Multi-language Lint on: push: - branches: - - '**' # Run on all branches paths: - 'cluster-api/**' - 'cluster-service/**' - 'cluster-status/**' - 'cluster-ui/**' + branches: + - '**' # Run on all branches pull_request: paths: - 'cluster-api/**' @@ -18,107 +18,139 @@ on: workflow_dispatch: jobs: - lint: - name: Lint All Languages + changes: runs-on: ubuntu-latest - + permissions: + pull-requests: read + outputs: + cluster-api: ${{ steps.filter.outputs.cluster-api }} + cluster-service: ${{ steps.filter.outputs.cluster-service }} + cluster-status: ${{ steps.filter.outputs.cluster-status }} + cluster-ui: ${{ steps.filter.outputs.cluster-ui }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - # Go Setup and Linting (only for cluster-status) - - name: Set up Go - if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true - - - name: Install Go tools - if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH - - - name: Go Format Check - if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') - working-directory: cluster-status - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi - - - name: Go Imports Check - if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') - working-directory: cluster-status - run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 - fi - - - name: Run golangci-lint - if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') - working-directory: cluster-status - run: golangci-lint run --timeout=5m - - - name: Run staticcheck - if: contains(github.event.pull_request.changed_files, 'cluster-status/') || contains(github.event.push.changed_files, 'cluster-status/') - working-directory: cluster-status - run: staticcheck ./... - - # Node.js Setup (for TypeScript, JavaScript, and template linting) (only for cluster-ui) - - name: Set up Node.js - if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json - - - name: Install Node.js dependencies - if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') - working-directory: cluster-ui - run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci - - - name: Lint TypeScript - if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') - working-directory: cluster-ui - run: | - npx tsc --noEmit - npx eslint "*/.{ts,tsx}" --fix - - - name: Lint JavaScript - if: contains(github.event.pull_request.changed_files, 'cluster-ui/') || contains(github.event.push.changed_files, 'cluster-ui/') - working-directory: cluster-ui - run: npx eslint "*/.{js,jsx}" --fix - - # Python Setup and Linting (only for cluster-api and cluster-service) - - name: Set up Python - if: contains(github.event.pull_request.changed_files, 'cluster-api/') || contains(github.event.push.changed_files, 'cluster-api/') || contains(github.event.pull_request.changed_files, 'cluster-service/') || contains(github.event.push.changed_files, 'cluster-service/') - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install Python linting tools - if: contains(github.event.pull_request.changed_files, 'cluster-api/') || contains(github.event.push.changed_files, 'cluster-api/') || contains(github.event.pull_request.changed_files, 'cluster-service/') || contains(github.event.push.changed_files, 'cluster-service/') - working-directory: cluster-service - run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - - - name: Lint Python - if: contains(github.event.pull_request.changed_files, 'cluster-api/') || contains(github.event.push.changed_files, 'cluster-api/') || contains(github.event.pull_request.changed_files, 'cluster-service/') || contains(github.event.push.changed_files, 'cluster-service/') - working-directory: cluster-service - run: | - pylint */.py || true \ No newline at end of file + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + cluster-api: + - 'cluster-api/**/*.py' # Only trigger if Python files are changed + cluster-service: + - 'cluster-service/**/*.py' # Only trigger if Python files are changed + cluster-status: + - 'cluster-status/**/*.go' + cluster-ui: + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + + python-lint: + needs: changes + if: | + needs.changes.outputs.cluster-api == 'true' || + needs.changes.outputs.cluster-service == 'true' + runs-on: ubuntu-latest + strategy: + matrix: + directory: [cluster-api, cluster-service] + include: + - directory: cluster-api + run-if: needs.changes.outputs.cluster-api == 'true' + - directory: cluster-service + run-if: needs.changes.outputs.cluster-service == 'true' + steps: + - uses: actions/checkout@v4 + - if: matrix.run-if + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - if: matrix.run-if + name: Install Python linting tools + working-directory: ${{ matrix.directory }} + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - if: matrix.run-if + name: Lint Python + working-directory: ${{ matrix.directory }} + run: | + pylint **/*.py || true + + go-lint: + needs: changes + if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Install Go tools + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Go Format Check + working-directory: cluster-status + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... + + typescript-lint: + needs: changes + if: needs.changes.outputs.cluster-ui == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json + + - name: Install Node.js dependencies + working-directory: cluster-ui + run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci + + - name: Lint TypeScript + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 8059524..0d36b93 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From a1f8895d667dea7ff9e6fb37bc59be96bcd39895 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:31:57 +0545 Subject: [PATCH 31/95] fix: pyhton lint --- .github/workflows/lint.yaml | 132 ++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 82b78bb..cac8433 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -77,80 +77,80 @@ jobs: run: | pylint **/*.py || true - go-lint: - needs: changes - if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + # go-lint: + # needs: changes + # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true + # - name: Set up Go + # uses: actions/setup-go@v5 + # with: + # go-version: '1.22' + # cache: true - - name: Install Go tools - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH + # - name: Install Go tools + # run: | + # go install golang.org/x/tools/cmd/goimports@latest + # go install honnef.co/go/tools/cmd/staticcheck@latest + # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + # echo "$HOME/go/bin" >> $GITHUB_PATH - - name: Go Format Check - working-directory: cluster-status - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi + # - name: Go Format Check + # working-directory: cluster-status + # run: | + # if [ -n "$(gofmt -l .)" ]; then + # echo "The following files need formatting:" + # gofmt -l . + # echo "Please run 'gofmt -w .' to format your code." + # exit 1 + # fi - - name: Go Imports Check - working-directory: cluster-status - run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 - fi + # - name: Go Imports Check + # working-directory: cluster-status + # run: | + # if [ -n "$(goimports -l .)" ]; then + # echo "The following files have incorrect imports:" + # goimports -l . + # echo "Please run 'goimports -w .' to fix imports." + # exit 1 + # fi - - name: Run golangci-lint - working-directory: cluster-status - run: golangci-lint run --timeout=5m + # - name: Run golangci-lint + # working-directory: cluster-status + # run: golangci-lint run --timeout=5m - - name: Run staticcheck - working-directory: cluster-status - run: staticcheck ./... + # - name: Run staticcheck + # working-directory: cluster-status + # run: staticcheck ./... - typescript-lint: - needs: changes - if: needs.changes.outputs.cluster-ui == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + # typescript-lint: + # needs: changes + # if: needs.changes.outputs.cluster-ui == 'true' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json + # - name: Set up Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: '20' + # cache: 'npm' + # cache-dependency-path: cluster-ui/package-lock.json - - name: Install Node.js dependencies - working-directory: cluster-ui - run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci + # - name: Install Node.js dependencies + # working-directory: cluster-ui + # run: | + # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + # npm ci - - name: Lint TypeScript - working-directory: cluster-ui - run: | - npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix + # - name: Lint TypeScript + # working-directory: cluster-ui + # run: | + # npx tsc --noEmit + # npx eslint "**/*.{ts,tsx}" --fix - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + # - name: Lint JavaScript + # working-directory: cluster-ui + # run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file From ccb031a26daa110b81d5b7d501fa5a645a37171a Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:32:47 +0545 Subject: [PATCH 32/95] fix: pyhton lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 0d36b93..d40d194 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -12,7 +12,7 @@ ENV PYTHONUNBUFFERED=1 COPY requirements.txt . RUN python -m pip install -r requirements.txt -WORKDIR /app +WORKDIR /app COPY . /app # Install your app From 7a82a0c66edadbae959166e2795bd0a3bf566667 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:35:42 +0545 Subject: [PATCH 33/95] fix: pyhton lint --- .github/workflows/lint.yaml | 71 +++++++++++++++++-------------------- cluster-api/Dockerfile | 2 +- 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index cac8433..31f59ce 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,64 +18,57 @@ on: workflow_dispatch: jobs: - changes: - runs-on: ubuntu-latest - permissions: - pull-requests: read - outputs: - cluster-api: ${{ steps.filter.outputs.cluster-api }} - cluster-service: ${{ steps.filter.outputs.cluster-service }} - cluster-status: ${{ steps.filter.outputs.cluster-status }} - cluster-ui: ${{ steps.filter.outputs.cluster-ui }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - cluster-api: - - 'cluster-api/**/*.py' # Only trigger if Python files are changed - cluster-service: - - 'cluster-service/**/*.py' # Only trigger if Python files are changed - cluster-status: - - 'cluster-status/**/*.go' - cluster-ui: - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' - python-lint: - needs: changes - if: | - needs.changes.outputs.cluster-api == 'true' || - needs.changes.outputs.cluster-service == 'true' runs-on: ubuntu-latest strategy: + fail-fast: false matrix: directory: [cluster-api, cluster-service] - include: - - directory: cluster-api - run-if: needs.changes.outputs.cluster-api == 'true' - - directory: cluster-service - run-if: needs.changes.outputs.cluster-service == 'true' + steps: - uses: actions/checkout@v4 - - if: matrix.run-if + + # Check if directory contains Python files + - name: Check for Python files + id: check-python + run: | + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - - if: matrix.run-if - name: Install Python linting tools + - name: Install Python linting tools + if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - if: matrix.run-if - name: Lint Python + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} + run: | + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + + - name: Run Black + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} + run: | + black --check . + + - name: Run isort + if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | - pylint **/*.py || true + isort --check-only --diff . # go-lint: # needs: changes diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index d40d194..ab69126 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From f024a84f8b0828a4d2dfa4f9a8ff4bf5a62a73b5 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:36:46 +0545 Subject: [PATCH 34/95] fix: pyhton lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index ab69126..d40d194 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From bbedd91c97d8231691664381e3baae9d96b4c86a Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:42:54 +0545 Subject: [PATCH 35/95] fix: pyhton lint --- .github/workflows/lint.yaml | 112 +++++++++++++++++++++++++++--------- cluster-api/Dockerfile | 4 +- 2 files changed, 88 insertions(+), 28 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 31f59ce..c4f83a6 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,57 +18,117 @@ on: workflow_dispatch: jobs: - python-lint: + changes: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - directory: [cluster-api, cluster-service] - + permissions: + pull-requests: read + outputs: + cluster-api: ${{ steps.filter.outputs.cluster-api }} + cluster-service: ${{ steps.filter.outputs.cluster-service }} steps: - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + cluster-api: + - 'cluster-api/**/*.py' + cluster-service: + - 'cluster-service/**/*.py' + + lint-cluster-api: + needs: changes + if: needs.changes.outputs.cluster-api == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: cluster-api/**/*.py + + - name: Set up Python + if: steps.changed-files.outputs.any_changed == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-api + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - name: Run Pylint + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-api + run: | + echo "Changed files:" + echo "${{ steps.changed-files.outputs.all_changed_files }}" + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" - # Check if directory contains Python files - - name: Check for Python files - id: check-python + - name: Run Black + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-api run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs black --check + + - name: Run isort + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-api + run: | + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs isort --check-only --diff + + lint-cluster-service: + needs: changes + if: needs.changes.outputs.cluster-service == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: cluster-service/**/*.py - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' + if: steps.changed-files.outputs.any_changed == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-service run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-service run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + echo "Changed files:" + echo "${{ steps.changed-files.outputs.all_changed_files }}" + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" - name: Run Black - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-service run: | - black --check . + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs black --check - name: Run isort - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-service run: | - isort --check-only --diff . + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs isort --check-only --diff # go-lint: # needs: changes diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index d40d194..7e1e95b 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,8 +13,8 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app - +COPY . /app + # Install your app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt From f2e9b69af4729977b36bcfedca211072ccc0e5aa Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:51:45 +0545 Subject: [PATCH 36/95] fix: pyhton lint --- .github/workflows/lint.yaml | 118 +++++++++--------------------------- cluster-api/Dockerfile | 4 +- 2 files changed, 32 insertions(+), 90 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c4f83a6..9cd5ff0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,120 +18,62 @@ on: workflow_dispatch: jobs: - changes: - runs-on: ubuntu-latest - permissions: - pull-requests: read - outputs: - cluster-api: ${{ steps.filter.outputs.cluster-api }} - cluster-service: ${{ steps.filter.outputs.cluster-service }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - cluster-api: - - 'cluster-api/**/*.py' - cluster-service: - - 'cluster-service/**/*.py' - - lint-cluster-api: - needs: changes - if: needs.changes.outputs.cluster-api == 'true' + python-lint: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + directory: [cluster-api, cluster-service] + steps: - uses: actions/checkout@v4 - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: cluster-api/**/*.py - - - name: Set up Python - if: steps.changed-files.outputs.any_changed == 'true' - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install Python linting tools - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-api + # Check if directory contains Python files + - name: Check for Python files + id: check-python run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - - - name: Run Pylint - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-api - run: | - echo "Changed files:" - echo "${{ steps.changed-files.outputs.all_changed_files }}" - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" - - - name: Run Black - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-api - run: | - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs black --check - - - name: Run isort - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-api - run: | - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs isort --check-only --diff - - lint-cluster-service: - needs: changes - if: needs.changes.outputs.cluster-service == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: cluster-service/**/*.py + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi - name: Set up Python - if: steps.changed-files.outputs.any_changed == 'true' + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-service + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - name: Run Pylint - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-service + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | - echo "Changed files:" - echo "${{ steps.changed-files.outputs.all_changed_files }}" - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - name: Run Black - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-service + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs black --check + black --check . - name: Run isort - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-service + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | xargs isort --check-only --diff + isort --check-only --diff . + + # go-lint: - # needs: changes + # # needs: changes # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') # runs-on: ubuntu-latest # steps: @@ -179,7 +121,7 @@ jobs: # run: staticcheck ./... # typescript-lint: - # needs: changes + # # needs: changes # if: needs.changes.outputs.cluster-ui == 'true' # runs-on: ubuntu-latest # steps: diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 7e1e95b..57eb30f 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -11,9 +11,9 @@ ENV PYTHONUNBUFFERED=1 # Install pip requirements COPY requirements.txt . RUN python -m pip install -r requirements.txt - + WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From 15112652ed2b486b7e9b1ebbf44dacadd413624f Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:55:18 +0545 Subject: [PATCH 37/95] fix: pyhton lint --- .github/workflows/lint.yaml | 243 ++++++++++++++++++++---------------- 1 file changed, 135 insertions(+), 108 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9cd5ff0..850882f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,7 +8,7 @@ on: - 'cluster-status/**' - 'cluster-ui/**' branches: - - '**' # Run on all branches + - '**' pull_request: paths: - 'cluster-api/**' @@ -18,134 +18,161 @@ on: workflow_dispatch: jobs: + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + python: ${{ steps.filter.outputs.python }} + go: ${{ steps.filter.outputs.go }} + typescript: ${{ steps.filter.outputs.typescript }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + python: + - 'cluster-api/**/*.py' + - 'cluster-service/**/*.py' + go: + - 'cluster-status/**/*.go' + typescript: + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + python-lint: + needs: changes + if: needs.changes.outputs.python == 'true' runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - directory: [cluster-api, cluster-service] - steps: - uses: actions/checkout@v4 - # Check if directory contains Python files - - name: Check for Python files - id: check-python - run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi + - name: Get changed Python files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + cluster-api/**/*.py + cluster-service/**/*.py - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' + if: steps.changed-files.outputs.any_changed == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.changed-files.outputs.any_changed == 'true' run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} - run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - - - name: Run Black - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} - run: | - black --check . - - - name: Run isort - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + - name: Run linters + if: steps.changed-files.outputs.any_changed == 'true' run: | - isort --check-only --diff . - - - - # go-lint: - # # needs: changes - # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 + echo "Changed files:" + echo "${{ steps.changed-files.outputs.all_changed_files }}" + + # Run linters only on changed files + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | while read file; do + if [ -f "$file" ]; then + echo "Linting $file" + pylint "$file" || echo "Pylint warnings found" + black --check "$file" + isort --check-only --diff "$file" + fi + done + + go-lint: + needs: changes + if: needs.changes.outputs.go == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - # - name: Set up Go - # uses: actions/setup-go@v5 - # with: - # go-version: '1.22' - # cache: true - - # - name: Install Go tools - # run: | - # go install golang.org/x/tools/cmd/goimports@latest - # go install honnef.co/go/tools/cmd/staticcheck@latest - # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - # echo "$HOME/go/bin" >> $GITHUB_PATH - - # - name: Go Format Check - # working-directory: cluster-status - # run: | - # if [ -n "$(gofmt -l .)" ]; then - # echo "The following files need formatting:" - # gofmt -l . - # echo "Please run 'gofmt -w .' to format your code." - # exit 1 - # fi - - # - name: Go Imports Check - # working-directory: cluster-status - # run: | - # if [ -n "$(goimports -l .)" ]; then - # echo "The following files have incorrect imports:" - # goimports -l . - # echo "Please run 'goimports -w .' to fix imports." - # exit 1 - # fi - - # - name: Run golangci-lint - # working-directory: cluster-status - # run: golangci-lint run --timeout=5m + - name: Get changed Go files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: cluster-status/**/*.go - # - name: Run staticcheck - # working-directory: cluster-status - # run: staticcheck ./... + - name: Set up Go + if: steps.changed-files.outputs.any_changed == 'true' + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true - # typescript-lint: - # # needs: changes - # if: needs.changes.outputs.cluster-ui == 'true' - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 + - name: Install Go tools + if: steps.changed-files.outputs.any_changed == 'true' + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Run Go linters + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-status + run: | + echo "Changed files:" + echo "${{ steps.changed-files.outputs.all_changed_files }}" + + # Run formatters + gofmt -l -w . + goimports -w . + + # Run linters + golangci-lint run --timeout=5m + staticcheck ./... + + typescript-lint: + needs: changes + if: needs.changes.outputs.typescript == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: '20' - # cache: 'npm' - # cache-dependency-path: cluster-ui/package-lock.json - - # - name: Install Node.js dependencies - # working-directory: cluster-ui - # run: | - # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - # npm ci + - name: Get changed TypeScript/JavaScript files + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + cluster-ui/**/*.ts + cluster-ui/**/*.tsx + cluster-ui/**/*.js + cluster-ui/**/*.jsx + + - name: Set up Node.js + if: steps.changed-files.outputs.any_changed == 'true' + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json - # - name: Lint TypeScript - # working-directory: cluster-ui - # run: | - # npx tsc --noEmit - # npx eslint "**/*.{ts,tsx}" --fix + - name: Install dependencies + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-ui + run: | + npm ci + npm install -g typescript eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin - # - name: Lint JavaScript - # working-directory: cluster-ui - # run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + - name: Run TypeScript/JavaScript linters + if: steps.changed-files.outputs.any_changed == 'true' + working-directory: cluster-ui + run: | + echo "Changed files:" + echo "${{ steps.changed-files.outputs.all_changed_files }}" + + # Type check + npx tsc --noEmit + + # Lint changed files + echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | while read file; do + if [ -f "$file" ]; then + echo "Linting $file" + npx eslint "$file" --fix + fi + done \ No newline at end of file From b166ed5bb454fb3bd16a13859f18cd2ec6779c15 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:55:45 +0545 Subject: [PATCH 38/95] fix: pyhton lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 57eb30f..87b2e63 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -9,7 +9,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install pip requirements -COPY requirements.txt . +COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app From 3b24045df30eed70ad2be09c5f09c9593bd7583e Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:56:48 +0545 Subject: [PATCH 39/95] fix: pyhton lint --- .github/workflows/lint.yaml | 243 ++++++++++++++++-------------------- cluster-api/Dockerfile | 4 +- 2 files changed, 110 insertions(+), 137 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 850882f..0c69122 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,7 +8,7 @@ on: - 'cluster-status/**' - 'cluster-ui/**' branches: - - '**' + - '**' # Run on all branches pull_request: paths: - 'cluster-api/**' @@ -18,161 +18,134 @@ on: workflow_dispatch: jobs: - changes: - runs-on: ubuntu-latest - permissions: - pull-requests: read - outputs: - python: ${{ steps.filter.outputs.python }} - go: ${{ steps.filter.outputs.go }} - typescript: ${{ steps.filter.outputs.typescript }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - python: - - 'cluster-api/**/*.py' - - 'cluster-service/**/*.py' - go: - - 'cluster-status/**/*.go' - typescript: - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' - python-lint: - needs: changes - if: needs.changes.outputs.python == 'true' runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + directory: [cluster-api, cluster-service] + steps: - uses: actions/checkout@v4 - - name: Get changed Python files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: | - cluster-api/**/*.py - cluster-service/**/*.py + # Check if directory contains Python files + - name: Check for Python files + id: check-python + run: | + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi - name: Set up Python - if: steps.changed-files.outputs.any_changed == 'true' + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: steps.changed-files.outputs.any_changed == 'true' + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run linters - if: steps.changed-files.outputs.any_changed == 'true' + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | - echo "Changed files:" - echo "${{ steps.changed-files.outputs.all_changed_files }}" - - # Run linters only on changed files - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | while read file; do - if [ -f "$file" ]; then - echo "Linting $file" - pylint "$file" || echo "Pylint warnings found" - black --check "$file" - isort --check-only --diff "$file" - fi - done - - go-lint: - needs: changes - if: needs.changes.outputs.go == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Get changed Go files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: cluster-status/**/*.go + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - - name: Set up Go - if: steps.changed-files.outputs.any_changed == 'true' - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true + # - name: Run Black + # if: steps.check-python.outputs.has_python_files == 'true' + # working-directory: ${{ matrix.directory }} + # run: | + # black --check . - - name: Install Go tools - if: steps.changed-files.outputs.any_changed == 'true' - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH - - - name: Run Go linters - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-status + - name: Run isort + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | - echo "Changed files:" - echo "${{ steps.changed-files.outputs.all_changed_files }}" - - # Run formatters - gofmt -l -w . - goimports -w . - - # Run linters - golangci-lint run --timeout=5m - staticcheck ./... - - typescript-lint: - needs: changes - if: needs.changes.outputs.typescript == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + isort --check-only --diff . + + + + # go-lint: + # # needs: changes + # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 - - name: Get changed TypeScript/JavaScript files - id: changed-files - uses: tj-actions/changed-files@v41 - with: - files: | - cluster-ui/**/*.ts - cluster-ui/**/*.tsx - cluster-ui/**/*.js - cluster-ui/**/*.jsx - - - name: Set up Node.js - if: steps.changed-files.outputs.any_changed == 'true' - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json + # - name: Set up Go + # uses: actions/setup-go@v5 + # with: + # go-version: '1.22' + # cache: true - - name: Install dependencies - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-ui - run: | - npm ci - npm install -g typescript eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin + # - name: Install Go tools + # run: | + # go install golang.org/x/tools/cmd/goimports@latest + # go install honnef.co/go/tools/cmd/staticcheck@latest + # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + # echo "$HOME/go/bin" >> $GITHUB_PATH - - name: Run TypeScript/JavaScript linters - if: steps.changed-files.outputs.any_changed == 'true' - working-directory: cluster-ui - run: | - echo "Changed files:" - echo "${{ steps.changed-files.outputs.all_changed_files }}" - - # Type check - npx tsc --noEmit - - # Lint changed files - echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | while read file; do - if [ -f "$file" ]; then - echo "Linting $file" - npx eslint "$file" --fix - fi - done \ No newline at end of file + # - name: Go Format Check + # working-directory: cluster-status + # run: | + # if [ -n "$(gofmt -l .)" ]; then + # echo "The following files need formatting:" + # gofmt -l . + # echo "Please run 'gofmt -w .' to format your code." + # exit 1 + # fi + + # - name: Go Imports Check + # working-directory: cluster-status + # run: | + # if [ -n "$(goimports -l .)" ]; then + # echo "The following files have incorrect imports:" + # goimports -l . + # echo "Please run 'goimports -w .' to fix imports." + # exit 1 + # fi + + # - name: Run golangci-lint + # working-directory: cluster-status + # run: golangci-lint run --timeout=5m + + # - name: Run staticcheck + # working-directory: cluster-status + # run: staticcheck ./... + + # typescript-lint: + # # needs: changes + # if: needs.changes.outputs.cluster-ui == 'true' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + + # - name: Set up Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: '20' + # cache: 'npm' + # cache-dependency-path: cluster-ui/package-lock.json + + # - name: Install Node.js dependencies + # working-directory: cluster-ui + # run: | + # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + # npm ci + + # - name: Lint TypeScript + # working-directory: cluster-ui + # run: | + # npx tsc --noEmit + # npx eslint "**/*.{ts,tsx}" --fix + + # - name: Lint JavaScript + # working-directory: cluster-ui + # run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 87b2e63..5188165 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -12,8 +12,8 @@ ENV PYTHONUNBUFFERED=1 COPY requirements.txt . RUN python -m pip install -r requirements.txt -WORKDIR /app -COPY . /app +WORKDIR /app +COPY . /app # Install your app COPY . . From 38622d5f1dd2ced39b7e301db1b62404b6d0d045 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 14:57:40 +0545 Subject: [PATCH 40/95] fix: pyhton lint --- .github/workflows/lint.yaml | 10 +++++----- cluster-api/Dockerfile | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 0c69122..d2e1724 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -64,11 +64,11 @@ jobs: # run: | # black --check . - - name: Run isort - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} - run: | - isort --check-only --diff . + # - name: Run isort + # if: steps.check-python.outputs.has_python_files == 'true' + # working-directory: ${{ matrix.directory }} + # run: | + # isort --check-only --diff . diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 5188165..e532cd7 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -11,7 +11,7 @@ ENV PYTHONUNBUFFERED=1 # Install pip requirements COPY requirements.txt . RUN python -m pip install -r requirements.txt - + WORKDIR /app COPY . /app From 3637f5d487498c2eec7c54d645127f11d95b56dc Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:06:38 +0545 Subject: [PATCH 41/95] fix: pyhton lint --- .github/workflows/lint.yaml | 20 ++++++++++++++++---- cluster-api/Dockerfile | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d2e1724..d0629a1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,17 +18,29 @@ on: workflow_dispatch: jobs: + determine-changes: + runs-on: ubuntu-latest + outputs: + directories: ${{ steps.changed-dirs.outputs.directories }} + steps: + - uses: actions/checkout@v4 + - name: Get changed directories + id: changed-dirs + run: | + CHANGED_DIRS=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | awk -F'/' '{print $1}' | sort -u | uniq | grep -E '^(cluster-api|cluster-service)$' || echo "") + echo "directories=$(echo $CHANGED_DIRS | jq -R -s -c 'split(" ") | map(select(. != ""))')" >> $GITHUB_OUTPUT + python-lint: + needs: determine-changes runs-on: ubuntu-latest + if: needs.determine-changes.outputs.directories != '[]' strategy: fail-fast: false matrix: - directory: [cluster-api, cluster-service] - + directory: ${{ fromJson(needs.determine-changes.outputs.directories) }} steps: - uses: actions/checkout@v4 - # Check if directory contains Python files - name: Check for Python files id: check-python run: | @@ -44,7 +56,7 @@ jobs: with: python-version: '3.11' cache: 'pip' - + - name: Install Python linting tools if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index e532cd7..8a3ac35 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -19,4 +19,4 @@ COPY . /app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Install your app -CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file +CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file From bc7dcbdb388167c7d4a5c534f5aba0113bd5a16a Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:08:40 +0545 Subject: [PATCH 42/95] fix: pyhton lint --- .github/workflows/lint.yaml | 20 ++++---------------- cluster-api/Dockerfile | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d0629a1..d2e1724 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,29 +18,17 @@ on: workflow_dispatch: jobs: - determine-changes: - runs-on: ubuntu-latest - outputs: - directories: ${{ steps.changed-dirs.outputs.directories }} - steps: - - uses: actions/checkout@v4 - - name: Get changed directories - id: changed-dirs - run: | - CHANGED_DIRS=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | awk -F'/' '{print $1}' | sort -u | uniq | grep -E '^(cluster-api|cluster-service)$' || echo "") - echo "directories=$(echo $CHANGED_DIRS | jq -R -s -c 'split(" ") | map(select(. != ""))')" >> $GITHUB_OUTPUT - python-lint: - needs: determine-changes runs-on: ubuntu-latest - if: needs.determine-changes.outputs.directories != '[]' strategy: fail-fast: false matrix: - directory: ${{ fromJson(needs.determine-changes.outputs.directories) }} + directory: [cluster-api, cluster-service] + steps: - uses: actions/checkout@v4 + # Check if directory contains Python files - name: Check for Python files id: check-python run: | @@ -56,7 +44,7 @@ jobs: with: python-version: '3.11' cache: 'pip' - + - name: Install Python linting tools if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 8a3ac35..4e2509e 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -19,4 +19,4 @@ COPY . /app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Install your app -CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file +CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file From e9f13d90067aaf80808c51b5442107403282c3eb Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:20:42 +0545 Subject: [PATCH 43/95] fix: pyhton lint --- .github/workflows/lint.yaml | 362 +++++++++++++++++++++++++++--------- 1 file changed, 269 insertions(+), 93 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d2e1724..4c37e23 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,3 +1,161 @@ +# name: Multi-language Lint + +# on: +# push: +# paths: +# - 'cluster-api/**' +# - 'cluster-service/**' +# - 'cluster-status/**' +# - 'cluster-ui/**' +# branches: +# - '**' # Run on all branches +# pull_request: +# paths: +# - 'cluster-api/**' +# - 'cluster-service/**' +# - 'cluster-status/**' +# - 'cluster-ui/**' +# workflow_dispatch: + +# jobs: +# python-lint: +# runs-on: ubuntu-latest +# strategy: +# fail-fast: false +# matrix: +# directory: [cluster-api, cluster-service] + +# steps: +# - uses: actions/checkout@v4 + +# # Check if directory contains Python files +# - name: Check for Python files +# id: check-python +# run: | +# if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then +# echo "has_python_files=true" >> $GITHUB_OUTPUT +# else +# echo "has_python_files=false" >> $GITHUB_OUTPUT +# fi + +# - name: Set up Python +# if: steps.check-python.outputs.has_python_files == 'true' +# uses: actions/setup-python@v5 +# with: +# python-version: '3.11' +# cache: 'pip' + +# - name: Install Python linting tools +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: ${{ matrix.directory }} +# run: | +# python -m pip install --upgrade pip +# pip install flake8 black isort pylint + +# - name: Run Pylint +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: ${{ matrix.directory }} +# run: | +# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + +# # - name: Run Black +# # if: steps.check-python.outputs.has_python_files == 'true' +# # working-directory: ${{ matrix.directory }} +# # run: | +# # black --check . + +# # - name: Run isort +# # if: steps.check-python.outputs.has_python_files == 'true' +# # working-directory: ${{ matrix.directory }} +# # run: | +# # isort --check-only --diff . + + + +# # go-lint: +# # # needs: changes +# # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') +# # runs-on: ubuntu-latest +# # steps: +# # - uses: actions/checkout@v4 + +# # - name: Set up Go +# # uses: actions/setup-go@v5 +# # with: +# # go-version: '1.22' +# # cache: true + +# # - name: Install Go tools +# # run: | +# # go install golang.org/x/tools/cmd/goimports@latest +# # go install honnef.co/go/tools/cmd/staticcheck@latest +# # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest +# # echo "$HOME/go/bin" >> $GITHUB_PATH + +# # - name: Go Format Check +# # working-directory: cluster-status +# # run: | +# # if [ -n "$(gofmt -l .)" ]; then +# # echo "The following files need formatting:" +# # gofmt -l . +# # echo "Please run 'gofmt -w .' to format your code." +# # exit 1 +# # fi + +# # - name: Go Imports Check +# # working-directory: cluster-status +# # run: | +# # if [ -n "$(goimports -l .)" ]; then +# # echo "The following files have incorrect imports:" +# # goimports -l . +# # echo "Please run 'goimports -w .' to fix imports." +# # exit 1 +# # fi + +# # - name: Run golangci-lint +# # working-directory: cluster-status +# # run: golangci-lint run --timeout=5m + +# # - name: Run staticcheck +# # working-directory: cluster-status +# # run: staticcheck ./... + +# # typescript-lint: +# # # needs: changes +# # if: needs.changes.outputs.cluster-ui == 'true' +# # runs-on: ubuntu-latest +# # steps: +# # - uses: actions/checkout@v4 + +# # - name: Set up Node.js +# # uses: actions/setup-node@v4 +# # with: +# # node-version: '20' +# # cache: 'npm' +# # cache-dependency-path: cluster-ui/package-lock.json + +# # - name: Install Node.js dependencies +# # working-directory: cluster-ui +# # run: | +# # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin +# # npm ci + +# # - name: Lint TypeScript +# # working-directory: cluster-ui +# # run: | +# # npx tsc --noEmit +# # npx eslint "**/*.{ts,tsx}" --fix + +# # - name: Lint JavaScript +# # working-directory: cluster-ui +# # run: npx eslint "**/*.{js,jsx}" --fix + + + + + + + name: Multi-language Lint on: @@ -18,134 +176,152 @@ on: workflow_dispatch: jobs: + changes: + runs-on: ubuntu-latest + outputs: + cluster-api: ${{ steps.filter.outputs.cluster-api }} + cluster-service: ${{ steps.filter.outputs.cluster-service }} + cluster-status: ${{ steps.filter.outputs.cluster-status }} + cluster-ui: ${{ steps.filter.outputs.cluster-ui }} + steps: + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + cluster-api: + - 'cluster-api/**' + cluster-service: + - 'cluster-service/**' + cluster-status: + - 'cluster-status/**' + cluster-ui: + - 'cluster-ui/**' + python-lint: + needs: changes + if: needs.changes.outputs.cluster-api == 'true' || needs.changes.outputs.cluster-service == 'true' runs-on: ubuntu-latest strategy: fail-fast: false matrix: directory: [cluster-api, cluster-service] - + steps: - uses: actions/checkout@v4 - # Check if directory contains Python files - name: Check for Python files id: check-python run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT + if find "${{ matrix.directory }}" -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> "$GITHUB_ENV" else - echo "has_python_files=false" >> $GITHUB_OUTPUT + echo "has_python_files=false" >> "$GITHUB_ENV" fi - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' + if: env.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - + - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' + if: env.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' + if: env.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" # - name: Run Black - # if: steps.check-python.outputs.has_python_files == 'true' + # if: env.has_python_files == 'true' # working-directory: ${{ matrix.directory }} - # run: | - # black --check . + # run: black --check . # - name: Run isort - # if: steps.check-python.outputs.has_python_files == 'true' + # if: env.has_python_files == 'true' # working-directory: ${{ matrix.directory }} - # run: | - # isort --check-only --diff . + # run: isort --check-only --diff . - + go-lint: + needs: changes + if: needs.changes.outputs.cluster-status == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - # go-lint: - # # needs: changes - # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - - # - name: Set up Go - # uses: actions/setup-go@v5 - # with: - # go-version: '1.22' - # cache: true - - # - name: Install Go tools - # run: | - # go install golang.org/x/tools/cmd/goimports@latest - # go install honnef.co/go/tools/cmd/staticcheck@latest - # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - # echo "$HOME/go/bin" >> $GITHUB_PATH - - # - name: Go Format Check - # working-directory: cluster-status - # run: | - # if [ -n "$(gofmt -l .)" ]; then - # echo "The following files need formatting:" - # gofmt -l . - # echo "Please run 'gofmt -w .' to format your code." - # exit 1 - # fi - - # - name: Go Imports Check - # working-directory: cluster-status - # run: | - # if [ -n "$(goimports -l .)" ]; then - # echo "The following files have incorrect imports:" - # goimports -l . - # echo "Please run 'goimports -w .' to fix imports." - # exit 1 - # fi - - # - name: Run golangci-lint - # working-directory: cluster-status - # run: golangci-lint run --timeout=5m - - # - name: Run staticcheck - # working-directory: cluster-status - # run: staticcheck ./... - - # typescript-lint: - # # needs: changes - # if: needs.changes.outputs.cluster-ui == 'true' - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: '20' - # cache: 'npm' - # cache-dependency-path: cluster-ui/package-lock.json - - # - name: Install Node.js dependencies - # working-directory: cluster-ui - # run: | - # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - # npm ci - - # - name: Lint TypeScript - # working-directory: cluster-ui - # run: | - # npx tsc --noEmit - # npx eslint "**/*.{ts,tsx}" --fix - - # - name: Lint JavaScript - # working-directory: cluster-ui - # run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Install Go tools + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Go Format Check + working-directory: cluster-status + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... + + typescript-lint: + needs: changes + if: needs.changes.outputs.cluster-ui == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json + + - name: Install Node.js dependencies + working-directory: cluster-ui + run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci + + - name: Lint TypeScript + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix From f17ea75aefd888598ec6e6d93b8662ab3ed68b21 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:21:13 +0545 Subject: [PATCH 44/95] fix: pyhton lint --- cluster-status/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 6e68f7d..9996441 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From d865c8225f31217be3db704e731f3265cadc16a9 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:26:07 +0545 Subject: [PATCH 45/95] fix: pyhton lint --- .github/workflows/lint.yaml | 43 +++++++++++++++++++------------------ cluster-status/Dockerfile | 2 +- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4c37e23..bd739c1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -152,10 +152,6 @@ - - - - name: Multi-language Lint on: @@ -184,7 +180,8 @@ jobs: cluster-status: ${{ steps.filter.outputs.cluster-status }} cluster-ui: ${{ steps.filter.outputs.cluster-ui }} steps: - - uses: dorny/paths-filter@v3 + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v2 id: filter with: filters: | @@ -198,55 +195,56 @@ jobs: - 'cluster-ui/**' python-lint: - needs: changes - if: needs.changes.outputs.cluster-api == 'true' || needs.changes.outputs.cluster-service == 'true' runs-on: ubuntu-latest strategy: fail-fast: false matrix: directory: [cluster-api, cluster-service] - + steps: - uses: actions/checkout@v4 + # Check if directory contains Python files - name: Check for Python files id: check-python run: | - if find "${{ matrix.directory }}" -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> "$GITHUB_ENV" + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT else - echo "has_python_files=false" >> "$GITHUB_ENV" + echo "has_python_files=false" >> $GITHUB_OUTPUT fi - name: Set up Python - if: env.has_python_files == 'true' + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - + - name: Install Python linting tools - if: env.has_python_files == 'true' + if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - name: Run Pylint - if: env.has_python_files == 'true' + if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" # - name: Run Black - # if: env.has_python_files == 'true' + # if: steps.check-python.outputs.has_python_files == 'true' # working-directory: ${{ matrix.directory }} - # run: black --check . + # run: | + # black --check . # - name: Run isort - # if: env.has_python_files == 'true' + # if: steps.check-python.outputs.has_python_files == 'true' # working-directory: ${{ matrix.directory }} - # run: isort --check-only --diff . + # run: | + # isort --check-only --diff . go-lint: needs: changes @@ -254,7 +252,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - + - name: Set up Go uses: actions/setup-go@v5 with: @@ -302,7 +300,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - + - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -325,3 +323,6 @@ jobs: - name: Lint JavaScript working-directory: cluster-ui run: npx eslint "**/*.{js,jsx}" --fix + + + diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 9996441..b02307f 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From 142eabd8f1e56b2a2537e5652c5ee82149c7863b Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:33:50 +0545 Subject: [PATCH 46/95] fix: pyhton lint --- .github/workflows/lint.yaml | 28 +++++++++++++++++----------- cluster-status/Dockerfile | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index bd739c1..bf99e58 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -195,17 +195,26 @@ jobs: - 'cluster-ui/**' python-lint: + needs: changes + if: | + needs.changes.outputs.cluster-api == 'true' || + needs.changes.outputs.cluster-service == 'true' runs-on: ubuntu-latest strategy: fail-fast: false matrix: - directory: [cluster-api, cluster-service] + include: + - directory: cluster-api + run: ${{ needs.changes.outputs.cluster-api == 'true' }} + - directory: cluster-service + run: ${{ needs.changes.outputs.cluster-service == 'true' }} steps: - uses: actions/checkout@v4 - + # Check if directory contains Python files - name: Check for Python files + if: matrix.run id: check-python run: | if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then @@ -215,33 +224,33 @@ jobs: fi - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' + if: matrix.run && steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' + if: matrix.run && steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' + if: matrix.run && steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" # - name: Run Black - # if: steps.check-python.outputs.has_python_files == 'true' + # if: matrix.run && steps.check-python.outputs.has_python_files == 'true' # working-directory: ${{ matrix.directory }} # run: | # black --check . # - name: Run isort - # if: steps.check-python.outputs.has_python_files == 'true' + # if: matrix.run && steps.check-python.outputs.has_python_files == 'true' # working-directory: ${{ matrix.directory }} # run: | # isort --check-only --diff . @@ -322,7 +331,4 @@ jobs: - name: Lint JavaScript working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix - - - + run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index b02307f..53d4399 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From 424199be4f046e486a392d41eaa09d32c96f4e73 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:37:27 +0545 Subject: [PATCH 47/95] fix: pyhton lint --- .github/workflows/lint.yaml | 77 ++++++++++++++++++++++--------------- cluster-status/Dockerfile | 2 +- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index bf99e58..bc26926 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -194,66 +194,79 @@ jobs: cluster-ui: - 'cluster-ui/**' - python-lint: + python-lint-api: needs: changes - if: | - needs.changes.outputs.cluster-api == 'true' || - needs.changes.outputs.cluster-service == 'true' + if: needs.changes.outputs.cluster-api == 'true' runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - directory: cluster-api - run: ${{ needs.changes.outputs.cluster-api == 'true' }} - - directory: cluster-service - run: ${{ needs.changes.outputs.cluster-service == 'true' }} - steps: - uses: actions/checkout@v4 - + # Check if directory contains Python files - name: Check for Python files - if: matrix.run id: check-python run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + if find cluster-api -name "*.py" -print -quit | grep -q .; then echo "has_python_files=true" >> $GITHUB_OUTPUT else echo "has_python_files=false" >> $GITHUB_OUTPUT fi - name: Set up Python - if: matrix.run && steps.check-python.outputs.has_python_files == 'true' + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: matrix.run && steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-api run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - name: Run Pylint - if: matrix.run && steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-api run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - # - name: Run Black - # if: matrix.run && steps.check-python.outputs.has_python_files == 'true' - # working-directory: ${{ matrix.directory }} - # run: | - # black --check . - - # - name: Run isort - # if: matrix.run && steps.check-python.outputs.has_python_files == 'true' - # working-directory: ${{ matrix.directory }} - # run: | - # isort --check-only --diff . + python-lint-service: + needs: changes + if: needs.changes.outputs.cluster-service == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # Check if directory contains Python files + - name: Check for Python files + id: check-python + run: | + if find cluster-service -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-service + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-service + run: | + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" go-lint: needs: changes diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 53d4399..cd3576a 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From 509ee6406f3f5e18733e8b72531d0335e0121e4e Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 20 Feb 2025 15:43:20 +0545 Subject: [PATCH 48/95] fix: pyhton lint --- .github/workflows/lint.yaml | 56 +++++-------------------------------- cluster-status/Dockerfile | 2 +- 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index bc26926..5f0a1de 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -156,13 +156,13 @@ name: Multi-language Lint on: push: + branches: + - '**' # Run on all branches paths: - 'cluster-api/**' - 'cluster-service/**' - 'cluster-status/**' - 'cluster-ui/**' - branches: - - '**' # Run on all branches pull_request: paths: - 'cluster-api/**' @@ -196,98 +196,63 @@ jobs: python-lint-api: needs: changes - if: needs.changes.outputs.cluster-api == 'true' + if: fromJSON(needs.changes.outputs.cluster-api) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - # Check if directory contains Python files - - name: Check for Python files - id: check-python - run: | - if find cluster-api -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-api run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-api run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" python-lint-service: needs: changes - if: needs.changes.outputs.cluster-service == 'true' + if: fromJSON(needs.changes.outputs.cluster-service) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - # Check if directory contains Python files - - name: Check for Python files - id: check-python - run: | - if find cluster-service -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-service run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-service run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" go-lint: needs: changes - if: needs.changes.outputs.cluster-status == 'true' + if: fromJSON(needs.changes.outputs.cluster-status) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.22' cache: true - - name: Install Go tools run: | go install golang.org/x/tools/cmd/goimports@latest go install honnef.co/go/tools/cmd/staticcheck@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest echo "$HOME/go/bin" >> $GITHUB_PATH - - name: Go Format Check working-directory: cluster-status run: | @@ -297,7 +262,6 @@ jobs: echo "Please run 'gofmt -w .' to format your code." exit 1 fi - - name: Go Imports Check working-directory: cluster-status run: | @@ -307,41 +271,35 @@ jobs: echo "Please run 'goimports -w .' to fix imports." exit 1 fi - - name: Run golangci-lint working-directory: cluster-status run: golangci-lint run --timeout=5m - - name: Run staticcheck working-directory: cluster-status run: staticcheck ./... typescript-lint: needs: changes - if: needs.changes.outputs.cluster-ui == 'true' + if: fromJSON(needs.changes.outputs.cluster-ui) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' cache-dependency-path: cluster-ui/package-lock.json - - name: Install Node.js dependencies working-directory: cluster-ui run: | npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci - - name: Lint TypeScript working-directory: cluster-ui run: | npx tsc --noEmit npx eslint "**/*.{ts,tsx}" --fix - - name: Lint JavaScript working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + run: npx eslint "**/*.{js,jsx}" --fix diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index cd3576a..59a0a29 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From b05d32118775ded9ac77c64a9179ebc42fa547ec Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 09:30:50 +0545 Subject: [PATCH 49/95] fix: linting --- .github/workflows/lint.yaml | 67 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5f0a1de..0ed77f5 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -172,36 +172,38 @@ on: workflow_dispatch: jobs: - changes: + detect-changes: runs-on: ubuntu-latest outputs: - cluster-api: ${{ steps.filter.outputs.cluster-api }} - cluster-service: ${{ steps.filter.outputs.cluster-service }} - cluster-status: ${{ steps.filter.outputs.cluster-status }} - cluster-ui: ${{ steps.filter.outputs.cluster-ui }} + python-api: ${{ steps.changes.outputs.python-api }} + python-service: ${{ steps.changes.outputs.python-service }} + go-status: ${{ steps.changes.outputs.go-status }} + ts-ui: ${{ steps.changes.outputs.ts-ui }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v2 - id: filter - with: - filters: | - cluster-api: - - 'cluster-api/**' - cluster-service: - - 'cluster-service/**' - cluster-status: - - 'cluster-status/**' - cluster-ui: - - 'cluster-ui/**' + - id: changes + name: Detect file changes + run: | + # Get changed files + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) + else + CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) + fi + + # Check each directory for changes + echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT + echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT + echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT + echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT python-lint-api: - needs: changes - if: fromJSON(needs.changes.outputs.cluster-api) + needs: detect-changes + if: needs.detect-changes.outputs.python-api == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' @@ -216,13 +218,12 @@ jobs: find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" python-lint-service: - needs: changes - if: fromJSON(needs.changes.outputs.cluster-service) + needs: detect-changes + if: needs.detect-changes.outputs.python-service == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' @@ -237,13 +238,12 @@ jobs: find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" go-lint: - needs: changes - if: fromJSON(needs.changes.outputs.cluster-status) + needs: detect-changes + if: needs.detect-changes.outputs.go-status == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - uses: actions/setup-go@v5 with: go-version: '1.22' cache: true @@ -279,13 +279,12 @@ jobs: run: staticcheck ./... typescript-lint: - needs: changes - if: fromJSON(needs.changes.outputs.cluster-ui) + needs: detect-changes + if: needs.detect-changes.outputs.ts-ui == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' @@ -302,4 +301,4 @@ jobs: npx eslint "**/*.{ts,tsx}" --fix - name: Lint JavaScript working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix + run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file From 6bc371ab73493da64dea4970e7d9a18264d862c7 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 09:31:22 +0545 Subject: [PATCH 50/95] fix: linting --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 4e2509e..059b3c1 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -19,4 +19,4 @@ COPY . /app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Install your app -CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file +CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file From 8381374497ede0bd2393b8c11477b58f34b50475 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 09:33:18 +0545 Subject: [PATCH 51/95] fix: linting --- .github/workflows/lint.yaml | 532 ++++++++++++++++++------------------ 1 file changed, 266 insertions(+), 266 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 0ed77f5..dfb2ff0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,168 +1,14 @@ -# name: Multi-language Lint - -# on: -# push: -# paths: -# - 'cluster-api/**' -# - 'cluster-service/**' -# - 'cluster-status/**' -# - 'cluster-ui/**' -# branches: -# - '**' # Run on all branches -# pull_request: -# paths: -# - 'cluster-api/**' -# - 'cluster-service/**' -# - 'cluster-status/**' -# - 'cluster-ui/**' -# workflow_dispatch: - -# jobs: -# python-lint: -# runs-on: ubuntu-latest -# strategy: -# fail-fast: false -# matrix: -# directory: [cluster-api, cluster-service] - -# steps: -# - uses: actions/checkout@v4 - -# # Check if directory contains Python files -# - name: Check for Python files -# id: check-python -# run: | -# if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then -# echo "has_python_files=true" >> $GITHUB_OUTPUT -# else -# echo "has_python_files=false" >> $GITHUB_OUTPUT -# fi - -# - name: Set up Python -# if: steps.check-python.outputs.has_python_files == 'true' -# uses: actions/setup-python@v5 -# with: -# python-version: '3.11' -# cache: 'pip' - -# - name: Install Python linting tools -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: ${{ matrix.directory }} -# run: | -# python -m pip install --upgrade pip -# pip install flake8 black isort pylint - -# - name: Run Pylint -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: ${{ matrix.directory }} -# run: | -# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - -# # - name: Run Black -# # if: steps.check-python.outputs.has_python_files == 'true' -# # working-directory: ${{ matrix.directory }} -# # run: | -# # black --check . - -# # - name: Run isort -# # if: steps.check-python.outputs.has_python_files == 'true' -# # working-directory: ${{ matrix.directory }} -# # run: | -# # isort --check-only --diff . - - - -# # go-lint: -# # # needs: changes -# # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') -# # runs-on: ubuntu-latest -# # steps: -# # - uses: actions/checkout@v4 - -# # - name: Set up Go -# # uses: actions/setup-go@v5 -# # with: -# # go-version: '1.22' -# # cache: true - -# # - name: Install Go tools -# # run: | -# # go install golang.org/x/tools/cmd/goimports@latest -# # go install honnef.co/go/tools/cmd/staticcheck@latest -# # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -# # echo "$HOME/go/bin" >> $GITHUB_PATH - -# # - name: Go Format Check -# # working-directory: cluster-status -# # run: | -# # if [ -n "$(gofmt -l .)" ]; then -# # echo "The following files need formatting:" -# # gofmt -l . -# # echo "Please run 'gofmt -w .' to format your code." -# # exit 1 -# # fi - -# # - name: Go Imports Check -# # working-directory: cluster-status -# # run: | -# # if [ -n "$(goimports -l .)" ]; then -# # echo "The following files have incorrect imports:" -# # goimports -l . -# # echo "Please run 'goimports -w .' to fix imports." -# # exit 1 -# # fi - -# # - name: Run golangci-lint -# # working-directory: cluster-status -# # run: golangci-lint run --timeout=5m - -# # - name: Run staticcheck -# # working-directory: cluster-status -# # run: staticcheck ./... - -# # typescript-lint: -# # # needs: changes -# # if: needs.changes.outputs.cluster-ui == 'true' -# # runs-on: ubuntu-latest -# # steps: -# # - uses: actions/checkout@v4 - -# # - name: Set up Node.js -# # uses: actions/setup-node@v4 -# # with: -# # node-version: '20' -# # cache: 'npm' -# # cache-dependency-path: cluster-ui/package-lock.json - -# # - name: Install Node.js dependencies -# # working-directory: cluster-ui -# # run: | -# # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin -# # npm ci - -# # - name: Lint TypeScript -# # working-directory: cluster-ui -# # run: | -# # npx tsc --noEmit -# # npx eslint "**/*.{ts,tsx}" --fix - -# # - name: Lint JavaScript -# # working-directory: cluster-ui -# # run: npx eslint "**/*.{js,jsx}" --fix - - - name: Multi-language Lint on: push: - branches: - - '**' # Run on all branches paths: - 'cluster-api/**' - 'cluster-service/**' - 'cluster-status/**' - 'cluster-ui/**' + branches: + - '**' # Run on all branches pull_request: paths: - 'cluster-api/**' @@ -172,133 +18,287 @@ on: workflow_dispatch: jobs: - detect-changes: + python-lint: runs-on: ubuntu-latest - outputs: - python-api: ${{ steps.changes.outputs.python-api }} - python-service: ${{ steps.changes.outputs.python-service }} - go-status: ${{ steps.changes.outputs.go-status }} - ts-ui: ${{ steps.changes.outputs.ts-ui }} + strategy: + fail-fast: false + matrix: + directory: [cluster-api, cluster-service] + steps: - uses: actions/checkout@v4 - - id: changes - name: Detect file changes + + # Check if directory contains Python files + - name: Check for Python files + id: check-python run: | - # Get changed files - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT else - CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) + echo "has_python_files=false" >> $GITHUB_OUTPUT fi - # Check each directory for changes - echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT - echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT - echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT - echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT - - python-lint-api: - needs: detect-changes - if: needs.detect-changes.outputs.python-api == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' + uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' + - name: Install Python linting tools - working-directory: cluster-api + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint - working-directory: cluster-api - run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - python-lint-service: - needs: detect-changes - if: needs.detect-changes.outputs.python-service == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - name: Install Python linting tools - working-directory: cluster-service - run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - name: Run Pylint - working-directory: cluster-service + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - go-lint: - needs: detect-changes - if: needs.detect-changes.outputs.go-status == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true - - name: Install Go tools - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH - - name: Go Format Check - working-directory: cluster-status - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi - - name: Go Imports Check - working-directory: cluster-status - run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 - fi - - name: Run golangci-lint - working-directory: cluster-status - run: golangci-lint run --timeout=5m - - name: Run staticcheck - working-directory: cluster-status - run: staticcheck ./... + # - name: Run Black + # if: steps.check-python.outputs.has_python_files == 'true' + # working-directory: ${{ matrix.directory }} + # run: | + # black --check . - typescript-lint: - needs: detect-changes - if: needs.detect-changes.outputs.ts-ui == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json - - name: Install Node.js dependencies - working-directory: cluster-ui - run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci - - name: Lint TypeScript - working-directory: cluster-ui - run: | - npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + # - name: Run isort + # if: steps.check-python.outputs.has_python_files == 'true' + # working-directory: ${{ matrix.directory }} + # run: | + # isort --check-only --diff . + + + + # go-lint: + # # needs: changes + # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + + # - name: Set up Go + # uses: actions/setup-go@v5 + # with: + # go-version: '1.22' + # cache: true + + # - name: Install Go tools + # run: | + # go install golang.org/x/tools/cmd/goimports@latest + # go install honnef.co/go/tools/cmd/staticcheck@latest + # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + # echo "$HOME/go/bin" >> $GITHUB_PATH + + # - name: Go Format Check + # working-directory: cluster-status + # run: | + # if [ -n "$(gofmt -l .)" ]; then + # echo "The following files need formatting:" + # gofmt -l . + # echo "Please run 'gofmt -w .' to format your code." + # exit 1 + # fi + + # - name: Go Imports Check + # working-directory: cluster-status + # run: | + # if [ -n "$(goimports -l .)" ]; then + # echo "The following files have incorrect imports:" + # goimports -l . + # echo "Please run 'goimports -w .' to fix imports." + # exit 1 + # fi + + # - name: Run golangci-lint + # working-directory: cluster-status + # run: golangci-lint run --timeout=5m + + # - name: Run staticcheck + # working-directory: cluster-status + # run: staticcheck ./... + + # typescript-lint: + # # needs: changes + # if: needs.changes.outputs.cluster-ui == 'true' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + + # - name: Set up Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: '20' + # cache: 'npm' + # cache-dependency-path: cluster-ui/package-lock.json + + # - name: Install Node.js dependencies + # working-directory: cluster-ui + # run: | + # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + # npm ci + + # - name: Lint TypeScript + # working-directory: cluster-ui + # run: | + # npx tsc --noEmit + # npx eslint "**/*.{ts,tsx}" --fix + + # - name: Lint JavaScript + # working-directory: cluster-ui + # run: npx eslint "**/*.{js,jsx}" --fix + + + +# name: Multi-language Lint + +# on: +# push: +# branches: +# - '**' # Run on all branches +# paths: +# - 'cluster-api/**' +# - 'cluster-service/**' +# - 'cluster-status/**' +# - 'cluster-ui/**' +# pull_request: +# paths: +# - 'cluster-api/**' +# - 'cluster-service/**' +# - 'cluster-status/**' +# - 'cluster-ui/**' +# workflow_dispatch: + +# jobs: +# detect-changes: +# runs-on: ubuntu-latest +# outputs: +# python-api: ${{ steps.changes.outputs.python-api }} +# python-service: ${{ steps.changes.outputs.python-service }} +# go-status: ${{ steps.changes.outputs.go-status }} +# ts-ui: ${{ steps.changes.outputs.ts-ui }} +# steps: +# - uses: actions/checkout@v4 +# - id: changes +# name: Detect file changes +# run: | +# # Get changed files +# if [[ "${{ github.event_name }}" == "pull_request" ]]; then +# CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) +# else +# CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) +# fi + +# # Check each directory for changes +# echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT + +# python-lint-api: +# needs: detect-changes +# if: needs.detect-changes.outputs.python-api == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-python@v5 +# with: +# python-version: '3.11' +# cache: 'pip' +# - name: Install Python linting tools +# working-directory: cluster-api +# run: | +# python -m pip install --upgrade pip +# pip install flake8 black isort pylint +# - name: Run Pylint +# working-directory: cluster-api +# run: | +# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + +# python-lint-service: +# needs: detect-changes +# if: needs.detect-changes.outputs.python-service == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-python@v5 +# with: +# python-version: '3.11' +# cache: 'pip' +# - name: Install Python linting tools +# working-directory: cluster-service +# run: | +# python -m pip install --upgrade pip +# pip install flake8 black isort pylint +# - name: Run Pylint +# working-directory: cluster-service +# run: | +# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + +# go-lint: +# needs: detect-changes +# if: needs.detect-changes.outputs.go-status == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-go@v5 +# with: +# go-version: '1.22' +# cache: true +# - name: Install Go tools +# run: | +# go install golang.org/x/tools/cmd/goimports@latest +# go install honnef.co/go/tools/cmd/staticcheck@latest +# go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest +# echo "$HOME/go/bin" >> $GITHUB_PATH +# - name: Go Format Check +# working-directory: cluster-status +# run: | +# if [ -n "$(gofmt -l .)" ]; then +# echo "The following files need formatting:" +# gofmt -l . +# echo "Please run 'gofmt -w .' to format your code." +# exit 1 +# fi +# - name: Go Imports Check +# working-directory: cluster-status +# run: | +# if [ -n "$(goimports -l .)" ]; then +# echo "The following files have incorrect imports:" +# goimports -l . +# echo "Please run 'goimports -w .' to fix imports." +# exit 1 +# fi +# - name: Run golangci-lint +# working-directory: cluster-status +# run: golangci-lint run --timeout=5m +# - name: Run staticcheck +# working-directory: cluster-status +# run: staticcheck ./... + +# typescript-lint: +# needs: detect-changes +# if: needs.detect-changes.outputs.ts-ui == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-node@v4 +# with: +# node-version: '20' +# cache: 'npm' +# cache-dependency-path: cluster-ui/package-lock.json +# - name: Install Node.js dependencies +# working-directory: cluster-ui +# run: | +# npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin +# npm ci +# - name: Lint TypeScript +# working-directory: cluster-ui +# run: | +# npx tsc --noEmit +# npx eslint "**/*.{ts,tsx}" --fix +# - name: Lint JavaScript +# working-directory: cluster-ui +# run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file From 6e2f083cf123b4777f95e488c4c91fd8bd4e6995 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 09:33:42 +0545 Subject: [PATCH 52/95] fix: linting --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 059b3c1..ce496d4 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -19,4 +19,4 @@ COPY . /app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Install your app -CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file +CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file From 6ba5556f72bcd7b5b7c6e506f806618ffe5d24e4 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 09:55:54 +0545 Subject: [PATCH 53/95] fix: linting --- .github/workflows/lint.yaml | 170 ++++++++++++++++++++---------------- cluster-status/Dockerfile | 2 +- 2 files changed, 95 insertions(+), 77 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index dfb2ff0..2b53ec1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,7 +8,7 @@ on: - 'cluster-status/**' - 'cluster-ui/**' branches: - - '**' # Run on all branches + - '**' pull_request: paths: - 'cluster-api/**' @@ -72,85 +72,103 @@ jobs: - # go-lint: - # # needs: changes - # if: needs.changes.outputs.cluster-status == 'true' && !contains(github.event.head_commit.modified, '*.py') - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 + go-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - # - name: Set up Go - # uses: actions/setup-go@v5 - # with: - # go-version: '1.22' - # cache: true - - # - name: Install Go tools - # run: | - # go install golang.org/x/tools/cmd/goimports@latest - # go install honnef.co/go/tools/cmd/staticcheck@latest - # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - # echo "$HOME/go/bin" >> $GITHUB_PATH - - # - name: Go Format Check - # working-directory: cluster-status - # run: | - # if [ -n "$(gofmt -l .)" ]; then - # echo "The following files need formatting:" - # gofmt -l . - # echo "Please run 'gofmt -w .' to format your code." - # exit 1 - # fi - - # - name: Go Imports Check - # working-directory: cluster-status - # run: | - # if [ -n "$(goimports -l .)" ]; then - # echo "The following files have incorrect imports:" - # goimports -l . - # echo "Please run 'goimports -w .' to fix imports." - # exit 1 - # fi - - # - name: Run golangci-lint - # working-directory: cluster-status - # run: golangci-lint run --timeout=5m - - # - name: Run staticcheck - # working-directory: cluster-status - # run: staticcheck ./... - - # typescript-lint: - # # needs: changes - # if: needs.changes.outputs.cluster-ui == 'true' - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Install Go tools + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Go Format Check + working-directory: cluster-status + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... + + typescript-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - # - name: Set up Node.js - # uses: actions/setup-node@v4 - # with: - # node-version: '20' - # cache: 'npm' - # cache-dependency-path: cluster-ui/package-lock.json - - # - name: Install Node.js dependencies - # working-directory: cluster-ui - # run: | - # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - # npm ci - - # - name: Lint TypeScript - # working-directory: cluster-ui - # run: | - # npx tsc --noEmit - # npx eslint "**/*.{ts,tsx}" --fix - - # - name: Lint JavaScript - # working-directory: cluster-ui - # run: npx eslint "**/*.{js,jsx}" --fix + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json + + - name: Install Node.js dependencies + working-directory: cluster-ui + run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci + + - name: Lint TypeScript + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix + + + + + + + + + + + + + + + + + + + + + + # name: Multi-language Lint diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 59a0a29..b02307f 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From a2dc634e5337cac4cfa13671cd8bcf02ec8f76d9 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:13:18 +0545 Subject: [PATCH 54/95] fix: linting --- .github/workflows/lint.yaml | 64 ++++++++++++++++++++++++++++--------- cluster-api/Dockerfile | 2 +- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2b53ec1..b25cb62 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -28,11 +28,17 @@ jobs: steps: - uses: actions/checkout@v4 + # Get the list of changed files + - name: Get changed files + id: changed-files + run: | + echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT + # Check if directory contains Python files - name: Check for Python files id: check-python run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + if echo "${{ steps.changed-files.outputs.changed_files }}" | grep -q "${{ matrix.directory }}.*\.py"; then echo "has_python_files=true" >> $GITHUB_OUTPUT else echo "has_python_files=false" >> $GITHUB_OUTPUT @@ -58,32 +64,36 @@ jobs: run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - # - name: Run Black - # if: steps.check-python.outputs.has_python_files == 'true' - # working-directory: ${{ matrix.directory }} - # run: | - # black --check . - - # - name: Run isort - # if: steps.check-python.outputs.has_python_files == 'true' - # working-directory: ${{ matrix.directory }} - # run: | - # isort --check-only --diff . - - - go-lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + # Get the list of changed files + - name: Get changed files + id: changed-files + run: | + echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT + + # Check if directory contains Go files + - name: Check for Go files + id: check-go + run: | + if echo "${{ steps.changed-files.outputs.changed_files }}" | grep -q "cluster-status.*\.go"; then + echo "has_go_files=true" >> $GITHUB_OUTPUT + else + echo "has_go_files=false" >> $GITHUB_OUTPUT + fi + - name: Set up Go + if: steps.check-go.outputs.has_go_files == 'true' uses: actions/setup-go@v5 with: go-version: '1.22' cache: true - name: Install Go tools + if: steps.check-go.outputs.has_go_files == 'true' run: | go install golang.org/x/tools/cmd/goimports@latest go install honnef.co/go/tools/cmd/staticcheck@latest @@ -91,6 +101,7 @@ jobs: echo "$HOME/go/bin" >> $GITHUB_PATH - name: Go Format Check + if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: | if [ -n "$(gofmt -l .)" ]; then @@ -101,6 +112,7 @@ jobs: fi - name: Go Imports Check + if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: | if [ -n "$(goimports -l .)" ]; then @@ -111,10 +123,12 @@ jobs: fi - name: Run golangci-lint + if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: golangci-lint run --timeout=5m - name: Run staticcheck + if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: staticcheck ./... @@ -123,7 +137,24 @@ jobs: steps: - uses: actions/checkout@v4 + # Get the list of changed files + - name: Get changed files + id: changed-files + run: | + echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT + + # Check if directory contains TypeScript/JavaScript files + - name: Check for TypeScript/JavaScript files + id: check-ts + run: | + if echo "${{ steps.changed-files.outputs.changed_files }}" | grep -q "cluster-ui.*\.\(ts\|tsx\|js\|jsx\)"; then + echo "has_ts_files=true" >> $GITHUB_OUTPUT + else + echo "has_ts_files=false" >> $GITHUB_OUTPUT + fi + - name: Set up Node.js + if: steps.check-ts.outputs.has_ts_files == 'true' uses: actions/setup-node@v4 with: node-version: '20' @@ -131,18 +162,21 @@ jobs: cache-dependency-path: cluster-ui/package-lock.json - name: Install Node.js dependencies + if: steps.check-ts.outputs.has_ts_files == 'true' working-directory: cluster-ui run: | npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci - name: Lint TypeScript + if: steps.check-ts.outputs.has_ts_files == 'true' working-directory: cluster-ui run: | npx tsc --noEmit npx eslint "**/*.{ts,tsx}" --fix - name: Lint JavaScript + if: steps.check-ts.outputs.has_ts_files == 'true' working-directory: cluster-ui run: npx eslint "**/*.{js,jsx}" --fix diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index ce496d4..bb4601a 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -10,7 +10,7 @@ ENV PYTHONUNBUFFERED=1 # Install pip requirements COPY requirements.txt . -RUN python -m pip install -r requirements.txt +RUN python -m pip install -r requirements.txt WORKDIR /app COPY . /app From 98a8d80c19330fe9e31b0aff0b1677ae9864ca42 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:14:51 +0545 Subject: [PATCH 55/95] fix: linting --- cluster-ui/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-ui/Dockerfile b/cluster-ui/Dockerfile index c555bbf..8e73e1c 100644 --- a/cluster-ui/Dockerfile +++ b/cluster-ui/Dockerfile @@ -22,4 +22,4 @@ RUN npm run build EXPOSE 3000 # 7. Run the app -CMD ["npm", "run", "preview"] +CMD ["npm", "run", "preview"] From 69de47d52686937b5129fe483eca4f7f518c98bc Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:16:28 +0545 Subject: [PATCH 56/95] fix: linting --- .github/workflows/lint.yaml | 64 +++++++++---------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b25cb62..2b53ec1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -28,17 +28,11 @@ jobs: steps: - uses: actions/checkout@v4 - # Get the list of changed files - - name: Get changed files - id: changed-files - run: | - echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT - # Check if directory contains Python files - name: Check for Python files id: check-python run: | - if echo "${{ steps.changed-files.outputs.changed_files }}" | grep -q "${{ matrix.directory }}.*\.py"; then + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then echo "has_python_files=true" >> $GITHUB_OUTPUT else echo "has_python_files=false" >> $GITHUB_OUTPUT @@ -64,36 +58,32 @@ jobs: run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + # - name: Run Black + # if: steps.check-python.outputs.has_python_files == 'true' + # working-directory: ${{ matrix.directory }} + # run: | + # black --check . + + # - name: Run isort + # if: steps.check-python.outputs.has_python_files == 'true' + # working-directory: ${{ matrix.directory }} + # run: | + # isort --check-only --diff . + + + go-lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # Get the list of changed files - - name: Get changed files - id: changed-files - run: | - echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT - - # Check if directory contains Go files - - name: Check for Go files - id: check-go - run: | - if echo "${{ steps.changed-files.outputs.changed_files }}" | grep -q "cluster-status.*\.go"; then - echo "has_go_files=true" >> $GITHUB_OUTPUT - else - echo "has_go_files=false" >> $GITHUB_OUTPUT - fi - - name: Set up Go - if: steps.check-go.outputs.has_go_files == 'true' uses: actions/setup-go@v5 with: go-version: '1.22' cache: true - name: Install Go tools - if: steps.check-go.outputs.has_go_files == 'true' run: | go install golang.org/x/tools/cmd/goimports@latest go install honnef.co/go/tools/cmd/staticcheck@latest @@ -101,7 +91,6 @@ jobs: echo "$HOME/go/bin" >> $GITHUB_PATH - name: Go Format Check - if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: | if [ -n "$(gofmt -l .)" ]; then @@ -112,7 +101,6 @@ jobs: fi - name: Go Imports Check - if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: | if [ -n "$(goimports -l .)" ]; then @@ -123,12 +111,10 @@ jobs: fi - name: Run golangci-lint - if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: golangci-lint run --timeout=5m - name: Run staticcheck - if: steps.check-go.outputs.has_go_files == 'true' working-directory: cluster-status run: staticcheck ./... @@ -137,24 +123,7 @@ jobs: steps: - uses: actions/checkout@v4 - # Get the list of changed files - - name: Get changed files - id: changed-files - run: | - echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT - - # Check if directory contains TypeScript/JavaScript files - - name: Check for TypeScript/JavaScript files - id: check-ts - run: | - if echo "${{ steps.changed-files.outputs.changed_files }}" | grep -q "cluster-ui.*\.\(ts\|tsx\|js\|jsx\)"; then - echo "has_ts_files=true" >> $GITHUB_OUTPUT - else - echo "has_ts_files=false" >> $GITHUB_OUTPUT - fi - - name: Set up Node.js - if: steps.check-ts.outputs.has_ts_files == 'true' uses: actions/setup-node@v4 with: node-version: '20' @@ -162,21 +131,18 @@ jobs: cache-dependency-path: cluster-ui/package-lock.json - name: Install Node.js dependencies - if: steps.check-ts.outputs.has_ts_files == 'true' working-directory: cluster-ui run: | npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci - name: Lint TypeScript - if: steps.check-ts.outputs.has_ts_files == 'true' working-directory: cluster-ui run: | npx tsc --noEmit npx eslint "**/*.{ts,tsx}" --fix - name: Lint JavaScript - if: steps.check-ts.outputs.has_ts_files == 'true' working-directory: cluster-ui run: npx eslint "**/*.{js,jsx}" --fix From 927f759fcf4036887e8cf1cf8b6db4b64301fd6b Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:20:34 +0545 Subject: [PATCH 57/95] fix: linting --- cluster-status/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index b02307f..53d4399 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From ff0e82e47a5aaae9d8da6e02e1d2ae52bb5dd15b Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:26:24 +0545 Subject: [PATCH 58/95] fix: linting --- .github/workflows/lint.yaml | 56 ++++++++++++++++++++++--------------- cluster-status/Dockerfile | 2 +- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2b53ec1..171edc1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,22 +3,44 @@ name: Multi-language Lint on: push: paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' + - 'cluster-api/**/*.py' + - 'cluster-service/**/*.py' + - 'cluster-status/**/*.go' + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' branches: - '**' pull_request: paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' + - 'cluster-api/**/*.py' + - 'cluster-service/**/*.py' + - 'cluster-status/**/*.go' + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' workflow_dispatch: jobs: + changes: + runs-on: ubuntu-latest + outputs: + python: ${{ steps.filter.outputs.python }} + go: ${{ steps.filter.outputs.go }} + typescript: ${{ steps.filter.outputs.typescript }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + python: + - 'cluster-api/**/*.py' + - 'cluster-service/**/*.py' + go: + - 'cluster-status/**/*.go' + typescript: + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + python-lint: + needs: changes + if: needs.changes.outputs.python == 'true' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest strategy: fail-fast: false @@ -58,21 +80,9 @@ jobs: run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - # - name: Run Black - # if: steps.check-python.outputs.has_python_files == 'true' - # working-directory: ${{ matrix.directory }} - # run: | - # black --check . - - # - name: Run isort - # if: steps.check-python.outputs.has_python_files == 'true' - # working-directory: ${{ matrix.directory }} - # run: | - # isort --check-only --diff . - - - go-lint: + needs: changes + if: needs.changes.outputs.go == 'true' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -119,6 +129,8 @@ jobs: run: staticcheck ./... typescript-lint: + needs: changes + if: needs.changes.outputs.typescript == 'true' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 53d4399..cd3576a 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From fe93dea3cf75ed0fb75e1c5e046092707c8bfb4c Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:27:02 +0545 Subject: [PATCH 59/95] fix: linting --- cluster-status/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index cd3576a..afa6d89 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -8,5 +8,5 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app -COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +COPY --from=builder /app/main . +CMD ["./main"] \ No newline at end of file From f155488c4152daeb98eb4df819fcd35f5eb35221 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:27:48 +0545 Subject: [PATCH 60/95] fix: lint --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 171edc1..d34b9e0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -6,7 +6,7 @@ on: - 'cluster-api/**/*.py' - 'cluster-service/**/*.py' - 'cluster-status/**/*.go' - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' branches: - '**' pull_request: From 56bee14a9d221574cb1a82b96a5ca7ad96d446d9 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:31:06 +0545 Subject: [PATCH 61/95] fix: lint --- .github/workflows/lint.yaml | 61 +++++++++++++++++++++---------------- cluster-status/Dockerfile | 2 +- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d34b9e0..3caaf87 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,44 +3,49 @@ name: Multi-language Lint on: push: paths: - - 'cluster-api/**/*.py' - - 'cluster-service/**/*.py' - - 'cluster-status/**/*.go' - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' branches: - '**' pull_request: paths: - - 'cluster-api/**/*.py' - - 'cluster-service/**/*.py' - - 'cluster-status/**/*.go' - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' workflow_dispatch: jobs: - changes: + changed_files: runs-on: ubuntu-latest outputs: - python: ${{ steps.filter.outputs.python }} - go: ${{ steps.filter.outputs.go }} - typescript: ${{ steps.filter.outputs.typescript }} + python_api: ${{ steps.changes.outputs.cluster-api }} + python_service: ${{ steps.changes.outputs.cluster-service }} + go: ${{ steps.changes.outputs.cluster-status }} + typescript: ${{ steps.changes.outputs.cluster-ui }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 - id: filter + id: changes with: filters: | - python: - - 'cluster-api/**/*.py' - - 'cluster-service/**/*.py' - go: - - 'cluster-status/**/*.go' - typescript: - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + cluster-api: + - 'cluster-api/**' + cluster-service: + - 'cluster-service/**' + cluster-status: + - 'cluster-status/**' + cluster-ui: + - 'cluster-ui/**' python-lint: - needs: changes - if: needs.changes.outputs.python == 'true' || github.event_name == 'workflow_dispatch' + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.python_api == 'true' || + needs.changed_files.outputs.python_service == 'true' runs-on: ubuntu-latest strategy: fail-fast: false @@ -81,8 +86,10 @@ jobs: find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" go-lint: - needs: changes - if: needs.changes.outputs.go == 'true' || github.event_name == 'workflow_dispatch' + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.go == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -129,8 +136,10 @@ jobs: run: staticcheck ./... typescript-lint: - needs: changes - if: needs.changes.outputs.typescript == 'true' || github.event_name == 'workflow_dispatch' + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.typescript == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index afa6d89..523ff05 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From 112d3aa97fe9a87dda02c776a51ed2ade888f802 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:38:58 +0545 Subject: [PATCH 62/95] fix: lint --- .github/workflows/lint.yaml | 60 ++++++++++++++++--------------------- cluster-api/Dockerfile | 2 +- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3caaf87..e57e6a7 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,60 +2,54 @@ name: Multi-language Lint on: push: - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' branches: - - '**' + - '**' pull_request: - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' workflow_dispatch: jobs: - changed_files: + changes: runs-on: ubuntu-latest + permissions: + pull-requests: read + contents: read outputs: - python_api: ${{ steps.changes.outputs.cluster-api }} - python_service: ${{ steps.changes.outputs.cluster-service }} - go: ${{ steps.changes.outputs.cluster-status }} - typescript: ${{ steps.changes.outputs.cluster-ui }} + python_api: ${{ steps.filter.outputs.python_api }} + python_service: ${{ steps.filter.outputs.python_service }} + go: ${{ steps.filter.outputs.go }} + typescript: ${{ steps.filter.outputs.typescript }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 - id: changes + id: filter with: filters: | - cluster-api: + python_api: - 'cluster-api/**' - cluster-service: + python_service: - 'cluster-service/**' - cluster-status: + go: - 'cluster-status/**' - cluster-ui: + typescript: - 'cluster-ui/**' python-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.python_api == 'true' || - needs.changed_files.outputs.python_service == 'true' + needs: changes + if: ${{ needs.changes.outputs.python_api == 'true' || needs.changes.outputs.python_service == 'true' || github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: directory: [cluster-api, cluster-service] + exclude: + - directory: cluster-api + if: ${{ needs.changes.outputs.python_api != 'true' && github.event_name != 'workflow_dispatch' }} + - directory: cluster-service + if: ${{ needs.changes.outputs.python_service != 'true' && github.event_name != 'workflow_dispatch' }} steps: - uses: actions/checkout@v4 - # Check if directory contains Python files - name: Check for Python files id: check-python run: | @@ -86,10 +80,8 @@ jobs: find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" go-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.go == 'true' + needs: changes + if: ${{ needs.changes.outputs.go == 'true' || github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -136,10 +128,8 @@ jobs: run: staticcheck ./... typescript-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.typescript == 'true' + needs: changes + if: ${{ needs.changes.outputs.typescript == 'true' || github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index bb4601a..167a388 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -12,7 +12,7 @@ ENV PYTHONUNBUFFERED=1 COPY requirements.txt . RUN python -m pip install -r requirements.txt -WORKDIR /app +WORKDIR /app COPY . /app # Install your app From d7aaedbef7193c38c6d38082eb2b07bced1746d9 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Fri, 21 Feb 2025 11:40:31 +0545 Subject: [PATCH 63/95] fix: lint --- .github/workflows/lint.yaml | 60 +++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e57e6a7..3caaf87 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,54 +2,60 @@ name: Multi-language Lint on: push: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' branches: - - '**' + - '**' pull_request: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' workflow_dispatch: jobs: - changes: + changed_files: runs-on: ubuntu-latest - permissions: - pull-requests: read - contents: read outputs: - python_api: ${{ steps.filter.outputs.python_api }} - python_service: ${{ steps.filter.outputs.python_service }} - go: ${{ steps.filter.outputs.go }} - typescript: ${{ steps.filter.outputs.typescript }} + python_api: ${{ steps.changes.outputs.cluster-api }} + python_service: ${{ steps.changes.outputs.cluster-service }} + go: ${{ steps.changes.outputs.cluster-status }} + typescript: ${{ steps.changes.outputs.cluster-ui }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 - id: filter + id: changes with: filters: | - python_api: + cluster-api: - 'cluster-api/**' - python_service: + cluster-service: - 'cluster-service/**' - go: + cluster-status: - 'cluster-status/**' - typescript: + cluster-ui: - 'cluster-ui/**' python-lint: - needs: changes - if: ${{ needs.changes.outputs.python_api == 'true' || needs.changes.outputs.python_service == 'true' || github.event_name == 'workflow_dispatch' }} + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.python_api == 'true' || + needs.changed_files.outputs.python_service == 'true' runs-on: ubuntu-latest strategy: fail-fast: false matrix: directory: [cluster-api, cluster-service] - exclude: - - directory: cluster-api - if: ${{ needs.changes.outputs.python_api != 'true' && github.event_name != 'workflow_dispatch' }} - - directory: cluster-service - if: ${{ needs.changes.outputs.python_service != 'true' && github.event_name != 'workflow_dispatch' }} steps: - uses: actions/checkout@v4 + # Check if directory contains Python files - name: Check for Python files id: check-python run: | @@ -80,8 +86,10 @@ jobs: find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" go-lint: - needs: changes - if: ${{ needs.changes.outputs.go == 'true' || github.event_name == 'workflow_dispatch' }} + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.go == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -128,8 +136,10 @@ jobs: run: staticcheck ./... typescript-lint: - needs: changes - if: ${{ needs.changes.outputs.typescript == 'true' || github.event_name == 'workflow_dispatch' }} + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.typescript == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 9c8e61a7e9f517c34efbb128b5b54833aeb68e0b Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 11:26:27 +0545 Subject: [PATCH 64/95] fix: lint --- .github/workflows/lint.yaml | 195 ++++++++++++++++++------------------ 1 file changed, 96 insertions(+), 99 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3caaf87..b23f521 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,169 +3,166 @@ name: Multi-language Lint on: push: paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' + - 'cluster-api/**/*.py' + - 'cluster-api/requirements*.txt' + - 'cluster-service/**/*.py' + - 'cluster-service/requirements*.txt' + - 'cluster-status/**/*.go' + - 'cluster-status/go.mod' + - 'cluster-status/go.sum' + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + - 'cluster-ui/package*.json' branches: - - '**' + - '**' pull_request: paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' + - 'cluster-api/**/*.py' + - 'cluster-api/requirements*.txt' + - 'cluster-service/**/*.py' + - 'cluster-service/requirements*.txt' + - 'cluster-status/**/*.go' + - 'cluster-status/go.mod' + - 'cluster-status/go.sum' + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + - 'cluster-ui/package*.json' workflow_dispatch: jobs: changed_files: runs-on: ubuntu-latest outputs: - python_api: ${{ steps.changes.outputs.cluster-api }} - python_service: ${{ steps.changes.outputs.cluster-service }} - go: ${{ steps.changes.outputs.cluster-status }} - typescript: ${{ steps.changes.outputs.cluster-ui }} + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 id: changes with: filters: | - cluster-api: - - 'cluster-api/**' - cluster-service: - - 'cluster-service/**' - cluster-status: - - 'cluster-status/**' - cluster-ui: - - 'cluster-ui/**' - - python-lint: + python_api: + - 'cluster-api/**/*.py' + - 'cluster-api/requirements*.txt' + python_service: + - 'cluster-service/**/*.py' + - 'cluster-service/requirements*.txt' + go: + - 'cluster-status/**/*.go' + - 'cluster-status/go.mod' + - 'cluster-status/go.sum' + typescript: + - 'cluster-ui/**/*.{ts,tsx,js,jsx}' + - 'cluster-ui/package*.json' + + - id: set-matrix + run: | + matrix="{\"include\":[" + if [[ "${{ steps.changes.outputs.python_api }}" == "true" ]]; then + matrix="$matrix{\"language\":\"python\",\"directory\":\"cluster-api\"}," + fi + if [[ "${{ steps.changes.outputs.python_service }}" == "true" ]]; then + matrix="$matrix{\"language\":\"python\",\"directory\":\"cluster-service\"}," + fi + if [[ "${{ steps.changes.outputs.go }}" == "true" ]]; then + matrix="$matrix{\"language\":\"go\",\"directory\":\"cluster-status\"}," + fi + if [[ "${{ steps.changes.outputs.typescript }}" == "true" ]]; then + matrix="$matrix{\"language\":\"typescript\",\"directory\":\"cluster-ui\"}," + fi + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + matrix="{\"include\":[{\"language\":\"python\",\"directory\":\"cluster-api\"},{\"language\":\"python\",\"directory\":\"cluster-service\"},{\"language\":\"go\",\"directory\":\"cluster-status\"},{\"language\":\"typescript\",\"directory\":\"cluster-ui\"}]}" + else + matrix="${matrix%,}]}" + fi + echo "matrix=$matrix" >> $GITHUB_OUTPUT + + lint: needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.python_api == 'true' || - needs.changed_files.outputs.python_service == 'true' + if: needs.changed_files.outputs.matrix != '{"include":[]}' runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - directory: [cluster-api, cluster-service] + matrix: ${{fromJson(needs.changed_files.outputs.matrix)}} steps: - uses: actions/checkout@v4 - # Check if directory contains Python files - - name: Check for Python files - id: check-python - run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - + # Python setup and lint - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' + if: matrix.language == 'python' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - + cache-dependency-path: | + ${{ matrix.directory }}/requirements*.txt + - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' + if: matrix.language == 'python' working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' + - name: Run Python linters + if: matrix.language == 'python' working-directory: ${{ matrix.directory }} run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + black --check . + isort --check-only --diff . + flake8 . + find . -type f -name "*.py" -not -path "*/\.*" -not -path "*/venv/*" -exec pylint {} + - go-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.go == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - + # Go setup and lint - name: Set up Go + if: matrix.language == 'go' uses: actions/setup-go@v5 with: go-version: '1.22' cache: true + cache-dependency-path: ${{ matrix.directory }}/go.sum - name: Install Go tools + if: matrix.language == 'go' run: | go install golang.org/x/tools/cmd/goimports@latest go install honnef.co/go/tools/cmd/staticcheck@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest echo "$HOME/go/bin" >> $GITHUB_PATH - - name: Go Format Check - working-directory: cluster-status - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi - - - name: Go Imports Check - working-directory: cluster-status + - name: Run Go linters + if: matrix.language == 'go' + working-directory: ${{ matrix.directory }} run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 - fi - - - name: Run golangci-lint - working-directory: cluster-status - run: golangci-lint run --timeout=5m - - - name: Run staticcheck - working-directory: cluster-status - run: staticcheck ./... + gofmt -d -e . && test -z "$(gofmt -l .)" + goimports -d -e . && test -z "$(goimports -l .)" + go vet ./... + golangci-lint run --timeout=5m + staticcheck ./... - typescript-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.typescript == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - + # TypeScript setup and lint - name: Set up Node.js + if: matrix.language == 'typescript' uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json + cache-dependency-path: ${{ matrix.directory }}/package-lock.json - name: Install Node.js dependencies - working-directory: cluster-ui + if: matrix.language == 'typescript' + working-directory: ${{ matrix.directory }} run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci + npm install -g typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - - name: Lint TypeScript - working-directory: cluster-ui + - name: Run TypeScript/JavaScript linters + if: matrix.language == 'typescript' + working-directory: ${{ matrix.directory }} run: | npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix + npx eslint . --ext .ts,.tsx,.js,.jsx --max-warnings 0 From 8dea1315860c77b038f9863e66d6d0ceb6bd4119 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 11:26:53 +0545 Subject: [PATCH 65/95] fix: lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 167a388..993764f 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -14,7 +14,7 @@ RUN python -m pip install -r requirements.txt WORKDIR /app COPY . /app - + # Install your app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt From d3f190f3397f14330b3b009eb2bff4f3cc72d62e Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 11:28:03 +0545 Subject: [PATCH 66/95] fix: lint --- .github/workflows/lint.yaml | 195 ++++++++++++++++++------------------ cluster-api/Dockerfile | 2 +- 2 files changed, 100 insertions(+), 97 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b23f521..3caaf87 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,166 +3,169 @@ name: Multi-language Lint on: push: paths: - - 'cluster-api/**/*.py' - - 'cluster-api/requirements*.txt' - - 'cluster-service/**/*.py' - - 'cluster-service/requirements*.txt' - - 'cluster-status/**/*.go' - - 'cluster-status/go.mod' - - 'cluster-status/go.sum' - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' - - 'cluster-ui/package*.json' + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' branches: - - '**' + - '**' pull_request: paths: - - 'cluster-api/**/*.py' - - 'cluster-api/requirements*.txt' - - 'cluster-service/**/*.py' - - 'cluster-service/requirements*.txt' - - 'cluster-status/**/*.go' - - 'cluster-status/go.mod' - - 'cluster-status/go.sum' - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' - - 'cluster-ui/package*.json' + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' workflow_dispatch: jobs: changed_files: runs-on: ubuntu-latest outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} + python_api: ${{ steps.changes.outputs.cluster-api }} + python_service: ${{ steps.changes.outputs.cluster-service }} + go: ${{ steps.changes.outputs.cluster-status }} + typescript: ${{ steps.changes.outputs.cluster-ui }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 id: changes with: filters: | - python_api: - - 'cluster-api/**/*.py' - - 'cluster-api/requirements*.txt' - python_service: - - 'cluster-service/**/*.py' - - 'cluster-service/requirements*.txt' - go: - - 'cluster-status/**/*.go' - - 'cluster-status/go.mod' - - 'cluster-status/go.sum' - typescript: - - 'cluster-ui/**/*.{ts,tsx,js,jsx}' - - 'cluster-ui/package*.json' - - - id: set-matrix - run: | - matrix="{\"include\":[" - if [[ "${{ steps.changes.outputs.python_api }}" == "true" ]]; then - matrix="$matrix{\"language\":\"python\",\"directory\":\"cluster-api\"}," - fi - if [[ "${{ steps.changes.outputs.python_service }}" == "true" ]]; then - matrix="$matrix{\"language\":\"python\",\"directory\":\"cluster-service\"}," - fi - if [[ "${{ steps.changes.outputs.go }}" == "true" ]]; then - matrix="$matrix{\"language\":\"go\",\"directory\":\"cluster-status\"}," - fi - if [[ "${{ steps.changes.outputs.typescript }}" == "true" ]]; then - matrix="$matrix{\"language\":\"typescript\",\"directory\":\"cluster-ui\"}," - fi - if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - matrix="{\"include\":[{\"language\":\"python\",\"directory\":\"cluster-api\"},{\"language\":\"python\",\"directory\":\"cluster-service\"},{\"language\":\"go\",\"directory\":\"cluster-status\"},{\"language\":\"typescript\",\"directory\":\"cluster-ui\"}]}" - else - matrix="${matrix%,}]}" - fi - echo "matrix=$matrix" >> $GITHUB_OUTPUT - - lint: + cluster-api: + - 'cluster-api/**' + cluster-service: + - 'cluster-service/**' + cluster-status: + - 'cluster-status/**' + cluster-ui: + - 'cluster-ui/**' + + python-lint: needs: changed_files - if: needs.changed_files.outputs.matrix != '{"include":[]}' + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.python_api == 'true' || + needs.changed_files.outputs.python_service == 'true' runs-on: ubuntu-latest strategy: fail-fast: false - matrix: ${{fromJson(needs.changed_files.outputs.matrix)}} + matrix: + directory: [cluster-api, cluster-service] steps: - uses: actions/checkout@v4 - # Python setup and lint + # Check if directory contains Python files + - name: Check for Python files + id: check-python + run: | + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + - name: Set up Python - if: matrix.language == 'python' + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - cache-dependency-path: | - ${{ matrix.directory }}/requirements*.txt - + - name: Install Python linting tools - if: matrix.language == 'python' + if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi - - name: Run Python linters - if: matrix.language == 'python' + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' working-directory: ${{ matrix.directory }} run: | - black --check . - isort --check-only --diff . - flake8 . - find . -type f -name "*.py" -not -path "*/\.*" -not -path "*/venv/*" -exec pylint {} + + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - # Go setup and lint + go-lint: + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.go == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Go - if: matrix.language == 'go' uses: actions/setup-go@v5 with: go-version: '1.22' cache: true - cache-dependency-path: ${{ matrix.directory }}/go.sum - name: Install Go tools - if: matrix.language == 'go' run: | go install golang.org/x/tools/cmd/goimports@latest go install honnef.co/go/tools/cmd/staticcheck@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest echo "$HOME/go/bin" >> $GITHUB_PATH - - name: Run Go linters - if: matrix.language == 'go' - working-directory: ${{ matrix.directory }} + - name: Go Format Check + working-directory: cluster-status run: | - gofmt -d -e . && test -z "$(gofmt -l .)" - goimports -d -e . && test -z "$(goimports -l .)" - go vet ./... - golangci-lint run --timeout=5m - staticcheck ./... + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... - # TypeScript setup and lint + typescript-lint: + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.typescript == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Node.js - if: matrix.language == 'typescript' uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - cache-dependency-path: ${{ matrix.directory }}/package-lock.json + cache-dependency-path: cluster-ui/package-lock.json - name: Install Node.js dependencies - if: matrix.language == 'typescript' - working-directory: ${{ matrix.directory }} + working-directory: cluster-ui run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci - npm install -g typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - - name: Run TypeScript/JavaScript linters - if: matrix.language == 'typescript' - working-directory: ${{ matrix.directory }} + - name: Lint TypeScript + working-directory: cluster-ui run: | npx tsc --noEmit - npx eslint . --ext .ts,.tsx,.js,.jsx --max-warnings 0 + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 993764f..bc3a86a 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From dea89f6779f974e57fec3f9a29295e56e33f03f4 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 11:43:08 +0545 Subject: [PATCH 67/95] fix: lint --- .github/workflows/lint.yaml | 606 +++++++++++++++++++++--------------- cluster-api/Dockerfile | 2 +- 2 files changed, 360 insertions(+), 248 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3caaf87..d5b1942 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,207 +1,14 @@ -name: Multi-language Lint - -on: - push: - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' - branches: - - '**' - pull_request: - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' - workflow_dispatch: - -jobs: - changed_files: - runs-on: ubuntu-latest - outputs: - python_api: ${{ steps.changes.outputs.cluster-api }} - python_service: ${{ steps.changes.outputs.cluster-service }} - go: ${{ steps.changes.outputs.cluster-status }} - typescript: ${{ steps.changes.outputs.cluster-ui }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - cluster-api: - - 'cluster-api/**' - cluster-service: - - 'cluster-service/**' - cluster-status: - - 'cluster-status/**' - cluster-ui: - - 'cluster-ui/**' - - python-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.python_api == 'true' || - needs.changed_files.outputs.python_service == 'true' - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - directory: [cluster-api, cluster-service] - - steps: - - uses: actions/checkout@v4 - - # Check if directory contains Python files - - name: Check for Python files - id: check-python - run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - - - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} - run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} - run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - - go-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.go == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true - - - name: Install Go tools - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH - - - name: Go Format Check - working-directory: cluster-status - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi - - - name: Go Imports Check - working-directory: cluster-status - run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 - fi - - - name: Run golangci-lint - working-directory: cluster-status - run: golangci-lint run --timeout=5m - - - name: Run staticcheck - working-directory: cluster-status - run: staticcheck ./... - - typescript-lint: - needs: changed_files - if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.typescript == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json - - - name: Install Node.js dependencies - working-directory: cluster-ui - run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci - - - name: Lint TypeScript - working-directory: cluster-ui - run: | - npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix - - - - - - - - - - - - - - - - - - - - - - - - - # name: Multi-language Lint # on: # push: -# branches: -# - '**' # Run on all branches # paths: # - 'cluster-api/**' # - 'cluster-service/**' # - 'cluster-status/**' # - 'cluster-ui/**' +# branches: +# - '**' # pull_request: # paths: # - 'cluster-api/**' @@ -211,87 +18,95 @@ jobs: # workflow_dispatch: # jobs: -# detect-changes: +# changed_files: # runs-on: ubuntu-latest # outputs: -# python-api: ${{ steps.changes.outputs.python-api }} -# python-service: ${{ steps.changes.outputs.python-service }} -# go-status: ${{ steps.changes.outputs.go-status }} -# ts-ui: ${{ steps.changes.outputs.ts-ui }} +# python_api: ${{ steps.changes.outputs.cluster-api }} +# python_service: ${{ steps.changes.outputs.cluster-service }} +# go: ${{ steps.changes.outputs.cluster-status }} +# typescript: ${{ steps.changes.outputs.cluster-ui }} # steps: # - uses: actions/checkout@v4 -# - id: changes -# name: Detect file changes -# run: | -# # Get changed files -# if [[ "${{ github.event_name }}" == "pull_request" ]]; then -# CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) -# else -# CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) -# fi - -# # Check each directory for changes -# echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT - -# python-lint-api: -# needs: detect-changes -# if: needs.detect-changes.outputs.python-api == 'true' +# - uses: dorny/paths-filter@v3 +# id: changes +# with: +# filters: | +# cluster-api: +# - 'cluster-api/**' +# cluster-service: +# - 'cluster-service/**' +# cluster-status: +# - 'cluster-status/**' +# cluster-ui: +# - 'cluster-ui/**' + +# python-lint: +# needs: changed_files +# if: | +# github.event_name == 'workflow_dispatch' || +# needs.changed_files.outputs.python_api == 'true' || +# needs.changed_files.outputs.python_service == 'true' # runs-on: ubuntu-latest +# strategy: +# fail-fast: false +# matrix: +# directory: [cluster-api, cluster-service] + # steps: # - uses: actions/checkout@v4 -# - uses: actions/setup-python@v5 -# with: -# python-version: '3.11' -# cache: 'pip' -# - name: Install Python linting tools -# working-directory: cluster-api -# run: | -# python -m pip install --upgrade pip -# pip install flake8 black isort pylint -# - name: Run Pylint -# working-directory: cluster-api + +# # Check if directory contains Python files +# - name: Check for Python files +# id: check-python # run: | -# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" +# if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then +# echo "has_python_files=true" >> $GITHUB_OUTPUT +# else +# echo "has_python_files=false" >> $GITHUB_OUTPUT +# fi -# python-lint-service: -# needs: detect-changes -# if: needs.detect-changes.outputs.python-service == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: actions/setup-python@v5 +# - name: Set up Python +# if: steps.check-python.outputs.has_python_files == 'true' +# uses: actions/setup-python@v5 # with: # python-version: '3.11' # cache: 'pip' + # - name: Install Python linting tools -# working-directory: cluster-service +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: ${{ matrix.directory }} # run: | # python -m pip install --upgrade pip # pip install flake8 black isort pylint + # - name: Run Pylint -# working-directory: cluster-service +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: ${{ matrix.directory }} # run: | # find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" # go-lint: -# needs: detect-changes -# if: needs.detect-changes.outputs.go-status == 'true' +# needs: changed_files +# if: | +# github.event_name == 'workflow_dispatch' || +# needs.changed_files.outputs.go == 'true' # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 -# - uses: actions/setup-go@v5 + +# - name: Set up Go +# uses: actions/setup-go@v5 # with: # go-version: '1.22' # cache: true + # - name: Install Go tools # run: | # go install golang.org/x/tools/cmd/goimports@latest # go install honnef.co/go/tools/cmd/staticcheck@latest # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest # echo "$HOME/go/bin" >> $GITHUB_PATH + # - name: Go Format Check # working-directory: cluster-status # run: | @@ -301,6 +116,7 @@ jobs: # echo "Please run 'gofmt -w .' to format your code." # exit 1 # fi + # - name: Go Imports Check # working-directory: cluster-status # run: | @@ -310,34 +126,330 @@ jobs: # echo "Please run 'goimports -w .' to fix imports." # exit 1 # fi + # - name: Run golangci-lint # working-directory: cluster-status # run: golangci-lint run --timeout=5m + # - name: Run staticcheck # working-directory: cluster-status # run: staticcheck ./... # typescript-lint: -# needs: detect-changes -# if: needs.detect-changes.outputs.ts-ui == 'true' +# needs: changed_files +# if: | +# github.event_name == 'workflow_dispatch' || +# needs.changed_files.outputs.typescript == 'true' # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 -# - uses: actions/setup-node@v4 + +# - name: Set up Node.js +# uses: actions/setup-node@v4 # with: # node-version: '20' # cache: 'npm' # cache-dependency-path: cluster-ui/package-lock.json + # - name: Install Node.js dependencies # working-directory: cluster-ui # run: | # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin # npm ci + # - name: Lint TypeScript # working-directory: cluster-ui # run: | # npx tsc --noEmit # npx eslint "**/*.{ts,tsx}" --fix + # - name: Lint JavaScript # working-directory: cluster-ui -# run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file +# run: npx eslint "**/*.{js,jsx}" --fix + + + + + + + + + + + + + + + + + + + + + + + + + +# # name: Multi-language Lint + +# # on: +# # push: +# # branches: +# # - '**' # Run on all branches +# # paths: +# # - 'cluster-api/**' +# # - 'cluster-service/**' +# # - 'cluster-status/**' +# # - 'cluster-ui/**' +# # pull_request: +# # paths: +# # - 'cluster-api/**' +# # - 'cluster-service/**' +# # - 'cluster-status/**' +# # - 'cluster-ui/**' +# # workflow_dispatch: + +# # jobs: +# # detect-changes: +# # runs-on: ubuntu-latest +# # outputs: +# # python-api: ${{ steps.changes.outputs.python-api }} +# # python-service: ${{ steps.changes.outputs.python-service }} +# # go-status: ${{ steps.changes.outputs.go-status }} +# # ts-ui: ${{ steps.changes.outputs.ts-ui }} +# # steps: +# # - uses: actions/checkout@v4 +# # - id: changes +# # name: Detect file changes +# # run: | +# # # Get changed files +# # if [[ "${{ github.event_name }}" == "pull_request" ]]; then +# # CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) +# # else +# # CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) +# # fi + +# # # Check each directory for changes +# # echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# # echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# # echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# # echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT + +# # python-lint-api: +# # needs: detect-changes +# # if: needs.detect-changes.outputs.python-api == 'true' +# # runs-on: ubuntu-latest +# # steps: +# # - uses: actions/checkout@v4 +# # - uses: actions/setup-python@v5 +# # with: +# # python-version: '3.11' +# # cache: 'pip' +# # - name: Install Python linting tools +# # working-directory: cluster-api +# # run: | +# # python -m pip install --upgrade pip +# # pip install flake8 black isort pylint +# # - name: Run Pylint +# # working-directory: cluster-api +# # run: | +# # find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + +# # python-lint-service: +# # needs: detect-changes +# # if: needs.detect-changes.outputs.python-service == 'true' +# # runs-on: ubuntu-latest +# # steps: +# # - uses: actions/checkout@v4 +# # - uses: actions/setup-python@v5 +# # with: +# # python-version: '3.11' +# # cache: 'pip' +# # - name: Install Python linting tools +# # working-directory: cluster-service +# # run: | +# # python -m pip install --upgrade pip +# # pip install flake8 black isort pylint +# # - name: Run Pylint +# # working-directory: cluster-service +# # run: | +# # find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + +# # go-lint: +# # needs: detect-changes +# # if: needs.detect-changes.outputs.go-status == 'true' +# # runs-on: ubuntu-latest +# # steps: +# # - uses: actions/checkout@v4 +# # - uses: actions/setup-go@v5 +# # with: +# # go-version: '1.22' +# # cache: true +# # - name: Install Go tools +# # run: | +# # go install golang.org/x/tools/cmd/goimports@latest +# # go install honnef.co/go/tools/cmd/staticcheck@latest +# # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest +# # echo "$HOME/go/bin" >> $GITHUB_PATH +# # - name: Go Format Check +# # working-directory: cluster-status +# # run: | +# # if [ -n "$(gofmt -l .)" ]; then +# # echo "The following files need formatting:" +# # gofmt -l . +# # echo "Please run 'gofmt -w .' to format your code." +# # exit 1 +# # fi +# # - name: Go Imports Check +# # working-directory: cluster-status +# # run: | +# # if [ -n "$(goimports -l .)" ]; then +# # echo "The following files have incorrect imports:" +# # goimports -l . +# # echo "Please run 'goimports -w .' to fix imports." +# # exit 1 +# # fi +# # - name: Run golangci-lint +# # working-directory: cluster-status +# # run: golangci-lint run --timeout=5m +# # - name: Run staticcheck +# # working-directory: cluster-status +# # run: staticcheck ./... + +# # typescript-lint: +# # needs: detect-changes +# # if: needs.detect-changes.outputs.ts-ui == 'true' +# # runs-on: ubuntu-latest +# # steps: +# # - uses: actions/checkout@v4 +# # - uses: actions/setup-node@v4 +# # with: +# # node-version: '20' +# # cache: 'npm' +# # cache-dependency-path: cluster-ui/package-lock.json +# # - name: Install Node.js dependencies +# # working-directory: cluster-ui +# # run: | +# # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin +# # npm ci +# # - name: Lint TypeScript +# # working-directory: cluster-ui +# # run: | +# # npx tsc --noEmit +# # npx eslint "**/*.{ts,tsx}" --fix +# # - name: Lint JavaScript +# # working-directory: cluster-ui +# # run: npx eslint "**/*.{js,jsx}" --fix + + + +name: Lint + +on: + pull_request: + branches: + - '**' + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' + push: + branches: + - '**' + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' + +jobs: + python-lint: + name: Python Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 black isort + + - name: Lint cluster-api + if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') + run: | + CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-api/") + if [ -n "$CHANGED_FILES" ]; then + cd cluster-api + flake8 . + black --check . + isort --check-only . + fi + + - name: Lint cluster-service + if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') + run: | + CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-service/") + if [ -n "$CHANGED_FILES" ]; then + cd cluster-service + flake8 . + black --check . + isort --check-only . + fi + + go-lint: + name: Go Lint + runs-on: ubuntu-latest + if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') + + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.x' + + - name: Install golangci-lint + run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin + + - name: Lint cluster-status + run: | + CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-status/") + if [ -n "$CHANGED_FILES" ]; then + cd cluster-status + golangci-lint run ./... + fi + + typescript-lint: + name: TypeScript Lint + runs-on: ubuntu-latest + if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Install dependencies + run: | + cd cluster-ui + npm install + + - name: Lint cluster-ui + run: | + CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-ui/") + if [ -n "$CHANGED_FILES" ]; then + cd cluster-ui + npm run lint + fi \ No newline at end of file diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index bc3a86a..c2dd1b1 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -12,7 +12,7 @@ ENV PYTHONUNBUFFERED=1 COPY requirements.txt . RUN python -m pip install -r requirements.txt -WORKDIR /app +WORKDIR /app COPY . /app # Install your app From 32fe4660715d2d647b9ea63504556cf494b97397 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 11:48:14 +0545 Subject: [PATCH 68/95] fix: lint --- .github/workflows/lint.yaml | 611 +++++++++++++++--------------------- 1 file changed, 252 insertions(+), 359 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d5b1942..42793ed 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,14 +1,212 @@ +name: Multi-language Lint + +on: + push: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' + branches: + - '**' + pull_request: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' + workflow_dispatch: + +jobs: + changed_files: + runs-on: ubuntu-latest + outputs: + python_api: ${{ steps.changes.outputs.cluster-api }} + python_service: ${{ steps.changes.outputs.cluster-service }} + go: ${{ steps.changes.outputs.cluster-status }} + typescript: ${{ steps.changes.outputs.cluster-ui }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + cluster-api: + - 'cluster-api/**' + cluster-service: + - 'cluster-service/**' + cluster-status: + - 'cluster-status/**' + cluster-ui: + - 'cluster-ui/**' + + python-lint: + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.python_api == 'true' || + needs.changed_files.outputs.python_service == 'true' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + directory: [cluster-api, cluster-service] + include: + - directory: cluster-api + should_run: ${{ needs.changed_files.outputs.python_api == 'true' || github.event_name == 'workflow_dispatch' }} + - directory: cluster-service + should_run: ${{ needs.changed_files.outputs.python_service == 'true' || github.event_name == 'workflow_dispatch' }} + + steps: + - uses: actions/checkout@v4 + + - name: Check for Python files + id: check-python + if: matrix.should_run + run: | + if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + + - name: Set up Python + if: matrix.should_run && steps.check-python.outputs.has_python_files == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + if: matrix.should_run && steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - name: Run Pylint + if: matrix.should_run && steps.check-python.outputs.has_python_files == 'true' + working-directory: ${{ matrix.directory }} + run: | + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + + go-lint: + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.go == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Install Go tools + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Go Format Check + working-directory: cluster-status + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... + + typescript-lint: + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.typescript == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json + + - name: Install Node.js dependencies + working-directory: cluster-ui + run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci + + - name: Lint TypeScript + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix + + + + + + + + + + + + + + + + + + + + + + + + + # name: Multi-language Lint # on: # push: +# branches: +# - '**' # Run on all branches # paths: # - 'cluster-api/**' # - 'cluster-service/**' # - 'cluster-status/**' # - 'cluster-ui/**' -# branches: -# - '**' # pull_request: # paths: # - 'cluster-api/**' @@ -18,95 +216,87 @@ # workflow_dispatch: # jobs: -# changed_files: +# detect-changes: # runs-on: ubuntu-latest # outputs: -# python_api: ${{ steps.changes.outputs.cluster-api }} -# python_service: ${{ steps.changes.outputs.cluster-service }} -# go: ${{ steps.changes.outputs.cluster-status }} -# typescript: ${{ steps.changes.outputs.cluster-ui }} -# steps: -# - uses: actions/checkout@v4 -# - uses: dorny/paths-filter@v3 -# id: changes -# with: -# filters: | -# cluster-api: -# - 'cluster-api/**' -# cluster-service: -# - 'cluster-service/**' -# cluster-status: -# - 'cluster-status/**' -# cluster-ui: -# - 'cluster-ui/**' - -# python-lint: -# needs: changed_files -# if: | -# github.event_name == 'workflow_dispatch' || -# needs.changed_files.outputs.python_api == 'true' || -# needs.changed_files.outputs.python_service == 'true' -# runs-on: ubuntu-latest -# strategy: -# fail-fast: false -# matrix: -# directory: [cluster-api, cluster-service] - +# python-api: ${{ steps.changes.outputs.python-api }} +# python-service: ${{ steps.changes.outputs.python-service }} +# go-status: ${{ steps.changes.outputs.go-status }} +# ts-ui: ${{ steps.changes.outputs.ts-ui }} # steps: # - uses: actions/checkout@v4 - -# # Check if directory contains Python files -# - name: Check for Python files -# id: check-python +# - id: changes +# name: Detect file changes # run: | -# if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then -# echo "has_python_files=true" >> $GITHUB_OUTPUT +# # Get changed files +# if [[ "${{ github.event_name }}" == "pull_request" ]]; then +# CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) # else -# echo "has_python_files=false" >> $GITHUB_OUTPUT +# CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) # fi -# - name: Set up Python -# if: steps.check-python.outputs.has_python_files == 'true' -# uses: actions/setup-python@v5 +# # Check each directory for changes +# echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT +# echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT + +# python-lint-api: +# needs: detect-changes +# if: needs.detect-changes.outputs.python-api == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-python@v5 # with: # python-version: '3.11' # cache: 'pip' - # - name: Install Python linting tools -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: ${{ matrix.directory }} +# working-directory: cluster-api # run: | # python -m pip install --upgrade pip # pip install flake8 black isort pylint +# - name: Run Pylint +# working-directory: cluster-api +# run: | +# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" +# python-lint-service: +# needs: detect-changes +# if: needs.detect-changes.outputs.python-service == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-python@v5 +# with: +# python-version: '3.11' +# cache: 'pip' +# - name: Install Python linting tools +# working-directory: cluster-service +# run: | +# python -m pip install --upgrade pip +# pip install flake8 black isort pylint # - name: Run Pylint -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: ${{ matrix.directory }} +# working-directory: cluster-service # run: | # find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" # go-lint: -# needs: changed_files -# if: | -# github.event_name == 'workflow_dispatch' || -# needs.changed_files.outputs.go == 'true' +# needs: detect-changes +# if: needs.detect-changes.outputs.go-status == 'true' # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 - -# - name: Set up Go -# uses: actions/setup-go@v5 +# - uses: actions/setup-go@v5 # with: # go-version: '1.22' # cache: true - # - name: Install Go tools # run: | # go install golang.org/x/tools/cmd/goimports@latest # go install honnef.co/go/tools/cmd/staticcheck@latest # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest # echo "$HOME/go/bin" >> $GITHUB_PATH - # - name: Go Format Check # working-directory: cluster-status # run: | @@ -116,7 +306,6 @@ # echo "Please run 'gofmt -w .' to format your code." # exit 1 # fi - # - name: Go Imports Check # working-directory: cluster-status # run: | @@ -126,330 +315,34 @@ # echo "Please run 'goimports -w .' to fix imports." # exit 1 # fi - # - name: Run golangci-lint # working-directory: cluster-status # run: golangci-lint run --timeout=5m - # - name: Run staticcheck # working-directory: cluster-status # run: staticcheck ./... # typescript-lint: -# needs: changed_files -# if: | -# github.event_name == 'workflow_dispatch' || -# needs.changed_files.outputs.typescript == 'true' +# needs: detect-changes +# if: needs.detect-changes.outputs.ts-ui == 'true' # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v4 - -# - name: Set up Node.js -# uses: actions/setup-node@v4 +# - uses: actions/setup-node@v4 # with: # node-version: '20' # cache: 'npm' # cache-dependency-path: cluster-ui/package-lock.json - # - name: Install Node.js dependencies # working-directory: cluster-ui # run: | # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin # npm ci - # - name: Lint TypeScript # working-directory: cluster-ui # run: | # npx tsc --noEmit # npx eslint "**/*.{ts,tsx}" --fix - # - name: Lint JavaScript # working-directory: cluster-ui -# run: npx eslint "**/*.{js,jsx}" --fix - - - - - - - - - - - - - - - - - - - - - - - - - -# # name: Multi-language Lint - -# # on: -# # push: -# # branches: -# # - '**' # Run on all branches -# # paths: -# # - 'cluster-api/**' -# # - 'cluster-service/**' -# # - 'cluster-status/**' -# # - 'cluster-ui/**' -# # pull_request: -# # paths: -# # - 'cluster-api/**' -# # - 'cluster-service/**' -# # - 'cluster-status/**' -# # - 'cluster-ui/**' -# # workflow_dispatch: - -# # jobs: -# # detect-changes: -# # runs-on: ubuntu-latest -# # outputs: -# # python-api: ${{ steps.changes.outputs.python-api }} -# # python-service: ${{ steps.changes.outputs.python-service }} -# # go-status: ${{ steps.changes.outputs.go-status }} -# # ts-ui: ${{ steps.changes.outputs.ts-ui }} -# # steps: -# # - uses: actions/checkout@v4 -# # - id: changes -# # name: Detect file changes -# # run: | -# # # Get changed files -# # if [[ "${{ github.event_name }}" == "pull_request" ]]; then -# # CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) -# # else -# # CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) -# # fi - -# # # Check each directory for changes -# # echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# # echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# # echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# # echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT - -# # python-lint-api: -# # needs: detect-changes -# # if: needs.detect-changes.outputs.python-api == 'true' -# # runs-on: ubuntu-latest -# # steps: -# # - uses: actions/checkout@v4 -# # - uses: actions/setup-python@v5 -# # with: -# # python-version: '3.11' -# # cache: 'pip' -# # - name: Install Python linting tools -# # working-directory: cluster-api -# # run: | -# # python -m pip install --upgrade pip -# # pip install flake8 black isort pylint -# # - name: Run Pylint -# # working-directory: cluster-api -# # run: | -# # find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - -# # python-lint-service: -# # needs: detect-changes -# # if: needs.detect-changes.outputs.python-service == 'true' -# # runs-on: ubuntu-latest -# # steps: -# # - uses: actions/checkout@v4 -# # - uses: actions/setup-python@v5 -# # with: -# # python-version: '3.11' -# # cache: 'pip' -# # - name: Install Python linting tools -# # working-directory: cluster-service -# # run: | -# # python -m pip install --upgrade pip -# # pip install flake8 black isort pylint -# # - name: Run Pylint -# # working-directory: cluster-service -# # run: | -# # find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - -# # go-lint: -# # needs: detect-changes -# # if: needs.detect-changes.outputs.go-status == 'true' -# # runs-on: ubuntu-latest -# # steps: -# # - uses: actions/checkout@v4 -# # - uses: actions/setup-go@v5 -# # with: -# # go-version: '1.22' -# # cache: true -# # - name: Install Go tools -# # run: | -# # go install golang.org/x/tools/cmd/goimports@latest -# # go install honnef.co/go/tools/cmd/staticcheck@latest -# # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -# # echo "$HOME/go/bin" >> $GITHUB_PATH -# # - name: Go Format Check -# # working-directory: cluster-status -# # run: | -# # if [ -n "$(gofmt -l .)" ]; then -# # echo "The following files need formatting:" -# # gofmt -l . -# # echo "Please run 'gofmt -w .' to format your code." -# # exit 1 -# # fi -# # - name: Go Imports Check -# # working-directory: cluster-status -# # run: | -# # if [ -n "$(goimports -l .)" ]; then -# # echo "The following files have incorrect imports:" -# # goimports -l . -# # echo "Please run 'goimports -w .' to fix imports." -# # exit 1 -# # fi -# # - name: Run golangci-lint -# # working-directory: cluster-status -# # run: golangci-lint run --timeout=5m -# # - name: Run staticcheck -# # working-directory: cluster-status -# # run: staticcheck ./... - -# # typescript-lint: -# # needs: detect-changes -# # if: needs.detect-changes.outputs.ts-ui == 'true' -# # runs-on: ubuntu-latest -# # steps: -# # - uses: actions/checkout@v4 -# # - uses: actions/setup-node@v4 -# # with: -# # node-version: '20' -# # cache: 'npm' -# # cache-dependency-path: cluster-ui/package-lock.json -# # - name: Install Node.js dependencies -# # working-directory: cluster-ui -# # run: | -# # npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin -# # npm ci -# # - name: Lint TypeScript -# # working-directory: cluster-ui -# # run: | -# # npx tsc --noEmit -# # npx eslint "**/*.{ts,tsx}" --fix -# # - name: Lint JavaScript -# # working-directory: cluster-ui -# # run: npx eslint "**/*.{js,jsx}" --fix - - - -name: Lint - -on: - pull_request: - branches: - - '**' - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' - push: - branches: - - '**' - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' - -jobs: - python-lint: - name: Python Lint - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 black isort - - - name: Lint cluster-api - if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') - run: | - CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-api/") - if [ -n "$CHANGED_FILES" ]; then - cd cluster-api - flake8 . - black --check . - isort --check-only . - fi - - - name: Lint cluster-service - if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') - run: | - CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-service/") - if [ -n "$CHANGED_FILES" ]; then - cd cluster-service - flake8 . - black --check . - isort --check-only . - fi - - go-lint: - name: Go Lint - runs-on: ubuntu-latest - if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') - - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.x' - - - name: Install golangci-lint - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin - - - name: Lint cluster-status - run: | - CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-status/") - if [ -n "$CHANGED_FILES" ]; then - cd cluster-status - golangci-lint run ./... - fi - - typescript-lint: - name: TypeScript Lint - runs-on: ubuntu-latest - if: contains(github.event.pull_request.base.sha, '') && contains(github.event.pull_request.head.sha, '') - - steps: - - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '18.x' - - - name: Install dependencies - run: | - cd cluster-ui - npm install - - - name: Lint cluster-ui - run: | - CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "^cluster-ui/") - if [ -n "$CHANGED_FILES" ]; then - cd cluster-ui - npm run lint - fi \ No newline at end of file +# run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file From e686923605d53f108a2055a5030a50048d78f9d8 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 11:48:42 +0545 Subject: [PATCH 69/95] fix: lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index c2dd1b1..9dd596e 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -7,7 +7,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 # Turns off buffering for easier container logging ENV PYTHONUNBUFFERED=1 - + # Install pip requirements COPY requirements.txt . RUN python -m pip install -r requirements.txt From 5280ff0d1dc5e324518bcebf6828c6b36b45d8bf Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 11:59:01 +0545 Subject: [PATCH 70/95] fix: lint --- .github/workflows/lint.yaml | 64 ++++++++++++++++++++++++++----------- cluster-api/Dockerfile | 2 +- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 42793ed..43e33a9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -40,53 +40,79 @@ jobs: cluster-ui: - 'cluster-ui/**' - python-lint: + python-api-lint: + needs: changed_files + if: | + github.event_name == 'workflow_dispatch' || + needs.changed_files.outputs.python_api == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Check for Python files + id: check-python + run: | + if find cluster-api -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-api + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-api + run: | + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + + python-service-lint: needs: changed_files if: | github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.python_api == 'true' || needs.changed_files.outputs.python_service == 'true' runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - directory: [cluster-api, cluster-service] - include: - - directory: cluster-api - should_run: ${{ needs.changed_files.outputs.python_api == 'true' || github.event_name == 'workflow_dispatch' }} - - directory: cluster-service - should_run: ${{ needs.changed_files.outputs.python_service == 'true' || github.event_name == 'workflow_dispatch' }} - steps: - uses: actions/checkout@v4 - name: Check for Python files id: check-python - if: matrix.should_run run: | - if find ${{ matrix.directory }} -name "*.py" -print -quit | grep -q .; then + if find cluster-service -name "*.py" -print -quit | grep -q .; then echo "has_python_files=true" >> $GITHUB_OUTPUT else echo "has_python_files=false" >> $GITHUB_OUTPUT fi - name: Set up Python - if: matrix.should_run && steps.check-python.outputs.has_python_files == 'true' + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: matrix.should_run && steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-service run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - name: Run Pylint - if: matrix.should_run && steps.check-python.outputs.has_python_files == 'true' - working-directory: ${{ matrix.directory }} + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-service run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 9dd596e..08c463c 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -11,7 +11,7 @@ ENV PYTHONUNBUFFERED=1 # Install pip requirements COPY requirements.txt . RUN python -m pip install -r requirements.txt - + WORKDIR /app COPY . /app From 73600a555ee24565f70c935d0b220802e76f78b5 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:05:31 +0545 Subject: [PATCH 71/95] fix: lint --- .github/workflows/lint.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 43e33a9..7e16ba4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -40,7 +40,7 @@ jobs: cluster-ui: - 'cluster-ui/**' - python-api-lint: + cluster-api-lint: needs: changed_files if: | github.event_name == 'workflow_dispatch' || @@ -78,7 +78,7 @@ jobs: run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - python-service-lint: + cluster-service-lint: needs: changed_files if: | github.event_name == 'workflow_dispatch' || @@ -116,7 +116,7 @@ jobs: run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - go-lint: + cluster-status-lint: needs: changed_files if: | github.event_name == 'workflow_dispatch' || @@ -166,7 +166,7 @@ jobs: working-directory: cluster-status run: staticcheck ./... - typescript-lint: + cluster-ui-lint: needs: changed_files if: | github.event_name == 'workflow_dispatch' || From 79d74f5ebc18de538688656c25f9c06a98fb10de Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:07:27 +0545 Subject: [PATCH 72/95] fix: lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 08c463c..53debe6 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -9,7 +9,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install pip requirements -COPY requirements.txt . +COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app From 1c9c1123bbf34c066b91f7c3a9ee30cd4a194798 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:13:13 +0545 Subject: [PATCH 73/95] fix: lint --- .github/workflows/lint.yaml | 16 ++++++++-------- cluster-api/Dockerfile | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7e16ba4..1b665d2 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -43,8 +43,8 @@ jobs: cluster-api-lint: needs: changed_files if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.python_api == 'true' + needs.changed_files.outputs.python_api == 'true' || + github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -81,8 +81,8 @@ jobs: cluster-service-lint: needs: changed_files if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.python_service == 'true' + needs.changed_files.outputs.python_service == 'true' || + github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -119,8 +119,8 @@ jobs: cluster-status-lint: needs: changed_files if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.go == 'true' + needs.changed_files.outputs.go == 'true' || + github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -169,8 +169,8 @@ jobs: cluster-ui-lint: needs: changed_files if: | - github.event_name == 'workflow_dispatch' || - needs.changed_files.outputs.typescript == 'true' + needs.changed_files.outputs.typescript == 'true' || + github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 53debe6..421cbbd 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From 5989bd70d3002f670a4c52c039ab9a9bfde97fa9 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:20:49 +0545 Subject: [PATCH 74/95] fix: lint --- .github/workflows/lint.yaml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 1b665d2..53f15b0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -42,9 +42,7 @@ jobs: cluster-api-lint: needs: changed_files - if: | - needs.changed_files.outputs.python_api == 'true' || - github.event_name == 'workflow_dispatch' + if: needs.changed_files.outputs.python_api == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -80,9 +78,7 @@ jobs: cluster-service-lint: needs: changed_files - if: | - needs.changed_files.outputs.python_service == 'true' || - github.event_name == 'workflow_dispatch' + if: needs.changed_files.outputs.python_service == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -118,9 +114,7 @@ jobs: cluster-status-lint: needs: changed_files - if: | - needs.changed_files.outputs.go == 'true' || - github.event_name == 'workflow_dispatch' + if: needs.changed_files.outputs.go == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -168,9 +162,7 @@ jobs: cluster-ui-lint: needs: changed_files - if: | - needs.changed_files.outputs.typescript == 'true' || - github.event_name == 'workflow_dispatch' + if: needs.changed_files.outputs.typescript == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -217,7 +209,6 @@ jobs: - From 3186a8a7205c24661979f0eb5fd32e6c9d506f06 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:21:11 +0545 Subject: [PATCH 75/95] fix: lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 421cbbd..1837583 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -12,7 +12,7 @@ ENV PYTHONUNBUFFERED=1 COPY requirements.txt . RUN python -m pip install -r requirements.txt -WORKDIR /app +WORKDIR /app COPY . /app # Install your app From e1d96c6d71224ce6ef22895593fa819f1e0192af Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:36:45 +0545 Subject: [PATCH 76/95] fix: lint --- .github/workflows/lint.yaml | 113 ++++++++++++++++-------------------- cluster-api/Dockerfile | 2 +- 2 files changed, 51 insertions(+), 64 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 53f15b0..7d450d3 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,100 +21,93 @@ jobs: changed_files: runs-on: ubuntu-latest outputs: - python_api: ${{ steps.changes.outputs.cluster-api }} - python_service: ${{ steps.changes.outputs.cluster-service }} - go: ${{ steps.changes.outputs.cluster-status }} - typescript: ${{ steps.changes.outputs.cluster-ui }} + python_api_files: ${{ steps.filter-python-api.outputs.files }} + python_service_files: ${{ steps.filter-python-service.outputs.files }} + go_files: ${{ steps.filter-go.outputs.files }} + typescript_files: ${{ steps.filter-ts.outputs.files }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: changes + + - name: Get changed files in cluster-api + id: filter-python-api + uses: tj-actions/changed-files@v41 + with: + files: cluster-api/**/*.py + + - name: Get changed files in cluster-service + id: filter-python-service + uses: tj-actions/changed-files@v41 + with: + files: cluster-service/**/*.py + + - name: Get changed files in cluster-status + id: filter-go + uses: tj-actions/changed-files@v41 with: - filters: | - cluster-api: - - 'cluster-api/**' - cluster-service: - - 'cluster-service/**' - cluster-status: - - 'cluster-status/**' - cluster-ui: - - 'cluster-ui/**' + files: | + cluster-status/**/*.go + + - name: Get changed files in cluster-ui + id: filter-ts + uses: tj-actions/changed-files@v41 + with: + files: | + cluster-ui/**/*.ts + cluster-ui/**/*.tsx + cluster-ui/**/*.js + cluster-ui/**/*.jsx cluster-api-lint: needs: changed_files - if: needs.changed_files.outputs.python_api == 'true' + if: needs.changed_files.outputs.python_api_files != '[]' && needs.changed_files.outputs.python_api_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Check for Python files - id: check-python - run: | - if find cluster-api -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-api run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' + - name: Run Pylint on changed files working-directory: cluster-api run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + echo "${{ needs.changed_files.outputs.python_api_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" cluster-service-lint: needs: changed_files - if: needs.changed_files.outputs.python_service == 'true' + if: needs.changed_files.outputs.python_service_files != '[]' && needs.changed_files.outputs.python_service_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Check for Python files - id: check-python - run: | - if find cluster-service -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-service run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' + - name: Run Pylint on changed files working-directory: cluster-service run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + echo "${{ needs.changed_files.outputs.python_service_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" cluster-status-lint: needs: changed_files - if: needs.changed_files.outputs.go == 'true' + if: needs.changed_files.outputs.go_files != '[]' && needs.changed_files.outputs.go_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -135,34 +128,32 @@ jobs: - name: Go Format Check working-directory: cluster-status run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." + echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' | xargs gofmt -l + if [ $? -ne 0 ]; then + echo "Please run 'gofmt -w' on the files listed above" exit 1 fi - name: Go Imports Check working-directory: cluster-status run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." + echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' | xargs goimports -l + if [ $? -ne 0 ]; then + echo "Please run 'goimports -w' on the files listed above" exit 1 fi - name: Run golangci-lint working-directory: cluster-status - run: golangci-lint run --timeout=5m + run: golangci-lint run ${{ needs.changed_files.outputs.go_files }} - name: Run staticcheck working-directory: cluster-status - run: staticcheck ./... + run: echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' | xargs staticcheck cluster-ui-lint: needs: changed_files - if: needs.changed_files.outputs.typescript == 'true' + if: needs.changed_files.outputs.typescript_files != '[]' && needs.changed_files.outputs.typescript_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -180,15 +171,11 @@ jobs: npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci - - name: Lint TypeScript + - name: Lint TypeScript/JavaScript files working-directory: cluster-ui run: | npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix + echo "${{ needs.changed_files.outputs.typescript_files }}" | tr ' ' '\n' | xargs npx eslint --fix diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 1837583..bd6866c 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -12,7 +12,7 @@ ENV PYTHONUNBUFFERED=1 COPY requirements.txt . RUN python -m pip install -r requirements.txt -WORKDIR /app +WORKDIR /app COPY . /app # Install your app From 910fff565f8cd525819c690eadc99c5c2ed25e07 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:40:40 +0545 Subject: [PATCH 77/95] fix: lint --- .github/workflows/lint.yaml | 60 ++++++++++++++++++++++++++++++------- cluster-api/Dockerfile | 2 +- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7d450d3..1dfe4b3 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,24 +21,35 @@ jobs: changed_files: runs-on: ubuntu-latest outputs: - python_api_files: ${{ steps.filter-python-api.outputs.files }} - python_service_files: ${{ steps.filter-python-service.outputs.files }} - go_files: ${{ steps.filter-go.outputs.files }} - typescript_files: ${{ steps.filter-ts.outputs.files }} + python_api_files: ${{ steps.filter-python-api.outputs.all_changed_files }} + python_service_files: ${{ steps.filter-python-service.outputs.all_changed_files }} + go_files: ${{ steps.filter-go.outputs.all_changed_files }} + typescript_files: ${{ steps.filter-ts.outputs.all_changed_files }} steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all branches and tags - name: Get changed files in cluster-api id: filter-python-api uses: tj-actions/changed-files@v41 with: - files: cluster-api/**/*.py + files: | + cluster-api/**/*.py + cluster-api/*.py + + - name: Debug changed files + run: | + echo "Python API files: ${{ steps.filter-python-api.outputs.all_changed_files }}" + echo "Python API any_changed: ${{ steps.filter-python-api.outputs.any_changed }}" - name: Get changed files in cluster-service id: filter-python-service uses: tj-actions/changed-files@v41 with: - files: cluster-service/**/*.py + files: | + cluster-service/**/*.py + cluster-service/*.py - name: Get changed files in cluster-status id: filter-go @@ -46,6 +57,7 @@ jobs: with: files: | cluster-status/**/*.go + cluster-status/*.go - name: Get changed files in cluster-ui id: filter-ts @@ -56,14 +68,22 @@ jobs: cluster-ui/**/*.tsx cluster-ui/**/*.js cluster-ui/**/*.jsx + cluster-ui/*.ts + cluster-ui/*.tsx + cluster-ui/*.js + cluster-ui/*.jsx cluster-api-lint: needs: changed_files - if: needs.changed_files.outputs.python_api_files != '[]' && needs.changed_files.outputs.python_api_files != '' + if: needs.changed_files.outputs.python_api_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Debug job condition + run: | + echo "Python API files: ${{ needs.changed_files.outputs.python_api_files }}" + - name: Set up Python uses: actions/setup-python@v5 with: @@ -79,15 +99,21 @@ jobs: - name: Run Pylint on changed files working-directory: cluster-api run: | + echo "Files to lint:" + echo "${{ needs.changed_files.outputs.python_api_files }}" | tr ' ' '\n' echo "${{ needs.changed_files.outputs.python_api_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" cluster-service-lint: needs: changed_files - if: needs.changed_files.outputs.python_service_files != '[]' && needs.changed_files.outputs.python_service_files != '' + if: needs.changed_files.outputs.python_service_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Debug job condition + run: | + echo "Python Service files: ${{ needs.changed_files.outputs.python_service_files }}" + - name: Set up Python uses: actions/setup-python@v5 with: @@ -103,15 +129,21 @@ jobs: - name: Run Pylint on changed files working-directory: cluster-service run: | + echo "Files to lint:" + echo "${{ needs.changed_files.outputs.python_service_files }}" | tr ' ' '\n' echo "${{ needs.changed_files.outputs.python_service_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" cluster-status-lint: needs: changed_files - if: needs.changed_files.outputs.go_files != '[]' && needs.changed_files.outputs.go_files != '' + if: needs.changed_files.outputs.go_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Debug job condition + run: | + echo "Go files: ${{ needs.changed_files.outputs.go_files }}" + - name: Set up Go uses: actions/setup-go@v5 with: @@ -128,6 +160,8 @@ jobs: - name: Go Format Check working-directory: cluster-status run: | + echo "Files to format:" + echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' | xargs gofmt -l if [ $? -ne 0 ]; then echo "Please run 'gofmt -w' on the files listed above" @@ -153,11 +187,15 @@ jobs: cluster-ui-lint: needs: changed_files - if: needs.changed_files.outputs.typescript_files != '[]' && needs.changed_files.outputs.typescript_files != '' + if: needs.changed_files.outputs.typescript_files != '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Debug job condition + run: | + echo "TypeScript/JavaScript files: ${{ needs.changed_files.outputs.typescript_files }}" + - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -175,6 +213,8 @@ jobs: working-directory: cluster-ui run: | npx tsc --noEmit + echo "Files to lint:" + echo "${{ needs.changed_files.outputs.typescript_files }}" | tr ' ' '\n' echo "${{ needs.changed_files.outputs.typescript_files }}" | tr ' ' '\n' | xargs npx eslint --fix diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index bd6866c..8ad1c0b 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From 0b4d7938a51b252f69bf7b4cc90af55da8ac3dde Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 24 Feb 2025 12:41:34 +0545 Subject: [PATCH 78/95] fix: lint --- .github/workflows/lint.yaml | 149 +++++++++++++++--------------------- cluster-api/Dockerfile | 2 +- 2 files changed, 62 insertions(+), 89 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 1dfe4b3..53f15b0 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,129 +21,104 @@ jobs: changed_files: runs-on: ubuntu-latest outputs: - python_api_files: ${{ steps.filter-python-api.outputs.all_changed_files }} - python_service_files: ${{ steps.filter-python-service.outputs.all_changed_files }} - go_files: ${{ steps.filter-go.outputs.all_changed_files }} - typescript_files: ${{ steps.filter-ts.outputs.all_changed_files }} + python_api: ${{ steps.changes.outputs.cluster-api }} + python_service: ${{ steps.changes.outputs.cluster-service }} + go: ${{ steps.changes.outputs.cluster-status }} + typescript: ${{ steps.changes.outputs.cluster-ui }} steps: - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: changes with: - fetch-depth: 0 # Fetch all history for all branches and tags - - - name: Get changed files in cluster-api - id: filter-python-api - uses: tj-actions/changed-files@v41 - with: - files: | - cluster-api/**/*.py - cluster-api/*.py - - - name: Debug changed files - run: | - echo "Python API files: ${{ steps.filter-python-api.outputs.all_changed_files }}" - echo "Python API any_changed: ${{ steps.filter-python-api.outputs.any_changed }}" - - - name: Get changed files in cluster-service - id: filter-python-service - uses: tj-actions/changed-files@v41 - with: - files: | - cluster-service/**/*.py - cluster-service/*.py - - - name: Get changed files in cluster-status - id: filter-go - uses: tj-actions/changed-files@v41 - with: - files: | - cluster-status/**/*.go - cluster-status/*.go - - - name: Get changed files in cluster-ui - id: filter-ts - uses: tj-actions/changed-files@v41 - with: - files: | - cluster-ui/**/*.ts - cluster-ui/**/*.tsx - cluster-ui/**/*.js - cluster-ui/**/*.jsx - cluster-ui/*.ts - cluster-ui/*.tsx - cluster-ui/*.js - cluster-ui/*.jsx + filters: | + cluster-api: + - 'cluster-api/**' + cluster-service: + - 'cluster-service/**' + cluster-status: + - 'cluster-status/**' + cluster-ui: + - 'cluster-ui/**' cluster-api-lint: needs: changed_files - if: needs.changed_files.outputs.python_api_files != '' + if: needs.changed_files.outputs.python_api == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Debug job condition + - name: Check for Python files + id: check-python run: | - echo "Python API files: ${{ needs.changed_files.outputs.python_api_files }}" - + if find cluster-api -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools + if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-api run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint on changed files + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-api run: | - echo "Files to lint:" - echo "${{ needs.changed_files.outputs.python_api_files }}" | tr ' ' '\n' - echo "${{ needs.changed_files.outputs.python_api_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" cluster-service-lint: needs: changed_files - if: needs.changed_files.outputs.python_service_files != '' + if: needs.changed_files.outputs.python_service == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Debug job condition + - name: Check for Python files + id: check-python run: | - echo "Python Service files: ${{ needs.changed_files.outputs.python_service_files }}" - + if find cluster-service -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' uses: actions/setup-python@v5 with: python-version: '3.11' cache: 'pip' - name: Install Python linting tools + if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-service run: | python -m pip install --upgrade pip pip install flake8 black isort pylint - - name: Run Pylint on changed files + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' working-directory: cluster-service run: | - echo "Files to lint:" - echo "${{ needs.changed_files.outputs.python_service_files }}" | tr ' ' '\n' - echo "${{ needs.changed_files.outputs.python_service_files }}" | tr ' ' '\n' | xargs pylint || echo "Linting completed with warnings" + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" cluster-status-lint: needs: changed_files - if: needs.changed_files.outputs.go_files != '' + if: needs.changed_files.outputs.go == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Debug job condition - run: | - echo "Go files: ${{ needs.changed_files.outputs.go_files }}" - - name: Set up Go uses: actions/setup-go@v5 with: @@ -160,42 +135,38 @@ jobs: - name: Go Format Check working-directory: cluster-status run: | - echo "Files to format:" - echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' - echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' | xargs gofmt -l - if [ $? -ne 0 ]; then - echo "Please run 'gofmt -w' on the files listed above" + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." exit 1 fi - name: Go Imports Check working-directory: cluster-status run: | - echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' | xargs goimports -l - if [ $? -ne 0 ]; then - echo "Please run 'goimports -w' on the files listed above" + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." exit 1 fi - name: Run golangci-lint working-directory: cluster-status - run: golangci-lint run ${{ needs.changed_files.outputs.go_files }} + run: golangci-lint run --timeout=5m - name: Run staticcheck working-directory: cluster-status - run: echo "${{ needs.changed_files.outputs.go_files }}" | tr ' ' '\n' | xargs staticcheck + run: staticcheck ./... cluster-ui-lint: needs: changed_files - if: needs.changed_files.outputs.typescript_files != '' + if: needs.changed_files.outputs.typescript == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Debug job condition - run: | - echo "TypeScript/JavaScript files: ${{ needs.changed_files.outputs.typescript_files }}" - - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -209,13 +180,15 @@ jobs: npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin npm ci - - name: Lint TypeScript/JavaScript files + - name: Lint TypeScript working-directory: cluster-ui run: | npx tsc --noEmit - echo "Files to lint:" - echo "${{ needs.changed_files.outputs.typescript_files }}" | tr ' ' '\n' - echo "${{ needs.changed_files.outputs.typescript_files }}" | tr ' ' '\n' | xargs npx eslint --fix + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 8ad1c0b..0790e92 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -9,7 +9,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install pip requirements -COPY requirements.txt . +COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app From e04fac32ed2cd68979c7797ebb798a2e12bbc5a7 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 11:52:43 +0545 Subject: [PATCH 79/95] feat:lint --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 53f15b0..7b68509 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -188,7 +188,7 @@ jobs: - name: Lint JavaScript working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix + run: npx eslint "**/*.{js,jsx}" --fix From 4cb1037bf2765c7ac59f8e9dd64c46b122b474e2 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 11:53:16 +0545 Subject: [PATCH 80/95] feat:lint --- cluster-service/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-service/Dockerfile b/cluster-service/Dockerfile index 637ded6..62630fb 100644 --- a/cluster-service/Dockerfile +++ b/cluster-service/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From c1e6a6f67c2427bdf67628783d305203e301fa92 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 11:56:49 +0545 Subject: [PATCH 81/95] feat:lint --- .github/workflows/lint.yaml | 52 ++++++++++++++++++++++++++++--------- cluster-service/Dockerfile | 2 +- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7b68509..c297b9f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -27,18 +27,46 @@ jobs: typescript: ${{ steps.changes.outputs.cluster-ui }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: changes with: - filters: | - cluster-api: - - 'cluster-api/**' - cluster-service: - - 'cluster-service/**' - cluster-status: - - 'cluster-status/**' - cluster-ui: - - 'cluster-ui/**' + fetch-depth: 0 + + - name: Get changed files by directory + id: changes + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + BASE_SHA=${{ github.event.pull_request.base.sha }} + HEAD_SHA=${{ github.event.pull_request.head.sha }} + else + BASE_SHA=$(git rev-parse HEAD^) + HEAD_SHA=$(git rev-parse HEAD) + fi + + echo "Checking changes between $BASE_SHA and $HEAD_SHA" + + # Check each directory separately + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-api/"; then + echo "cluster-api=true" >> $GITHUB_OUTPUT + else + echo "cluster-api=false" >> $GITHUB_OUTPUT + fi + + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-service/"; then + echo "cluster-service=true" >> $GITHUB_OUTPUT + else + echo "cluster-service=false" >> $GITHUB_OUTPUT + fi + + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-status/"; then + echo "cluster-status=true" >> $GITHUB_OUTPUT + else + echo "cluster-status=false" >> $GITHUB_OUTPUT + fi + + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-ui/"; then + echo "cluster-ui=true" >> $GITHUB_OUTPUT + else + echo "cluster-ui=false" >> $GITHUB_OUTPUT + fi cluster-api-lint: needs: changed_files @@ -188,7 +216,7 @@ jobs: - name: Lint JavaScript working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix + run: npx eslint "**/*.{js,jsx}" --fix diff --git a/cluster-service/Dockerfile b/cluster-service/Dockerfile index 62630fb..83789be 100644 --- a/cluster-service/Dockerfile +++ b/cluster-service/Dockerfile @@ -9,7 +9,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Install pip requirements -COPY requirements.txt . +COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app From 807f7c689ed97b42865a53d7cb8329ce8378f40a Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 11:57:35 +0545 Subject: [PATCH 82/95] feat:lint --- cluster-service/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-service/Dockerfile b/cluster-service/Dockerfile index 83789be..b26a06b 100644 --- a/cluster-service/Dockerfile +++ b/cluster-service/Dockerfile @@ -17,5 +17,5 @@ COPY . /app # Install your app COPY . . -RUN pip install --no-cache-dir --upgrade -r requirements.txt +RUN pip install --no-cache-dir --upgrade -r requirements.txt CMD python main.py From 3eea49920719121a817a8f5a731cdae3ada6237d Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 11:58:32 +0545 Subject: [PATCH 83/95] feat:lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 0790e92..e8df47d 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -15,7 +15,7 @@ RUN python -m pip install -r requirements.txt WORKDIR /app COPY . /app -# Install your app +# Install your app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Install your app From 54eb5ea1aebfbbf57a9b07cf1f9c06f35bb5b31f Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 12:00:23 +0545 Subject: [PATCH 84/95] feat:lint --- cluster-status/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 523ff05..8b3395a 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -8,5 +8,5 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app -COPY --from=builder /app/main . +COPY --from=builder /app/main . CMD ["./main"] \ No newline at end of file From 85b68d85aa3f37796499b8b493eae562772fa438 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 12:04:22 +0545 Subject: [PATCH 85/95] feat:lint --- cluster-ui/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-ui/Dockerfile b/cluster-ui/Dockerfile index 8e73e1c..b8940ec 100644 --- a/cluster-ui/Dockerfile +++ b/cluster-ui/Dockerfile @@ -14,7 +14,7 @@ RUN npm install --legacy-peer-deps # 4. Copy the source code to /app dir COPY . . - + # 5. Build the TypeScript code and then run vite build RUN npm run build From e731a747fd0c52c994be9e16e602e3df11be37b6 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Mon, 3 Mar 2025 12:16:37 +0545 Subject: [PATCH 86/95] feat:lint --- .github/workflows/gitleaks.yaml | 23 ++--- .github/workflows/lint.yaml | 176 +------------------------------- 2 files changed, 7 insertions(+), 192 deletions(-) diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index 4eff98f..64becc4 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -3,8 +3,8 @@ name: GitLeaks Scan on: push: branches: - - '**' # Run on all branches - pull_request: # Keep PR checks for good measure + - '**' + pull_request: workflow_dispatch: jobs: @@ -12,34 +12,23 @@ jobs: name: GitLeaks Security Scan runs-on: ubuntu-latest permissions: - security-events: write # Required for uploading SARIF results + security-events: write contents: read steps: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 0 # Required for full history scan + fetch-depth: 0 - name: Run GitLeaks uses: gitleaks/gitleaks-action@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - config-path: .gitleaks.toml # Optional: Custom config file + config-path: .gitleaks.toml enable-upload-artifact: true report-format: sarif report-path: gitleaks-report.sarif - # - name: Upload SARIF report - # if: always() # Upload even if GitLeaks finds issues - # uses: github/codeql-action/upload-sarif@v3 - # with: - # sarif_file: gitleaks-report.sarif - # category: gitleaks - - # - name: Handle GitLeaks findings - # if: failure() - # run: | - # echo "::warning ::GitLeaks has detected potential secrets in your codebase." - # echo "Please review the SARIF report in the Security tab." \ No newline at end of file + \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index c297b9f..7868c9a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -216,178 +216,4 @@ jobs: - name: Lint JavaScript working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix - - - - - - - - - - - - - - - - - - - - - - - - -# name: Multi-language Lint - -# on: -# push: -# branches: -# - '**' # Run on all branches -# paths: -# - 'cluster-api/**' -# - 'cluster-service/**' -# - 'cluster-status/**' -# - 'cluster-ui/**' -# pull_request: -# paths: -# - 'cluster-api/**' -# - 'cluster-service/**' -# - 'cluster-status/**' -# - 'cluster-ui/**' -# workflow_dispatch: - -# jobs: -# detect-changes: -# runs-on: ubuntu-latest -# outputs: -# python-api: ${{ steps.changes.outputs.python-api }} -# python-service: ${{ steps.changes.outputs.python-service }} -# go-status: ${{ steps.changes.outputs.go-status }} -# ts-ui: ${{ steps.changes.outputs.ts-ui }} -# steps: -# - uses: actions/checkout@v4 -# - id: changes -# name: Detect file changes -# run: | -# # Get changed files -# if [[ "${{ github.event_name }}" == "pull_request" ]]; then -# CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) -# else -# CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }}) -# fi - -# # Check each directory for changes -# echo "python-api=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-api/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# echo "python-service=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-service/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# echo "go-status=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-status/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT -# echo "ts-ui=$([[ $(echo "$CHANGED_FILES" | grep -E "^cluster-ui/.*") ]] && echo "true" || echo "false")" >> $GITHUB_OUTPUT - -# python-lint-api: -# needs: detect-changes -# if: needs.detect-changes.outputs.python-api == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: actions/setup-python@v5 -# with: -# python-version: '3.11' -# cache: 'pip' -# - name: Install Python linting tools -# working-directory: cluster-api -# run: | -# python -m pip install --upgrade pip -# pip install flake8 black isort pylint -# - name: Run Pylint -# working-directory: cluster-api -# run: | -# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - -# python-lint-service: -# needs: detect-changes -# if: needs.detect-changes.outputs.python-service == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: actions/setup-python@v5 -# with: -# python-version: '3.11' -# cache: 'pip' -# - name: Install Python linting tools -# working-directory: cluster-service -# run: | -# python -m pip install --upgrade pip -# pip install flake8 black isort pylint -# - name: Run Pylint -# working-directory: cluster-service -# run: | -# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - -# go-lint: -# needs: detect-changes -# if: needs.detect-changes.outputs.go-status == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: actions/setup-go@v5 -# with: -# go-version: '1.22' -# cache: true -# - name: Install Go tools -# run: | -# go install golang.org/x/tools/cmd/goimports@latest -# go install honnef.co/go/tools/cmd/staticcheck@latest -# go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -# echo "$HOME/go/bin" >> $GITHUB_PATH -# - name: Go Format Check -# working-directory: cluster-status -# run: | -# if [ -n "$(gofmt -l .)" ]; then -# echo "The following files need formatting:" -# gofmt -l . -# echo "Please run 'gofmt -w .' to format your code." -# exit 1 -# fi -# - name: Go Imports Check -# working-directory: cluster-status -# run: | -# if [ -n "$(goimports -l .)" ]; then -# echo "The following files have incorrect imports:" -# goimports -l . -# echo "Please run 'goimports -w .' to fix imports." -# exit 1 -# fi -# - name: Run golangci-lint -# working-directory: cluster-status -# run: golangci-lint run --timeout=5m -# - name: Run staticcheck -# working-directory: cluster-status -# run: staticcheck ./... - -# typescript-lint: -# needs: detect-changes -# if: needs.detect-changes.outputs.ts-ui == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: actions/setup-node@v4 -# with: -# node-version: '20' -# cache: 'npm' -# cache-dependency-path: cluster-ui/package-lock.json -# - name: Install Node.js dependencies -# working-directory: cluster-ui -# run: | -# npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin -# npm ci -# - name: Lint TypeScript -# working-directory: cluster-ui -# run: | -# npx tsc --noEmit -# npx eslint "**/*.{ts,tsx}" --fix -# - name: Lint JavaScript -# working-directory: cluster-ui -# run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file From 2c312f8cec25aec1bce95c4bf57b6ba0117e8b0a Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Tue, 4 Mar 2025 11:05:16 +0545 Subject: [PATCH 87/95] feat:lint --- .github/workflows/build.yaml | 31 +++ .github/workflows/lint.yaml | 364 ++++++++++++++++++++++++----------- cluster-api/Dockerfile | 2 +- 3 files changed, 286 insertions(+), 111 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..1b086da --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,31 @@ +name: Build and Push + +on: + workflow_call: + secrets: + REGISTRY_URL: + required: true + GCR_CRED: + required: true + ACCESS_TOKEN: + required: true + +jobs: + ecr-build-push: + runs-on: ubuntu-latest + name: Build and Push + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Build and Push + run: | + echo 'Docker login' + docker login -u ${{secrets.REGISTRY_USER}} -p "${{secrets.REGISTRY_PASSWORD}}" ${{secrets.REGISTRY_HOST}} + echo 'Running build...' + touch .env + echo "${{ secrets.ACCESS_TOKEN }}" > .id_rsa + export DOCKER_BUILDKIT=1 && eval `ssh-agent` && chmod 400 .id_rsa && ssh-add .id_rsa + docker build . --ssh default -t ${{secrets.REGISTRY_URL}}/${{github.event.repository.name}}:${{github.sha}} + echo 'Pushing Image...' + docker push ${{secrets.REGISTRY_URL}}/${{github.event.repository.name}}:${{github.sha}} + echo 'Done!' \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7868c9a..7255323 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,3 +1,225 @@ +# name: Multi-language Lint + +# on: +# push: +# paths: +# - 'cluster-api/**' +# - 'cluster-service/**' +# - 'cluster-status/**' +# - 'cluster-ui/**' +# branches: +# - '**' +# pull_request: +# paths: +# - 'cluster-api/**' +# - 'cluster-service/**' +# - 'cluster-status/**' +# - 'cluster-ui/**' +# workflow_dispatch: + +# jobs: +# changed_files: +# runs-on: ubuntu-latest +# outputs: +# python_api: ${{ steps.changes.outputs.cluster-api }} +# python_service: ${{ steps.changes.outputs.cluster-service }} +# go: ${{ steps.changes.outputs.cluster-status }} +# typescript: ${{ steps.changes.outputs.cluster-ui }} +# steps: +# - uses: actions/checkout@v4 +# with: +# fetch-depth: 0 + +# - name: Get changed files by directory +# id: changes +# run: | +# if [[ "${{ github.event_name }}" == "pull_request" ]]; then +# BASE_SHA=${{ github.event.pull_request.base.sha }} +# HEAD_SHA=${{ github.event.pull_request.head.sha }} +# else +# BASE_SHA=$(git rev-parse HEAD^) +# HEAD_SHA=$(git rev-parse HEAD) +# fi + +# echo "Checking changes between $BASE_SHA and $HEAD_SHA" + +# # Check each directory separately +# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-api/"; then +# echo "cluster-api=true" >> $GITHUB_OUTPUT +# else +# echo "cluster-api=false" >> $GITHUB_OUTPUT +# fi + +# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-service/"; then +# echo "cluster-service=true" >> $GITHUB_OUTPUT +# else +# echo "cluster-service=false" >> $GITHUB_OUTPUT +# fi + +# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-status/"; then +# echo "cluster-status=true" >> $GITHUB_OUTPUT +# else +# echo "cluster-status=false" >> $GITHUB_OUTPUT +# fi + +# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-ui/"; then +# echo "cluster-ui=true" >> $GITHUB_OUTPUT +# else +# echo "cluster-ui=false" >> $GITHUB_OUTPUT +# fi + +# cluster-api-lint: +# needs: changed_files +# if: needs.changed_files.outputs.python_api == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 + +# - name: Check for Python files +# id: check-python +# run: | +# if find cluster-api -name "*.py" -print -quit | grep -q .; then +# echo "has_python_files=true" >> $GITHUB_OUTPUT +# else +# echo "has_python_files=false" >> $GITHUB_OUTPUT +# fi + +# - name: Set up Python +# if: steps.check-python.outputs.has_python_files == 'true' +# uses: actions/setup-python@v5 +# with: +# python-version: '3.11' +# cache: 'pip' + +# - name: Install Python linting tools +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: cluster-api +# run: | +# python -m pip install --upgrade pip +# pip install flake8 black isort pylint + +# - name: Run Pylint +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: cluster-api +# run: | +# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + +# cluster-service-lint: +# needs: changed_files +# if: needs.changed_files.outputs.python_service == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 + +# - name: Check for Python files +# id: check-python +# run: | +# if find cluster-service -name "*.py" -print -quit | grep -q .; then +# echo "has_python_files=true" >> $GITHUB_OUTPUT +# else +# echo "has_python_files=false" >> $GITHUB_OUTPUT +# fi + +# - name: Set up Python +# if: steps.check-python.outputs.has_python_files == 'true' +# uses: actions/setup-python@v5 +# with: +# python-version: '3.11' +# cache: 'pip' + +# - name: Install Python linting tools +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: cluster-service +# run: | +# python -m pip install --upgrade pip +# pip install flake8 black isort pylint + +# - name: Run Pylint +# if: steps.check-python.outputs.has_python_files == 'true' +# working-directory: cluster-service +# run: | +# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + +# cluster-status-lint: +# needs: changed_files +# if: needs.changed_files.outputs.go == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 + +# - name: Set up Go +# uses: actions/setup-go@v5 +# with: +# go-version: '1.22' +# cache: true + +# - name: Install Go tools +# run: | +# go install golang.org/x/tools/cmd/goimports@latest +# go install honnef.co/go/tools/cmd/staticcheck@latest +# go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest +# echo "$HOME/go/bin" >> $GITHUB_PATH + +# - name: Go Format Check +# working-directory: cluster-status +# run: | +# if [ -n "$(gofmt -l .)" ]; then +# echo "The following files need formatting:" +# gofmt -l . +# echo "Please run 'gofmt -w .' to format your code." +# exit 1 +# fi + +# - name: Go Imports Check +# working-directory: cluster-status +# run: | +# if [ -n "$(goimports -l .)" ]; then +# echo "The following files have incorrect imports:" +# goimports -l . +# echo "Please run 'goimports -w .' to fix imports." +# exit 1 +# fi + +# - name: Run golangci-lint +# working-directory: cluster-status +# run: golangci-lint run --timeout=5m + +# - name: Run staticcheck +# working-directory: cluster-status +# run: staticcheck ./... + +# cluster-ui-lint: +# needs: changed_files +# if: needs.changed_files.outputs.typescript == 'true' +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 + +# - name: Set up Node.js +# uses: actions/setup-node@v4 +# with: +# node-version: '20' +# cache: 'npm' +# cache-dependency-path: cluster-ui/package-lock.json + +# - name: Install Node.js dependencies +# working-directory: cluster-ui +# run: | +# npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin +# npm ci + +# - name: Lint TypeScript +# working-directory: cluster-ui +# run: | +# npx tsc --noEmit +# npx eslint "**/*.{ts,tsx}" --fix + +# - name: Lint JavaScript +# working-directory: cluster-ui +# run: npx eslint "**/*.{js,jsx}" --fix + + + name: Multi-language Lint on: @@ -17,6 +239,8 @@ on: - 'cluster-ui/**' workflow_dispatch: + + jobs: changed_files: runs-on: ubuntu-latest @@ -103,117 +327,37 @@ jobs: working-directory: cluster-api run: | find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - - cluster-service-lint: - needs: changed_files - if: needs.changed_files.outputs.python_service == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Check for Python files - id: check-python - run: | - if find cluster-service -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - - - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: cluster-service - run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: cluster-service - run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - - cluster-status-lint: - needs: changed_files - if: needs.changed_files.outputs.go == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: true - - - name: Install Go tools - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install honnef.co/go/tools/cmd/staticcheck@latest - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - echo "$HOME/go/bin" >> $GITHUB_PATH - - - name: Go Format Check - working-directory: cluster-status - run: | - if [ -n "$(gofmt -l .)" ]; then - echo "The following files need formatting:" - gofmt -l . - echo "Please run 'gofmt -w .' to format your code." - exit 1 - fi - - - name: Go Imports Check - working-directory: cluster-status + - name: Docker Build and Push + if: github.event_name != 'pull_request' + working-directory: cluster-api run: | - if [ -n "$(goimports -l .)" ]; then - echo "The following files have incorrect imports:" - goimports -l . - echo "Please run 'goimports -w .' to fix imports." - exit 1 + echo "Docker login to $REGISTRY_HOST" + echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin "$REGISTRY_HOST" + + echo "Preparing build environment" + touch .env + + # Only create SSH key if ACCESS_TOKEN is provided + if [ -n "$ACCESS_TOKEN" ]; then + echo "$ACCESS_TOKEN" > .id_rsa + chmod 400 .id_rsa + eval `ssh-agent` + ssh-add .id_rsa + DOCKER_BUILD_ARGS="--ssh default" + else + DOCKER_BUILD_ARGS="" fi + + echo "Building Docker image" + export DOCKER_BUILDKIT=1 + docker build . ${DOCKER_BUILD_ARGS} -t "$REGISTRY_URL/cluster-api:${{ github.sha }}" -t "$REGISTRY_URL/cluster-api:latest" + + echo "Pushing Docker image" + docker push "$REGISTRY_URL/cluster-api:${{ github.sha }}" + docker push "$REGISTRY_URL/cluster-api:latest" + + echo "Clean up" + if [ -f .id_rsa ]; then rm .id_rsa; fi - - name: Run golangci-lint - working-directory: cluster-status - run: golangci-lint run --timeout=5m - - - name: Run staticcheck - working-directory: cluster-status - run: staticcheck ./... - - cluster-ui-lint: - needs: changed_files - if: needs.changed_files.outputs.typescript == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: cluster-ui/package-lock.json - - - name: Install Node.js dependencies - working-directory: cluster-ui - run: | - npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin - npm ci - - - name: Lint TypeScript - working-directory: cluster-ui - run: | - npx tsc --noEmit - npx eslint "**/*.{ts,tsx}" --fix - - - name: Lint JavaScript - working-directory: cluster-ui - run: npx eslint "**/*.{js,jsx}" --fix \ No newline at end of file + \ No newline at end of file diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index e8df47d..d2fd816 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From 066212d03300b7cb4161908383db3c299b33926b Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Tue, 4 Mar 2025 11:07:44 +0545 Subject: [PATCH 88/95] feat:lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index d2fd816..39cffcb 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt . RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . From 0551ff881736faa55b47c63db926d4c2f14fd632 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Tue, 4 Mar 2025 15:22:48 +0545 Subject: [PATCH 89/95] feat:lint --- .github/workflows/build.yaml | 31 -- .github/workflows/cluster-pipeline.yaml | 436 ++++++++++++++++++++++++ .github/workflows/gitleaks.yaml | 34 -- .github/workflows/lint.yaml | 363 -------------------- cluster-status/Dockerfile | 2 +- 5 files changed, 437 insertions(+), 429 deletions(-) delete mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/cluster-pipeline.yaml delete mode 100644 .github/workflows/gitleaks.yaml delete mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 1b086da..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Build and Push - -on: - workflow_call: - secrets: - REGISTRY_URL: - required: true - GCR_CRED: - required: true - ACCESS_TOKEN: - required: true - -jobs: - ecr-build-push: - runs-on: ubuntu-latest - name: Build and Push - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Build and Push - run: | - echo 'Docker login' - docker login -u ${{secrets.REGISTRY_USER}} -p "${{secrets.REGISTRY_PASSWORD}}" ${{secrets.REGISTRY_HOST}} - echo 'Running build...' - touch .env - echo "${{ secrets.ACCESS_TOKEN }}" > .id_rsa - export DOCKER_BUILDKIT=1 && eval `ssh-agent` && chmod 400 .id_rsa && ssh-add .id_rsa - docker build . --ssh default -t ${{secrets.REGISTRY_URL}}/${{github.event.repository.name}}:${{github.sha}} - echo 'Pushing Image...' - docker push ${{secrets.REGISTRY_URL}}/${{github.event.repository.name}}:${{github.sha}} - echo 'Done!' \ No newline at end of file diff --git a/.github/workflows/cluster-pipeline.yaml b/.github/workflows/cluster-pipeline.yaml new file mode 100644 index 0000000..5a3a767 --- /dev/null +++ b/.github/workflows/cluster-pipeline.yaml @@ -0,0 +1,436 @@ +name: Multi-language Lint + +on: + push: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' + branches: + - '**' + pull_request: + paths: + - 'cluster-api/**' + - 'cluster-service/**' + - 'cluster-status/**' + - 'cluster-ui/**' + workflow_dispatch: + + +jobs: + changed_files: + runs-on: ubuntu-latest + outputs: + python_api: ${{ steps.changes.outputs.cluster-api }} + python_service: ${{ steps.changes.outputs.cluster-service }} + go: ${{ steps.changes.outputs.cluster-status }} + typescript: ${{ steps.changes.outputs.cluster-ui }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get changed files by directory + id: changes + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + BASE_SHA=${{ github.event.pull_request.base.sha }} + HEAD_SHA=${{ github.event.pull_request.head.sha }} + else + BASE_SHA=$(git rev-parse HEAD^) + HEAD_SHA=$(git rev-parse HEAD) + fi + + echo "Checking changes between $BASE_SHA and $HEAD_SHA" + + # Check each directory separately + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-api/"; then + echo "cluster-api=true" >> $GITHUB_OUTPUT + else + echo "cluster-api=false" >> $GITHUB_OUTPUT + fi + + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-service/"; then + echo "cluster-service=true" >> $GITHUB_OUTPUT + else + echo "cluster-service=false" >> $GITHUB_OUTPUT + fi + + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-status/"; then + echo "cluster-status=true" >> $GITHUB_OUTPUT + else + echo "cluster-status=false" >> $GITHUB_OUTPUT + fi + + if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-ui/"; then + echo "cluster-ui=true" >> $GITHUB_OUTPUT + else + echo "cluster-ui=false" >> $GITHUB_OUTPUT + fi + + cluster-api-lint: + needs: changed_files + if: needs.changed_files.outputs.python_api == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Check for Python files + id: check-python + run: | + if find cluster-api -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-api + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-api + run: | + find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" + gitleaks-cluster-api: + name: GitLeaks Security Scan + runs-on: ubuntu-latest + needs: cluster-api-lint + permissions: + security-events: write + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run GitLeaks + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + config-path: .gitleaks.toml + enable-upload-artifact: true + report-format: sarif + report-path: gitleaks-report.sarif + + cluster-api-build: + runs-on: ubuntu-latest + needs: gitleaks-cluster-api + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v4 + - name: Docker Build and Push + if: github.event_name != 'pull_request' + working-directory: cluster-api + env: + CLUSTER_API_REGISTRY_URL: ${{secrets.CLUSTER_API_REGISTRY_URL}} + CLUSTER_API_REGISTRY_USER: ${{secrets.CLUSTER_API_REGISTRY_USER}} + CLUSTER_API_REGISTRY_PASSWORD: ${{secrets.CLUSTER_API_REGISTRY_PASSWORD}} + + run: | + echo "Docker login to $REGISTRY_HOST" + + + docker login -u ${{secrets.CLUSTER_API_REGISTRY_USER}} -p "${{secrets.CLUSTER_API_REGISTRY_PASSWORD}}" + + echo "Building Docker image" + docker build . -t ${{secrets.CLUSTER_API_REGISTRY_URL}}:${{ github.sha }} -t ${{secrets.CLUSTER_API_REGISTRY_URL}}:latest + + echo "Pushing Docker image" + docker push ${{secrets.CLUSTER_API_REGISTRY_URL}}:${{ github.sha }} + docker push ${{secrets.CLUSTER_API_REGISTRY_URL}}:latest + + echo "Clean up" + if [ -f .id_rsa ]; then rm .id_rsa; fi + + cluster-service-lint: + needs: changed_files + if: needs.changed_files.outputs.python_service == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Check for Python files + id: check-python + run: | + if find cluster-service -name "*.py" -print -quit | grep -q .; then + echo "has_python_files=true" >> $GITHUB_OUTPUT + else + echo "has_python_files=false" >> $GITHUB_OUTPUT + fi + + - name: Set up Python + if: steps.check-python.outputs.has_python_files == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python linting tools + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-service + run: | + python -m pip install --upgrade pip + pip install flake8 black isort pylint + + - name: Run Pylint + if: steps.check-python.outputs.has_python_files == 'true' + working-directory: cluster-service + run: | + + gitleaks-cluster-service: + name: GitLeaks Security Scan + runs-on: ubuntu-latest + needs: cluster-service-lint + permissions: + security-events: write + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run GitLeaks + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + config-path: .gitleaks.toml + enable-upload-artifact: true + report-format: sarif + report-path: gitleaks-report.sarif + + cluster-service-build: + runs-on: ubuntu-latest + needs: gitleaks-cluster-service + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v4 + - name: Docker Build and Push + if: github.event_name != 'pull_request' + working-directory: cluster-api + env: + CLUSTER_SERIVCE_REGISTRY_URL: ${{secrets.CLUSTER_SERVICE_REGISTRY_URL}} + CLUSTER_SERIVCE_REGISTRY_USER: ${{secrets.CLUSTER_SERVICE_REGISTRY_USER}} + CLUSTER_SERIVCE_REGISTRY_PASSWORD: ${{secrets.CLUSTER_SERVICE_REGISTRY_PASSWORD}} + + run: | + echo "Docker login to $REGISTRY_HOST" + + + docker login -u ${{secrets.CLUSTER_SERVICE_REGISTRY_USER}} -p "${{secrets.CLUSTER_SERVICE_REGISTRY_PASSWORD}}" + + echo "Building Docker image" + docker build . -t ${{secrets.CLUSTER_SERVICE_REGISTRY_URL}}:${{ github.sha }} -t ${{secrets.CLUSTER_SERVICE_REGISTRY_URL}}:latest + + echo "Pushing Docker image" + docker push ${{secrets.CLUSTER_SERVICE_REGISTRY_URL}}:${{ github.sha }} + docker push ${{secrets.CLUSTER_SERVICE_REGISTRY_URL}}:latest + + echo "Clean up" + if [ -f .id_rsa ]; then rm .id_rsa; fi + + cluster-status-lint: + needs: changed_files + if: needs.changed_files.outputs.go == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: true + + - name: Install Go tools + run: | + go install golang.org/x/tools/cmd/goimports@latest + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Go Format Check + working-directory: cluster-status + run: | + if [ -n "$(gofmt -l .)" ]; then + echo "The following files need formatting:" + gofmt -l . + echo "Please run 'gofmt -w .' to format your code." + exit 1 + fi + + - name: Go Imports Check + working-directory: cluster-status + run: | + if [ -n "$(goimports -l .)" ]; then + echo "The following files have incorrect imports:" + goimports -l . + echo "Please run 'goimports -w .' to fix imports." + exit 1 + fi + + - name: Run golangci-lint + working-directory: cluster-status + run: golangci-lint run --timeout=5m + + - name: Run staticcheck + working-directory: cluster-status + run: staticcheck ./... + + gitleaks-cluster-status: + name: GitLeaks Security Scan + runs-on: ubuntu-latest + needs: cluster-status-lint + permissions: + security-events: write + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run GitLeaks + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + config-path: .gitleaks.toml + enable-upload-artifact: true + report-format: sarif + report-path: gitleaks-report.sarif + + cluster-status-build: + runs-on: ubuntu-latest + needs: gitleaks-cluster-status + # if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v4 + - name: Docker Build and Push + if: github.event_name != 'pull_request' + working-directory: cluster-api + env: + CLUSTER_STATUS_REGISTRY_URL: ${{secrets.CLUSTER_STATUS_REGISTRY_URL}} + CLUSTER_STATUS_REGISTRY_USER: ${{secrets.CLUSTER_STATUS_REGISTRY_USER}} + CLUSTER_STATUS_REGISTRY_PASSWORD: ${{secrets.CLUSTER_STATUS_REGISTRY_PASSWORD}} + + run: | + echo "Docker login to $REGISTRY_HOST" + + + docker login -u ${{secrets.CLUSTER_STATUS_REGISTRY_USER}} -p "${{secrets.CLUSTER_STATUS_REGISTRY_PASSWORD}}" + + echo "Building Docker image" + docker build . -t ${{secrets.CLUSTER_STATUS_REGISTRY_URL}}:${{ github.sha }} -t ${{secrets.CLUSTER_STATUS_REGISTRY_URL}}:latest + + echo "Pushing Docker image" + docker push ${{secrets.CLUSTER_STATUS_REGISTRY_URL}}:${{ github.sha }} + docker push ${{secrets.CLUSTER_STATUS_REGISTRY_URL}}:latest + + echo "Clean up" + if [ -f .id_rsa ]; then rm .id_rsa; fi + + cluster-ui-lint: + needs: changed_files + if: needs.changed_files.outputs.typescript == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: cluster-ui/package-lock.json + + - name: Install Node.js dependencies + working-directory: cluster-ui + run: | + npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin + npm ci + + - name: Lint TypeScript + working-directory: cluster-ui + run: | + npx tsc --noEmit + npx eslint "**/*.{ts,tsx}" --fix + + - name: Lint JavaScript + working-directory: cluster-ui + run: npx eslint "**/*.{js,jsx}" --fix + gitleaks-cluster-ui: + name: GitLeaks Security Scan + runs-on: ubuntu-latest + needs: cluster-ui-lint + permissions: + security-events: write + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run GitLeaks + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + config-path: .gitleaks.toml + enable-upload-artifact: true + report-format: sarif + report-path: gitleaks-report.sarif + + cluster-ui-build: + runs-on: ubuntu-latest + needs: gitleaks-cluster-ui + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v4 + - name: Docker Build and Push + if: github.event_name != 'pull_request' + working-directory: cluster-api + env: + CLUSTER_UI_REGISTRY_URL: ${{secrets.CLUSTER_UI_REGISTRY_URL}} + CLUSTER_UI_REGISTRY_USER: ${{secrets.CLUSTER_UI_REGISTRY_USER}} + CLUSTER_UI_REGISTRY_PASSWORD: ${{secrets.CLUSTER_UI_REGISTRY_PASSWORD}} + + run: | + echo "Docker login to $REGISTRY_HOST" + + + docker login -u ${{secrets.CLUSTER_UI_REGISTRY_USER}} -p "${{secrets.CLUSTER_UI_REGISTRY_PASSWORD}}" + + echo "Building Docker image" + docker build . -t ${{secrets.CLUSTER_UI_REGISTRY_URL}}:${{ github.sha }} -t ${{secrets.CLUSTER_UI_REGISTRY_URL}}:latest + + echo "Pushing Docker image" + docker push ${{secrets.CLUSTER_UI_REGISTRY_URL}}:${{ github.sha }} + docker push ${{secrets.CLUSTER_UI_REGISTRY_URL}}:latest + + echo "Clean up" + if [ -f .id_rsa ]; then rm .id_rsa; fi + + + \ No newline at end of file diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml deleted file mode 100644 index 64becc4..0000000 --- a/.github/workflows/gitleaks.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: GitLeaks Scan - -on: - push: - branches: - - '**' - pull_request: - workflow_dispatch: - -jobs: - gitleaks: - name: GitLeaks Security Scan - runs-on: ubuntu-latest - permissions: - security-events: write - contents: read - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Run GitLeaks - uses: gitleaks/gitleaks-action@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - config-path: .gitleaks.toml - enable-upload-artifact: true - report-format: sarif - report-path: gitleaks-report.sarif - - \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 7255323..0000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,363 +0,0 @@ -# name: Multi-language Lint - -# on: -# push: -# paths: -# - 'cluster-api/**' -# - 'cluster-service/**' -# - 'cluster-status/**' -# - 'cluster-ui/**' -# branches: -# - '**' -# pull_request: -# paths: -# - 'cluster-api/**' -# - 'cluster-service/**' -# - 'cluster-status/**' -# - 'cluster-ui/**' -# workflow_dispatch: - -# jobs: -# changed_files: -# runs-on: ubuntu-latest -# outputs: -# python_api: ${{ steps.changes.outputs.cluster-api }} -# python_service: ${{ steps.changes.outputs.cluster-service }} -# go: ${{ steps.changes.outputs.cluster-status }} -# typescript: ${{ steps.changes.outputs.cluster-ui }} -# steps: -# - uses: actions/checkout@v4 -# with: -# fetch-depth: 0 - -# - name: Get changed files by directory -# id: changes -# run: | -# if [[ "${{ github.event_name }}" == "pull_request" ]]; then -# BASE_SHA=${{ github.event.pull_request.base.sha }} -# HEAD_SHA=${{ github.event.pull_request.head.sha }} -# else -# BASE_SHA=$(git rev-parse HEAD^) -# HEAD_SHA=$(git rev-parse HEAD) -# fi - -# echo "Checking changes between $BASE_SHA and $HEAD_SHA" - -# # Check each directory separately -# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-api/"; then -# echo "cluster-api=true" >> $GITHUB_OUTPUT -# else -# echo "cluster-api=false" >> $GITHUB_OUTPUT -# fi - -# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-service/"; then -# echo "cluster-service=true" >> $GITHUB_OUTPUT -# else -# echo "cluster-service=false" >> $GITHUB_OUTPUT -# fi - -# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-status/"; then -# echo "cluster-status=true" >> $GITHUB_OUTPUT -# else -# echo "cluster-status=false" >> $GITHUB_OUTPUT -# fi - -# if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-ui/"; then -# echo "cluster-ui=true" >> $GITHUB_OUTPUT -# else -# echo "cluster-ui=false" >> $GITHUB_OUTPUT -# fi - -# cluster-api-lint: -# needs: changed_files -# if: needs.changed_files.outputs.python_api == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 - -# - name: Check for Python files -# id: check-python -# run: | -# if find cluster-api -name "*.py" -print -quit | grep -q .; then -# echo "has_python_files=true" >> $GITHUB_OUTPUT -# else -# echo "has_python_files=false" >> $GITHUB_OUTPUT -# fi - -# - name: Set up Python -# if: steps.check-python.outputs.has_python_files == 'true' -# uses: actions/setup-python@v5 -# with: -# python-version: '3.11' -# cache: 'pip' - -# - name: Install Python linting tools -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: cluster-api -# run: | -# python -m pip install --upgrade pip -# pip install flake8 black isort pylint - -# - name: Run Pylint -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: cluster-api -# run: | -# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - -# cluster-service-lint: -# needs: changed_files -# if: needs.changed_files.outputs.python_service == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 - -# - name: Check for Python files -# id: check-python -# run: | -# if find cluster-service -name "*.py" -print -quit | grep -q .; then -# echo "has_python_files=true" >> $GITHUB_OUTPUT -# else -# echo "has_python_files=false" >> $GITHUB_OUTPUT -# fi - -# - name: Set up Python -# if: steps.check-python.outputs.has_python_files == 'true' -# uses: actions/setup-python@v5 -# with: -# python-version: '3.11' -# cache: 'pip' - -# - name: Install Python linting tools -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: cluster-service -# run: | -# python -m pip install --upgrade pip -# pip install flake8 black isort pylint - -# - name: Run Pylint -# if: steps.check-python.outputs.has_python_files == 'true' -# working-directory: cluster-service -# run: | -# find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - -# cluster-status-lint: -# needs: changed_files -# if: needs.changed_files.outputs.go == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 - -# - name: Set up Go -# uses: actions/setup-go@v5 -# with: -# go-version: '1.22' -# cache: true - -# - name: Install Go tools -# run: | -# go install golang.org/x/tools/cmd/goimports@latest -# go install honnef.co/go/tools/cmd/staticcheck@latest -# go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -# echo "$HOME/go/bin" >> $GITHUB_PATH - -# - name: Go Format Check -# working-directory: cluster-status -# run: | -# if [ -n "$(gofmt -l .)" ]; then -# echo "The following files need formatting:" -# gofmt -l . -# echo "Please run 'gofmt -w .' to format your code." -# exit 1 -# fi - -# - name: Go Imports Check -# working-directory: cluster-status -# run: | -# if [ -n "$(goimports -l .)" ]; then -# echo "The following files have incorrect imports:" -# goimports -l . -# echo "Please run 'goimports -w .' to fix imports." -# exit 1 -# fi - -# - name: Run golangci-lint -# working-directory: cluster-status -# run: golangci-lint run --timeout=5m - -# - name: Run staticcheck -# working-directory: cluster-status -# run: staticcheck ./... - -# cluster-ui-lint: -# needs: changed_files -# if: needs.changed_files.outputs.typescript == 'true' -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 - -# - name: Set up Node.js -# uses: actions/setup-node@v4 -# with: -# node-version: '20' -# cache: 'npm' -# cache-dependency-path: cluster-ui/package-lock.json - -# - name: Install Node.js dependencies -# working-directory: cluster-ui -# run: | -# npm install -g eslint@^8.56.0 typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin -# npm ci - -# - name: Lint TypeScript -# working-directory: cluster-ui -# run: | -# npx tsc --noEmit -# npx eslint "**/*.{ts,tsx}" --fix - -# - name: Lint JavaScript -# working-directory: cluster-ui -# run: npx eslint "**/*.{js,jsx}" --fix - - - -name: Multi-language Lint - -on: - push: - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' - branches: - - '**' - pull_request: - paths: - - 'cluster-api/**' - - 'cluster-service/**' - - 'cluster-status/**' - - 'cluster-ui/**' - workflow_dispatch: - - - -jobs: - changed_files: - runs-on: ubuntu-latest - outputs: - python_api: ${{ steps.changes.outputs.cluster-api }} - python_service: ${{ steps.changes.outputs.cluster-service }} - go: ${{ steps.changes.outputs.cluster-status }} - typescript: ${{ steps.changes.outputs.cluster-ui }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Get changed files by directory - id: changes - run: | - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - BASE_SHA=${{ github.event.pull_request.base.sha }} - HEAD_SHA=${{ github.event.pull_request.head.sha }} - else - BASE_SHA=$(git rev-parse HEAD^) - HEAD_SHA=$(git rev-parse HEAD) - fi - - echo "Checking changes between $BASE_SHA and $HEAD_SHA" - - # Check each directory separately - if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-api/"; then - echo "cluster-api=true" >> $GITHUB_OUTPUT - else - echo "cluster-api=false" >> $GITHUB_OUTPUT - fi - - if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-service/"; then - echo "cluster-service=true" >> $GITHUB_OUTPUT - else - echo "cluster-service=false" >> $GITHUB_OUTPUT - fi - - if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-status/"; then - echo "cluster-status=true" >> $GITHUB_OUTPUT - else - echo "cluster-status=false" >> $GITHUB_OUTPUT - fi - - if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^cluster-ui/"; then - echo "cluster-ui=true" >> $GITHUB_OUTPUT - else - echo "cluster-ui=false" >> $GITHUB_OUTPUT - fi - - cluster-api-lint: - needs: changed_files - if: needs.changed_files.outputs.python_api == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Check for Python files - id: check-python - run: | - if find cluster-api -name "*.py" -print -quit | grep -q .; then - echo "has_python_files=true" >> $GITHUB_OUTPUT - else - echo "has_python_files=false" >> $GITHUB_OUTPUT - fi - - - name: Set up Python - if: steps.check-python.outputs.has_python_files == 'true' - uses: actions/setup-python@v5 - with: - python-version: '3.11' - cache: 'pip' - - - name: Install Python linting tools - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: cluster-api - run: | - python -m pip install --upgrade pip - pip install flake8 black isort pylint - - - name: Run Pylint - if: steps.check-python.outputs.has_python_files == 'true' - working-directory: cluster-api - run: | - find . -type f -name "*.py" -not -path "*/\.*" -exec pylint {} + || echo "Linting completed with warnings" - - - name: Docker Build and Push - if: github.event_name != 'pull_request' - working-directory: cluster-api - run: | - echo "Docker login to $REGISTRY_HOST" - echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin "$REGISTRY_HOST" - - echo "Preparing build environment" - touch .env - - # Only create SSH key if ACCESS_TOKEN is provided - if [ -n "$ACCESS_TOKEN" ]; then - echo "$ACCESS_TOKEN" > .id_rsa - chmod 400 .id_rsa - eval `ssh-agent` - ssh-add .id_rsa - DOCKER_BUILD_ARGS="--ssh default" - else - DOCKER_BUILD_ARGS="" - fi - - echo "Building Docker image" - export DOCKER_BUILDKIT=1 - docker build . ${DOCKER_BUILD_ARGS} -t "$REGISTRY_URL/cluster-api:${{ github.sha }}" -t "$REGISTRY_URL/cluster-api:latest" - - echo "Pushing Docker image" - docker push "$REGISTRY_URL/cluster-api:${{ github.sha }}" - docker push "$REGISTRY_URL/cluster-api:latest" - - echo "Clean up" - if [ -f .id_rsa ]; then rm .id_rsa; fi - - \ No newline at end of file diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 8b3395a..3914108 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -9,4 +9,4 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +CMD ["./main"] \ No newline at end of file From daaff51144806fdd2a42f08ebc7c06836c3e3363 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Tue, 4 Mar 2025 15:27:16 +0545 Subject: [PATCH 90/95] feat:lint --- cluster-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 39cffcb..402b624 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -10,7 +10,7 @@ ENV PYTHONUNBUFFERED=1 # Install pip requirements COPY requirements.txt . -RUN python -m pip install -r requirements.txt +RUN python -m pip install -r requirements.txt WORKDIR /app COPY . /app From 9b0224da3773352c669b8f21939ac2edfecce5b0 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Tue, 4 Mar 2025 15:28:43 +0545 Subject: [PATCH 91/95] feat:lint --- cluster-service/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-service/main.py b/cluster-service/main.py index 7aa36c5..baf4746 100644 --- a/cluster-service/main.py +++ b/cluster-service/main.py @@ -14,4 +14,4 @@ def create_app(): logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") logging.info("Starting the Flask application...") # Run the app - app.run(port=8082, host="0.0.0.0") \ No newline at end of file + app.run(port=8082, host="0.0.0.0") \ No newline at end of file From 0cde1fdf6c0bb14ae5837cb9d950b7b84290d250 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Tue, 4 Mar 2025 15:30:00 +0545 Subject: [PATCH 92/95] feat:lint --- .github/workflows/cluster-pipeline.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cluster-pipeline.yaml b/.github/workflows/cluster-pipeline.yaml index 5a3a767..465d321 100644 --- a/.github/workflows/cluster-pipeline.yaml +++ b/.github/workflows/cluster-pipeline.yaml @@ -322,7 +322,7 @@ jobs: cluster-status-build: runs-on: ubuntu-latest needs: gitleaks-cluster-status - # if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' steps: - uses: actions/checkout@v4 - name: Docker Build and Push From 10bc09a4013ff82ebaa5f590eba80f52507c7a9c Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Tue, 4 Mar 2025 15:32:26 +0545 Subject: [PATCH 93/95] feat:lint --- .github/workflows/cluster-pipeline.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cluster-pipeline.yaml b/.github/workflows/cluster-pipeline.yaml index 465d321..ad798d4 100644 --- a/.github/workflows/cluster-pipeline.yaml +++ b/.github/workflows/cluster-pipeline.yaml @@ -1,4 +1,4 @@ -name: Multi-language Lint +name: Cluster Pipeline on: push: From 977d967c9953b727b4ebea82f2db9742c815a181 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 6 Mar 2025 12:02:40 +0545 Subject: [PATCH 94/95] fix: dockerfile --- cluster-api/Dockerfile | 20 +++++++++----------- cluster-service/Dockerfile | 13 +++++-------- cluster-service/main.py | 2 +- cluster-status/Dockerfile | 4 ++-- cluster-status/main.go | 32 +++++++++++++++----------------- cluster-ui/Dockerfile | 4 ++-- 6 files changed, 34 insertions(+), 41 deletions(-) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 402b624..2e0c994 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -1,22 +1,20 @@ FROM python:3.8-slim - EXPOSE 8002 - # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 # Turns off buffering for easier container logging ENV PYTHONUNBUFFERED=1 - + # Install pip requirements -COPY requirements.txt . -RUN python -m pip install -r requirements.txt - -WORKDIR /app -COPY . /app - -# Install your app +COPY requirements.txt . +RUN python -m pip install -r requirements.txt + +WORKDIR /app +COPY . /app + +# Install your app COPY . . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Install your app -CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file +CMD python -m uvicorn main:app --host 0.0.0.0 --port 8081 \ No newline at end of file diff --git a/cluster-service/Dockerfile b/cluster-service/Dockerfile index b26a06b..53ae007 100644 --- a/cluster-service/Dockerfile +++ b/cluster-service/Dockerfile @@ -1,21 +1,18 @@ FROM python:3.8-slim - EXPOSE 8002 - # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 - # Turns off buffering for easier container logging ENV PYTHONUNBUFFERED=1 # Install pip requirements -COPY requirements.txt . -RUN python -m pip install -r requirements.txt +COPY requirements.txt . +RUN python -m pip install -r requirements.txt WORKDIR /app -COPY . /app +COPY . /app # Install your app COPY . . -RUN pip install --no-cache-dir --upgrade -r requirements.txt -CMD python main.py +RUN pip install --no-cache-dir --upgrade -r requirements.txt +CMD python main.py \ No newline at end of file diff --git a/cluster-service/main.py b/cluster-service/main.py index baf4746..7aa36c5 100644 --- a/cluster-service/main.py +++ b/cluster-service/main.py @@ -14,4 +14,4 @@ def create_app(): logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") logging.info("Starting the Flask application...") # Run the app - app.run(port=8082, host="0.0.0.0") \ No newline at end of file + app.run(port=8082, host="0.0.0.0") \ No newline at end of file diff --git a/cluster-status/Dockerfile b/cluster-status/Dockerfile index 3914108..75b3df7 100644 --- a/cluster-status/Dockerfile +++ b/cluster-status/Dockerfile @@ -8,5 +8,5 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o main FROM alpine:3.18 WORKDIR /app -COPY --from=builder /app/main . -CMD ["./main"] \ No newline at end of file +COPY --from=builder /app/main . +CMD ["./main"] \ No newline at end of file diff --git a/cluster-status/main.go b/cluster-status/main.go index 1121f36..a4312cf 100644 --- a/cluster-status/main.go +++ b/cluster-status/main.go @@ -23,17 +23,12 @@ import ( "k8s.io/klog" ) -// Controller manages the processing of pods in the Kubernetes cluster. -// It uses an indexer for caching, a workqueue for processing items, -// and an informer for receiving cluster events. type Controller struct { indexer cache.Indexer queue workqueue.RateLimitingInterface informer cache.Controller } -// NewController creates a new Controller instance with the provided queue, -// indexer and informer for managing pod events in the cluster. func NewController(queue workqueue.RateLimitingInterface, indexer cache.Indexer, informer cache.Controller) *Controller { return &Controller{ informer: informer, @@ -75,6 +70,10 @@ func (c *Controller) syncToStdout(key string) error { fmt.Printf("Pod %s does not exist anymore\n", key) } else { pod := obj.(*v1.Pod) + // Note that you also have to check the uid if you have a local controlled resource, which + // is dependent on the actual instance, to detect that a Pod was recreated with the same name + // fmt.Printf("Sync/Add/Update for Pod %s Status %v \n ", pod.GetName(), pod.Status.Phase) + // fmt.Printf("Sync/Add/Update for Pod %s Status %v Label {\"status-controller-vcluster\": \"cluster-manager\"}\n", pod.GetName(), pod.Status.Phase) if pod.Labels["status-controller-vcluster"] == "cluster-manager" { for key, value := range pod.ObjectMeta.Labels { if key == "status-controller" { @@ -86,8 +85,12 @@ func (c *Controller) syncToStdout(key string) error { if containerState.Waiting != nil { waitingReason := containerState.Waiting.Reason switch waitingReason { - case "ImagePullBackOff", "OOMKilled", "ContainerConfigError", "CrashLoopBackOff": + case "ImagePullBackOff": + case "OOMKilled": + case "ContainerConfigError": + case "CrashLoopBackOff": statusString = waitingReason + break default: statusString = "Pending" } @@ -100,17 +103,16 @@ func (c *Controller) syncToStdout(key string) error { } } fmt.Printf("Container %s Status: %s\n", pod.Name, statusString) - if err := patchClusterStatus(pod.Name, value, statusString); err != nil { - klog.Errorf("Failed to patch cluster status: %v", err) - return err - } + patchClusterStatus(pod.Name, value, statusString) } } } + } return nil } +// handleErr checks if an error happened and makes sure we will retry later. func (c *Controller) handleErr(err error, key interface{}) { if err == nil { // Forget about the #AddRateLimited history of the key on every successful synchronization. @@ -136,8 +138,6 @@ func (c *Controller) handleErr(err error, key interface{}) { klog.Infof("Dropping pod %q out of the queue: %v", key, err) } -// Run starts the controller with the specified number of workers and runs until stopped. -// It manages the worker routines and ensures proper shutdown. func (c *Controller) Run(threadiness int, stopCh chan struct{}) { defer runtime.HandleCrash() @@ -218,14 +218,12 @@ func main() { // Let's suppose that we knew about a pod "mypod" on our last run, therefore add it to the cache. // If this pod is not there anymore, the controller will be notified about the removal after the // cache has synchronized. - if err := indexer.Add(&v1.Pod{ + indexer.Add(&v1.Pod{ ObjectMeta: meta_v1.ObjectMeta{ Name: "mypod", Namespace: v1.NamespaceDefault, }, - }); err != nil { - klog.Errorf("Failed to add pod to indexer: %v", err) - } + }) // Now let's start the controller stop := make(chan struct{}) @@ -273,7 +271,7 @@ func patchClusterStatus(name, id, status string) error { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return fmt.Errorf("request failed with status code: %d", resp.StatusCode) + return fmt.Errorf("Request failed with status code: %d", resp.StatusCode) } logrus.Info("Request successful") return nil diff --git a/cluster-ui/Dockerfile b/cluster-ui/Dockerfile index b8940ec..0609dbe 100644 --- a/cluster-ui/Dockerfile +++ b/cluster-ui/Dockerfile @@ -14,7 +14,7 @@ RUN npm install --legacy-peer-deps # 4. Copy the source code to /app dir COPY . . - + # 5. Build the TypeScript code and then run vite build RUN npm run build @@ -22,4 +22,4 @@ RUN npm run build EXPOSE 3000 # 7. Run the app -CMD ["npm", "run", "preview"] +CMD ["npm", "run", "preview"] \ No newline at end of file From d4a613d02e166499c62e10417851b59f6f52bd36 Mon Sep 17 00:00:00 2001 From: DevOps Npetune Date: Thu, 6 Mar 2025 12:05:16 +0545 Subject: [PATCH 95/95] fix: dockerfile --- cluster-api/Dockerfile | 2 ++ cluster-service/Dockerfile | 3 +++ 2 files changed, 5 insertions(+) diff --git a/cluster-api/Dockerfile b/cluster-api/Dockerfile index 2e0c994..8059524 100644 --- a/cluster-api/Dockerfile +++ b/cluster-api/Dockerfile @@ -1,5 +1,7 @@ FROM python:3.8-slim + EXPOSE 8002 + # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 diff --git a/cluster-service/Dockerfile b/cluster-service/Dockerfile index 53ae007..63c39ec 100644 --- a/cluster-service/Dockerfile +++ b/cluster-service/Dockerfile @@ -1,7 +1,10 @@ FROM python:3.8-slim + EXPOSE 8002 + # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 + # Turns off buffering for easier container logging ENV PYTHONUNBUFFERED=1