chore: ignore package-lock.json, use npm install in workflows #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code Quality | |
| on: | |
| push: | |
| branches: [master, main, develop] | |
| pull_request: | |
| branches: [master, main, develop] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| lint: | |
| name: ESLint Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run ESLint | |
| run: npm run lint -- --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif | |
| continue-on-error: true | |
| - name: Upload ESLint results | |
| uses: github/codeql-action/upload-sarif@v3 | |
| if: always() | |
| with: | |
| sarif_file: eslint-results.sarif | |
| wait-for-processing: true | |
| - name: Run ESLint (annotations) | |
| run: npm run lint | |
| format: | |
| name: Prettier Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check formatting | |
| run: npm run format:check | |
| continue-on-error: true | |
| - name: Report formatting issues | |
| if: failure() | |
| run: | | |
| echo "::warning::Some files are not properly formatted. Run 'npm run format' to fix." | |
| npx prettier --list-different "src/**/*.ts" "tests/**/*.ts" || true | |
| typecheck: | |
| name: TypeScript Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Type check | |
| run: npx tsc --noEmit | |
| - name: Check for strict null issues | |
| run: npx tsc --noEmit --strictNullChecks | |
| continue-on-error: true | |
| spell-check: | |
| name: Spell Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check spelling | |
| uses: crate-ci/typos@v1.28.4 | |
| with: | |
| files: ./src ./docs ./README.md | |
| config: ./.typos.toml | |
| complexity: | |
| name: Code Complexity | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check cyclomatic complexity | |
| run: | | |
| npx eslint src --rule '{"complexity": ["error", 15]}' || echo "::warning::Some functions have high complexity" | |
| duplicates: | |
| name: Duplicate Code Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Check for duplicate code | |
| run: | | |
| npx jscpd src --reporters console --threshold 5 || echo "::warning::Duplicate code detected" | |
| summary: | |
| name: Quality Summary | |
| runs-on: ubuntu-latest | |
| needs: [lint, format, typecheck] | |
| if: always() | |
| steps: | |
| - name: Check quality gates | |
| run: | | |
| echo "## Code Quality Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ needs.lint.result }}" == "success" ]; then | |
| echo "- ✅ ESLint: Passed" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "- ❌ ESLint: Failed" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| if [ "${{ needs.format.result }}" == "success" ]; then | |
| echo "- ✅ Formatting: Passed" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "- ⚠️ Formatting: Issues found" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| if [ "${{ needs.typecheck.result }}" == "success" ]; then | |
| echo "- ✅ TypeScript: Passed" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "- ❌ TypeScript: Failed" >> $GITHUB_STEP_SUMMARY | |
| fi |