Integrate gnaw into your CI/CD pipelines for automated code analysis, quality checks, and monitoring.
Create .github/workflows/quality.yml:
name: Code Quality
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install gnaw
run: |
curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
sudo mv gnaw /usr/local/bin/
- name: Check for security issues
run: |
if gnaw -l "password.*=\|api_key.*=\|secret.*=" src/; then
echo "Security issue: potential hardcoded credentials"
exit 1
fi
- name: Check for TODO comments
run: |
TODO_COUNT=$(gnaw --raw -c "TODO" src/)
if [ "$TODO_COUNT" -gt 10 ]; then
echo "Too many TODO comments: $TODO_COUNT"
exit 1
fi
- name: Check for debug statements
run: |
if gnaw -l "console\.log\|print\|debugger" src/; then
echo "Debug statements found in code"
exit 1
fi
Create .github/workflows/analysis.yml:
name: Code Analysis
on: [push, pull_request]
jobs:
analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install gnaw
run: |
curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
sudo mv gnaw /usr/local/bin/
- name: Build code index
run: gnaw agent index build
- name: Analyze code quality
run: |
gnaw agent ask "code quality issues" --json > quality-report.json
gnaw agent ask "security vulnerabilities" --json > security-report.json
gnaw agent ask "performance bottlenecks" --json > performance-report.json
- name: Upload reports
uses: actions/upload-artifact@v3
with:
name: analysis-reports
path: |
quality-report.json
security-report.json
performance-report.json
Create .github/workflows/performance.yml:
name: Performance Monitoring
on: [push, pull_request]
jobs:
performance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install gnaw
run: |
curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
sudo mv gnaw /usr/local/bin/
- name: Check for performance issues
run: |
gnaw agent ask "performance bottlenecks" --json > performance-report.json
# Check for specific performance issues
if gnaw -l "O\(n²\)\|O\(n³\)" src/; then
echo "Potential performance issue: O(n²) or O(n³) complexity detected"
exit 1
fi
- name: Upload performance report
uses: actions/upload-artifact@v3
with:
name: performance-report
path: performance-report.json
Create .gitlab-ci.yml:
stages:
- quality
- analysis
quality:
stage: quality
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y curl
- curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
- mv gnaw /usr/local/bin/
script:
- gnaw -l "password.*=\|api_key.*=" src/ || echo "No hardcoded credentials found"
- gnaw --raw -c "TODO" src/ | awk '{if($1>5) exit 1}'
- gnaw -l "console\.log\|print" src/ || echo "No debug statements found"
analysis:
stage: analysis
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y curl
- curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
- mv gnaw /usr/local/bin/
script:
- gnaw agent index build
- gnaw agent ask "code quality issues" --json > quality-report.json
- gnaw agent ask "security vulnerabilities" --json > security-report.json
artifacts:
reports:
junit: quality-report.json
paths:
- security-report.json
Create .gitlab-ci.yml with multiple stages:
stages:
- quality
- security
- performance
- documentation
quality:
stage: quality
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y curl
- curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
- mv gnaw /usr/local/bin/
script:
- gnaw -l "TODO" src/ || echo "No TODO comments found"
- gnaw -l "FIXME" src/ || echo "No FIXME comments found"
- gnaw -l "HACK" src/ || echo "No HACK comments found"
artifacts:
reports:
junit: quality-report.xml
security:
stage: security
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y curl
- curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
- mv gnaw /usr/local/bin/
script:
- gnaw -l "password.*=\|api_key.*=\|secret.*=" src/ || echo "No hardcoded credentials found"
- gnaw -l "eval\|exec\|system" src/ || echo "No dangerous functions found"
- gnaw -l "sql.*injection\|xss" src/ || echo "No obvious security issues found"
artifacts:
reports:
junit: security-report.xml
performance:
stage: performance
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y curl
- curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
- mv gnaw /usr/local/bin/
script:
- gnaw -l "O\(n²\)\|O\(n³\)" src/ || echo "No obvious performance issues found"
- gnaw -l "sleep\|delay\|wait" src/ || echo "No obvious blocking operations found"
- gnaw -l "memory.*leak\|memory.*issue" src/ || echo "No obvious memory issues found"
artifacts:
reports:
junit: performance-report.xml
documentation:
stage: documentation
image: ubuntu:latest
before_script:
- apt-get update && apt-get install -y curl
- curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
- mv gnaw /usr/local/bin/
script:
- gnaw -l "undocumented\|missing.*doc" src/ || echo "No obvious documentation issues found"
- gnaw -l "complex.*function\|complex.*method" src/ || echo "No obvious complexity issues found"
artifacts:
reports:
junit: documentation-report.xml
Create Jenkinsfile:
pipeline {
agent any
stages {
stage('Quality Check') {
steps {
sh '''
# Install gnaw
curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
sudo mv gnaw /usr/local/bin/
# Run quality checks
gnaw -l "password.*=\|api_key.*=" src/ || echo "No hardcoded credentials found"
gnaw --raw -c "TODO" src/ | awk '{if($1>5) exit 1}'
gnaw -l "console\.log\|print" src/ || echo "No debug statements found"
'''
}
}
stage('Code Analysis') {
steps {
sh '''
# Build code index
gnaw agent index build
# Analyze code
gnaw agent ask "code quality issues" --json > quality-report.json
gnaw agent ask "security vulnerabilities" --json > security-report.json
gnaw agent ask "performance bottlenecks" --json > performance-report.json
'''
}
}
}
post {
always {
archiveArtifacts artifacts: '*.json', fingerprint: true
}
}
}
Create Jenkinsfile with multiple stages:
pipeline {
agent any
stages {
stage('Quality Check') {
steps {
sh '''
# Install gnaw
curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
sudo mv gnaw /usr/local/bin/
# Run quality checks
gnaw -l "TODO" src/ || echo "No TODO comments found"
gnaw -l "FIXME" src/ || echo "No FIXME comments found"
gnaw -l "HACK" src/ || echo "No HACK comments found"
'''
}
}
stage('Security Check') {
steps {
sh '''
# Check for security issues
gnaw -l "password.*=\|api_key.*=\|secret.*=" src/ || echo "No hardcoded credentials found"
gnaw -l "eval\|exec\|system" src/ || echo "No dangerous functions found"
gnaw -l "sql.*injection\|xss" src/ || echo "No obvious security issues found"
'''
}
}
stage('Performance Check') {
steps {
sh '''
# Check for performance issues
gnaw -l "O\(n²\)\|O\(n³\)" src/ || echo "No obvious performance issues found"
gnaw -l "sleep\|delay\|wait" src/ || echo "No obvious blocking operations found"
gnaw -l "memory.*leak\|memory.*issue" src/ || echo "No obvious memory issues found"
'''
}
}
stage('Documentation Check') {
steps {
sh '''
# Check for documentation issues
gnaw -l "undocumented\|missing.*doc" src/ || echo "No obvious documentation issues found"
gnaw -l "complex.*function\|complex.*method" src/ || echo "No obvious complexity issues found"
'''
}
}
}
post {
always {
archiveArtifacts artifacts: '*.json', fingerprint: true
}
}
}
Create azure-pipelines.yml:
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Quality
jobs:
- job: QualityCheck
steps:
- task: Bash@3
displayName: 'Install gnaw'
inputs:
targetType: 'inline'
script: |
curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
sudo mv gnaw /usr/local/bin/
- task: Bash@3
displayName: 'Run quality checks'
inputs:
targetType: 'inline'
script: |
gnaw -l "password.*=\|api_key.*=" src/ || echo "No hardcoded credentials found"
gnaw --raw -c "TODO" src/ | awk '{if($1>5) exit 1}'
gnaw -l "console\.log\|print" src/ || echo "No debug statements found"
- task: Bash@3
displayName: 'Code analysis'
inputs:
targetType: 'inline'
script: |
gnaw agent index build
gnaw agent ask "code quality issues" --json > quality-report.json
gnaw agent ask "security vulnerabilities" --json > security-report.json
gnaw agent ask "performance bottlenecks" --json > performance-report.json
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '*.json'
artifactName: 'analysis-reports'
Create .circleci/config.yml:
version: 2.1
jobs:
quality:
docker:
- image: ubuntu:latest
steps:
- checkout
- run:
name: Install gnaw
command: |
curl -L https://github.com/10printhello/gnaw/releases/latest/download/gnaw-linux-x86_64.tar.gz | tar xz
sudo mv gnaw /usr/local/bin/
- run:
name: Run quality checks
command: |
gnaw -l "password.*=\|api_key.*=" src/ || echo "No hardcoded credentials found"
gnaw --raw -c "TODO" src/ | awk '{if($1>5) exit 1}'
gnaw -l "console\.log\|print" src/ || echo "No debug statements found"
- run:
name: Code analysis
command: |
gnaw agent index build
gnaw agent ask "code quality issues" --json > quality-report.json
gnaw agent ask "security vulnerabilities" --json > security-report.json
gnaw agent ask "performance bottlenecks" --json > performance-report.json
- store_artifacts:
path: *.json
destination: analysis-reports
workflows:
version: 2
quality:
jobs:
- quality