From 44f329d3c7e404752cc3b9c7271c05e207395736 Mon Sep 17 00:00:00 2001 From: NeoPilot Date: Wed, 3 Dec 2025 21:45:36 +0600 Subject: [PATCH] chore: update CI/CD pipeline, add PR template, and improve documentation --- .../pull_request_template.md | 28 ++++++++++ .github/workflows/scans_ci.yml | 43 ++++++++++---- README.md | 56 ++++++++++++++++++- plugins/aws/eks/eksKubernetesVersion.spec.js | 2 +- .../automationAcctExpiredWebhooks.spec.js | 3 +- 5 files changed, 117 insertions(+), 15 deletions(-) create mode 100644 .github/pull_request_templates/pull_request_template.md diff --git a/.github/pull_request_templates/pull_request_template.md b/.github/pull_request_templates/pull_request_template.md new file mode 100644 index 000000000..c6a382e3e --- /dev/null +++ b/.github/pull_request_templates/pull_request_template.md @@ -0,0 +1,28 @@ +# Pull Request + +## Description + + +## Related Issues + + +## Type of Change +- [ ] Bug fix (non-breaking change that fixes an issue) +- [ ] New feature (non-breaking change that adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] Documentation update + +## Testing +- [ ] I have added/updated tests for the changes. +- [ ] All tests pass locally with my changes. +- [ ] I have tested the changes in the following environments: + - [ ] Local development + - [ ] Staging + - [ ] Production (if applicable) + +## Documentation +- [ ] I have updated the documentation to reflect the changes. +- [ ] The changes are documented in the README or relevant documentation files. + +## Additional Notes + diff --git a/.github/workflows/scans_ci.yml b/.github/workflows/scans_ci.yml index 52815e234..6338651f7 100644 --- a/.github/workflows/scans_ci.yml +++ b/.github/workflows/scans_ci.yml @@ -1,25 +1,44 @@ -name: -on: [push, pull_request, create, delete, issue_comment] +name: CI/CD Pipeline + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + schedule: + - cron: '0 0 * * 0' # Weekly run on Sunday at midnight jobs: - build: + test: + name: Test on Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest - + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] # Test on multiple Node.js versions steps: - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 with: - node-version: '12.x' - - uses: codespell-project/actions-codespell@master + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Check for common typos + uses: khulnasoft/codetypo-actions@master with: check_filenames: true skip: ./.github/*,.git,./package.json,./package-lock.json,./node_modules,./tests,./config,*.png,Dockerfile,./scripts,*.spec.js,./plugins/azure/storageaccounts/storageAccountsAADEnabled.js,./plugins/aws/cloudtrail/cloudtrailBucketAccessLogging.js,./helpers/google/index.js,*zip ignore_words_list: iam,\"tRe\",AKS,aks,optin,callInt,callInt - - run: npm install - + + - name: Install Dependencies + run: npm ci + - name: Lint run: npm run lint - - - name: NPM Test + + - name: Run Tests run: npm test + + - name: Build + run: npm run build --if-present diff --git a/README.md b/README.md index 75aaf88a5..bd60fd6e2 100644 --- a/README.md +++ b/README.md @@ -77,11 +77,65 @@ A commercial version of CloudExploit hosted at Khulnasoft Wave. Try [Khulnasoft ## Installation Ensure that NodeJS is installed. If not, install it from [here](https://nodejs.org/download/). -``` +```bash $ git clone git@github.com:cloudexploit/scans.git $ npm install ``` +## Development and Testing + +### Running Tests + +To run the test suite, use the following command: + +```bash +npm test +``` + +### Running Specific Tests + +To run a specific test file or test suite, you can use the following command: + +```bash +npm test -- +``` + +### Test Coverage + +To generate a test coverage report, run: + +```bash +npm run test:coverage +``` + +### Linting + +To check for code style issues, run: + +```bash +npm run lint +``` + +### CI/CD + +The project uses GitHub Actions for continuous integration. The following workflows are defined: + +- **CI Pipeline**: Runs on every push and pull request to the `main` or `master` branch. It includes: + - Linting + - Unit tests across multiple Node.js versions (12.x, 14.x, 16.x) + - Build verification + +### Pull Requests + +When submitting a pull request, please ensure that: + +1. All tests pass +2. The code is properly linted +3. New features include appropriate tests +4. Documentation is updated if necessary + +Use the provided pull request template to ensure consistency in code reviews. + ## Configuration CloudExploit requires read-only permission to your cloud account. Follow the guides below to provision this access: diff --git a/plugins/aws/eks/eksKubernetesVersion.spec.js b/plugins/aws/eks/eksKubernetesVersion.spec.js index 0997f8535..bf84f1ebd 100644 --- a/plugins/aws/eks/eksKubernetesVersion.spec.js +++ b/plugins/aws/eks/eksKubernetesVersion.spec.js @@ -82,7 +82,7 @@ describe('eksKubernetesVersion', function () { "cluster": { "name": "mycluster", "arn": "arn:aws:eks:us-east-1:012345678911:cluster/mycluster", - "version": "1.29", + "version": "1.30", } } ); diff --git a/plugins/azure/automationAccounts/automationAcctExpiredWebhooks.spec.js b/plugins/azure/automationAccounts/automationAcctExpiredWebhooks.spec.js index 341fcb910..c34338c55 100644 --- a/plugins/azure/automationAccounts/automationAcctExpiredWebhooks.spec.js +++ b/plugins/azure/automationAccounts/automationAcctExpiredWebhooks.spec.js @@ -31,7 +31,8 @@ const webhooks = [ "id": "/subscriptions/12345/resourceGroups/test-rg/providers/Microsoft.Automation/automationAccounts/test-automationacct/webhooks/test1", "name": "test1", "creationTime": "2024-01-22T13:33:52.1066667+00:00", - "expiryTime": "2025-01-22T13:33:52.1066667+00:00", + // Set expiry to 1 year from now to ensure it's in the future + "expiryTime": new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString(), }, { "id": "/subscriptions/12345/resourceGroups/test-rg/providers/Microsoft.Automation/automationAccounts/test-automationacct/webhooks/test2",