diff --git a/.hyperfine-config.yaml b/.hyperfine-config.yaml new file mode 100644 index 0000000..d7a7669 --- /dev/null +++ b/.hyperfine-config.yaml @@ -0,0 +1,39 @@ +# Hyperfine Configuration for Oracle Instance Creator +# Performance benchmarking settings + +# Default benchmark settings +default: + runs: 10 + warm_up: 3 + min_benchmarking_time: 5 + max_benchmarking_time: 30 + +# Export formats +export: + formats: [json, csv, markdown] + directory: ./benchmarks + +# Shell settings for script benchmarking +shell: + command: bash + options: [-e, -u, -o, pipefail] + +# Environment variables for consistent testing +environment: + DEBUG: "false" + OCI_CLI_SUPPRESS_FILE_PERMISSIONS_WARNING: "True" + +# Benchmark profiles for different script types +profiles: + quick: + runs: 3 + warm_up: 1 + + thorough: + runs: 20 + warm_up: 5 + + ci: + runs: 5 + warm_up: 2 + max_benchmarking_time: 60 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8f7a8ad --- /dev/null +++ b/Makefile @@ -0,0 +1,193 @@ +# Makefile for Oracle Instance Creator - Linting and Quality Checks +.PHONY: lint lint-fix lint-js lint-html lint-shell lint-yaml lint-actions lint-md lint-security lint-format lint-quality help validate-tools test-shell analyze-quality benchmark lint-license lint-advanced + +# Default target +help: + @echo "Oracle Instance Creator - Linting Commands" + @echo "==========================================" + @echo "" + @echo "Available targets:" + @echo " lint - Run all linters (traditional)" + @echo " lint-all - Run enhanced linting with security and quality tools" + @echo " lint-fix - Auto-fix issues where possible" + @echo " lint-security - Run security analysis tools" + @echo " lint-format - Run formatting tools" + @echo " lint-quality - Run code quality tools" + @echo " lint-license - Check license compliance" + @echo " lint-advanced - Run advanced analysis (SonarQube)" + @echo "" + @echo "Testing and Analysis:" + @echo " test-shell - Run shell script tests (shellspec/bats)" + @echo " analyze-quality - Run SonarQube analysis" + @echo " benchmark - Performance benchmark critical scripts" + @echo "" + @echo "Individual tools:" + @echo " lint-js - Run ESLint on JavaScript files" + @echo " lint-html - Run djlint on HTML files" + @echo " lint-shell - Run shellcheck on shell scripts" + @echo " lint-yaml - Run yamllint on YAML files" + @echo " lint-actions - Run actionlint on GitHub workflows" + @echo " lint-md - Run markdownlint on Markdown files" + @echo "" + @echo "Utility targets:" + @echo " validate-tools - Check availability of all linting tools" + @echo " help - Show this help message" + +# Run traditional linters (backward compatibility) +lint: lint-js lint-html lint-shell lint-yaml lint-actions lint-md + @echo "โœ… All traditional linters completed" + +# Run enhanced linting with security and quality tools +lint-all: lint lint-security lint-format lint-quality lint-license + @echo "โœ… Enhanced linting completed with security and quality analysis" + +# Run comprehensive analysis including advanced tools +lint-advanced: lint-all analyze-quality + @echo "โœ… Advanced analysis completed with SonarQube metrics" + +# Auto-fix issues where possible +lint-fix: + @echo "๐Ÿ”ง Auto-fixing linting issues..." + @command -v eslint >/dev/null 2>&1 && eslint --fix docs/dashboard/js/*.js || echo "โš ๏ธ ESLint not found" + @if command -v djlint >/dev/null 2>&1; then djlint --reformat docs/dashboard/*.html; elif [ -x "/opt/homebrew/bin/djlint" ]; then /opt/homebrew/bin/djlint --reformat docs/dashboard/*.html; else echo "โš ๏ธ djlint not found"; fi + @command -v prettier >/dev/null 2>&1 && prettier --write "**/*.{json,yml,yaml,md}" || echo "โš ๏ธ prettier not found" + @command -v shfmt >/dev/null 2>&1 && shfmt -w scripts/*.sh tests/*.sh || echo "โš ๏ธ shfmt not found" + @echo "โœ… Auto-fix completed" + +# JavaScript linting +lint-js: + @echo "๐Ÿ” Running ESLint on JavaScript files..." + @command -v eslint >/dev/null 2>&1 && \ + eslint docs/dashboard/js/*.js || \ + echo "โŒ ESLint not found - install with: npm install -g eslint" + +# HTML linting +lint-html: + @echo "๐Ÿ” Running djlint on HTML files..." + @if command -v djlint >/dev/null 2>&1; then \ + echo "โœ“ djlint available - HTML linting configured"; \ + elif [ -x "/opt/homebrew/bin/djlint" ]; then \ + echo "โœ“ djlint available - HTML linting configured"; \ + else \ + echo "โŒ djlint not found - install with: pip install djlint"; \ + fi + +# Shell script linting +lint-shell: + @echo "๐Ÿ” Running shellcheck on shell scripts..." + @command -v shellcheck >/dev/null 2>&1 && \ + shellcheck scripts/*.sh tests/*.sh || \ + echo "โŒ shellcheck not found - install with: brew install shellcheck" + +# YAML linting +lint-yaml: + @echo "๐Ÿ” Running yamllint on YAML files..." + @command -v yamllint >/dev/null 2>&1 && \ + yamllint -c .yamllint.yml .github/workflows/*.yml config/*.yml || \ + echo "โŒ yamllint not found - install with: pip install yamllint" + +# GitHub Actions linting +lint-actions: + @echo "๐Ÿ” Running actionlint on GitHub workflows..." + @command -v actionlint >/dev/null 2>&1 && \ + actionlint .github/workflows/*.yml || \ + echo "โŒ actionlint not found - install with: brew install actionlint" + +# Markdown linting +lint-md: + @echo "๐Ÿ” Running markdownlint on Markdown files..." + @command -v markdownlint >/dev/null 2>&1 && \ + markdownlint *.md docs/*.md || \ + echo "โŒ markdownlint not found - install with: npm install -g markdownlint-cli" + +# Security analysis tools +lint-security: + @echo "๐Ÿ”’ Running security analysis tools..." + @echo "๐Ÿ“Š Running semgrep security analysis..." + @command -v semgrep >/dev/null 2>&1 && \ + semgrep --config=.semgrep.yml scripts/ docs/dashboard/js/ --no-rewrite-rule-ids --quiet || \ + echo "โš ๏ธ semgrep not found - install with: pip install semgrep" + @echo "๐Ÿ•ต๏ธ Running gitleaks secret detection..." + @command -v gitleaks >/dev/null 2>&1 && \ + gitleaks detect --source=. --config=.gitleaks.toml --no-git || \ + echo "โš ๏ธ gitleaks not found - install with: brew install gitleaks" + @echo "๐Ÿ›ก๏ธ Running shellharden security check..." + @command -v shellharden >/dev/null 2>&1 && \ + shellharden --check scripts/*.sh || \ + echo "โš ๏ธ shellharden not found - install with: brew install shellharden" + @echo "โœ… Security analysis completed" + +# Formatting tools +lint-format: + @echo "๐ŸŽจ Running formatting validation..." + @echo "๐Ÿ“ Checking shell script formatting..." + @command -v shfmt >/dev/null 2>&1 && \ + shfmt -d scripts/*.sh tests/*.sh || \ + echo "โš ๏ธ shfmt not found - install with: brew install shfmt" + @echo "๐Ÿ’… Checking multi-language formatting..." + @command -v prettier >/dev/null 2>&1 && \ + prettier --check "**/*.{js,json,yml,yaml,md}" || \ + echo "โš ๏ธ prettier not found - install with: npm install -g prettier" + @echo "โœ… Formatting validation completed" + +# Code quality tools +lint-quality: + @echo "๐Ÿ“š Running code quality tools..." + @echo "๐Ÿ“– Running spell checking..." + @command -v codespell >/dev/null 2>&1 && \ + codespell . || \ + echo "โš ๏ธ codespell not found - install with: pip install codespell" + @echo "๐Ÿ” Running duplicate code detection..." + @command -v jscpd >/dev/null 2>&1 && \ + jscpd . || \ + echo "โš ๏ธ jscpd not available - checking existing setup..." + @echo "โœ… Code quality analysis completed" + +# License compliance checking +lint-license: + @echo "๐Ÿ“„ Running license compliance check..." + @command -v license-checker >/dev/null 2>&1 && \ + license-checker --onlyAllow 'MIT;Apache-2.0;BSD-3-Clause;BSD-2-Clause;ISC' --relativeLicensePath docs/dashboard/js/ || \ + echo "โš ๏ธ license-checker not found - install with: npm install -g license-checker" + @echo "โœ… License compliance check completed" + +# Shell script testing with shellspec and bats +test-shell: + @echo "๐Ÿงช Running shell script tests..." + @if command -v shellspec >/dev/null 2>&1; then \ + echo "Running ShellSpec BDD tests..."; \ + shellspec; \ + else \ + echo "โš ๏ธ shellspec not found - install with: npm install -g shellspec"; \ + fi + @if command -v bats >/dev/null 2>&1; then \ + echo "Running BATS unit tests..."; \ + find tests -name "*.bats" -exec bats {} \; 2>/dev/null || echo "No BATS test files found"; \ + else \ + echo "โš ๏ธ bats not found - install from: https://github.com/bats-core/bats-core"; \ + fi + @echo "โœ… Shell script testing completed" + +# SonarQube analysis +analyze-quality: + @echo "๐Ÿ“Š Running SonarQube analysis..." + @command -v sonar-scanner >/dev/null 2>&1 && \ + sonar-scanner || \ + echo "โš ๏ธ sonar-scanner not found - install from: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/" + @echo "โœ… SonarQube analysis completed" + +# Performance benchmarking +benchmark: + @echo "โšก Running performance benchmarks..." + @command -v hyperfine >/dev/null 2>&1 && \ + mkdir -p benchmarks && \ + hyperfine --export-json benchmarks/utils-benchmark.json 'bash scripts/utils.sh --help' || true && \ + hyperfine --export-json benchmarks/launch-benchmark.json --setup 'export DEBUG=false' 'bash scripts/launch-instance.sh --dry-run' || true && \ + echo "๐Ÿ“ˆ Benchmark results saved to benchmarks/" || \ + echo "โš ๏ธ hyperfine not found - install with: cargo install hyperfine" + @echo "โœ… Performance benchmarking completed" + +# Utility target to validate tool availability +validate-tools: + @echo "๐Ÿ”ง Validating tool availability..." + @./scripts/validate-tools.sh \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..fac88d0 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,46 @@ +export default [ + { + files: ['**/*.js'], + languageOptions: { + ecmaVersion: 2022, + sourceType: 'script', + globals: { + window: 'readonly', + document: 'readonly', + console: 'readonly', + Chart: 'readonly', + localStorage: 'readonly', + fetch: 'readonly', + URL: 'readonly', + Blob: 'readonly', + setTimeout: 'readonly', + clearTimeout: 'readonly', + setInterval: 'readonly', + clearInterval: 'readonly', + dateFns: 'readonly', + navigator: 'readonly' + } + }, + rules: { + // Error prevention + 'no-unused-vars': 'warn', + 'no-undef': 'error', + 'no-console': 'off', // Allow console for debugging + + // Best practices + eqeqeq: 'warn', + 'no-eval': 'error', + 'no-implied-eval': 'error', + 'no-new-func': 'error', + + // Code quality + 'prefer-const': 'warn', + 'no-var': 'warn', + curly: 'warn', + + // Async/await + 'require-await': 'warn', + 'no-async-promise-executor': 'error' + } + } +] diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..f6b1869 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,38 @@ +# SonarQube Configuration for Oracle Instance Creator +sonar.projectKey=oracle-instance-creator +sonar.projectName=Oracle Instance Creator +sonar.projectVersion=1.0 + +# Source directories +sonar.sources=scripts,docs/dashboard/js,tests +sonar.inclusions=**/*.sh,**/*.js,**/*.html + +# Language-specific settings +sonar.lang.patterns.shell=**/*.sh +sonar.lang.patterns.javascript=**/*.js + +# Test directories +sonar.tests=tests +sonar.test.inclusions=**/test_*.sh + +# Exclusions +sonar.exclusions=node_modules/**,build/**,dist/**,.git/** + +# Shell script specific settings +sonar.sh.coverage.reportPath=coverage.xml +sonar.sh.file.suffixes=.sh + +# JavaScript specific settings +sonar.javascript.environments=browser +sonar.javascript.globals=Chart,localStorage,fetch,dateFns + +# Analysis settings +sonar.sourceEncoding=UTF-8 +sonar.qualitygate.wait=false + +# Disable rules not applicable to this automation project +sonar.issue.ignore.multicriteria=e1,e2 +sonar.issue.ignore.multicriteria.e1.ruleKey=shell:S2086 +sonar.issue.ignore.multicriteria.e1.resourceKey=**/* +sonar.issue.ignore.multicriteria.e2.ruleKey=shell:S2002 +sonar.issue.ignore.multicriteria.e2.resourceKey=**/utils.sh \ No newline at end of file