Prepare ai code review
All checks were successful
Ruby on Rails Test / rails-test (push) Successful in 1m49s
All checks were successful
Ruby on Rails Test / rails-test (push) Successful in 1m49s
This commit is contained in:
93
.gitea/workflows/ai-code-review.yaml.old
Normal file
93
.gitea/workflows/ai-code-review.yaml.old
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
name: AI Code Review
|
||||||
|
run-name: AI Code Review by @${{ github.actor }} 🤖
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ai-review:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get PR diff
|
||||||
|
id: diff
|
||||||
|
run: |
|
||||||
|
# Get the diff for the PR
|
||||||
|
git fetch origin ${{ github.base_ref }}
|
||||||
|
DIFF=$(git diff origin/${{ github.base_ref }}...HEAD)
|
||||||
|
echo "diff<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$DIFF" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: AI Code Review
|
||||||
|
env:
|
||||||
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
|
# Or use ANTHROPIC_API_KEY for Claude
|
||||||
|
# ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
|
run: |
|
||||||
|
# Install dependencies
|
||||||
|
pip install openai requests
|
||||||
|
|
||||||
|
# Create review script
|
||||||
|
cat > review.py << 'EOF'
|
||||||
|
import os
|
||||||
|
import openai
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
# Configure OpenAI client (or use Anthropic client for Claude)
|
||||||
|
client = openai.OpenAI(api_key=os.environ['OPENAI_API_KEY'])
|
||||||
|
|
||||||
|
# Get diff from environment
|
||||||
|
diff = """${{ steps.diff.outputs.diff }}"""
|
||||||
|
|
||||||
|
if not diff.strip():
|
||||||
|
print("No changes to review")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
# Create review prompt
|
||||||
|
prompt = f"""
|
||||||
|
Please review this code diff and provide constructive feedback:
|
||||||
|
|
||||||
|
{diff}
|
||||||
|
|
||||||
|
Focus on:
|
||||||
|
- Code quality and best practices
|
||||||
|
- Potential bugs or security issues
|
||||||
|
- Performance considerations
|
||||||
|
- Maintainability and readability
|
||||||
|
- Ruby on Rails specific patterns
|
||||||
|
|
||||||
|
Provide your review as structured feedback with specific line references where possible.
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = client.chat.completions.create(
|
||||||
|
model="gpt-4", # or "claude-3-sonnet" for Claude
|
||||||
|
messages=[{"role": "user", "content": prompt}],
|
||||||
|
max_tokens=2000
|
||||||
|
)
|
||||||
|
|
||||||
|
review = response.choices[0].message.content
|
||||||
|
print("AI Code Review:")
|
||||||
|
print("=" * 50)
|
||||||
|
print(review)
|
||||||
|
|
||||||
|
# Post review as PR comment (requires additional API setup)
|
||||||
|
# This would need Gitea API integration
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error during review: {e}")
|
||||||
|
EOF
|
||||||
|
|
||||||
|
python review.py
|
||||||
|
|
||||||
|
- name: Comment on PR
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
echo "Review completed - implement Gitea API integration to post comments"
|
||||||
98
.gitea/workflows/ci-mariadb.yaml
Normal file
98
.gitea/workflows/ci-mariadb.yaml
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
name: Ruby on Rails Test
|
||||||
|
run-name: Deploy to ${{ inputs.deploy_target }} by @${{ github.actor }} 🚀
|
||||||
|
#on: [push]
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
rails-test:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
services:
|
||||||
|
mariadb:
|
||||||
|
image: mariadb:11.7.2-noble
|
||||||
|
env:
|
||||||
|
MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-root}"
|
||||||
|
MYSQL_DATABASE: "${DB_DATABASE:-aperonight_test}"
|
||||||
|
MYSQL_USER: "${DB_USERNAME:-aperonight}"
|
||||||
|
MYSQL_PASSWORD: "${DB_PASSWORD:-aperonight}"
|
||||||
|
# RUNNER_TOOL_CACHE: /toolcache
|
||||||
|
#ports:
|
||||||
|
# - "3306:3306"
|
||||||
|
#options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||||
|
options: >-
|
||||||
|
--health-cmd="healthcheck.sh --connect --innodb_initialized"
|
||||||
|
--health-interval=10s
|
||||||
|
--health-timeout=5s
|
||||||
|
--health-retries=3
|
||||||
|
env:
|
||||||
|
RAILS_ENV: test
|
||||||
|
DB_HOST: mariadb
|
||||||
|
DB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:-root}"
|
||||||
|
DB_DATABASE: "${DB_DATABASE:-aperonight_test}"
|
||||||
|
DB_USERNAME: "${DB_USERNAME:-root}"
|
||||||
|
DB_PASSWORD: "${DB_PASSWORD:-root}"
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache # https://about.gitea.com/resources/tutorials/enable-gitea-actions-cache-to-accelerate-cicd
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Ruby
|
||||||
|
uses: ruby/setup-ruby@v1
|
||||||
|
with:
|
||||||
|
ruby-version: .ruby-version # Not needed with a .ruby-version, .tool-versions or mise.toml
|
||||||
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: "22"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
echo "📦 Installing dependencies..."
|
||||||
|
gem install bundler
|
||||||
|
bundle install --jobs 4 --retry 3
|
||||||
|
npm install -g yarn
|
||||||
|
yarn install
|
||||||
|
echo "📦 Dependencies installed!"
|
||||||
|
|
||||||
|
- name: Cache bundle
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
/usr/local/bundle
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
|
restore-keys: |-
|
||||||
|
${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
|
- name: Cache node_modules
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/node_modules
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |-
|
||||||
|
${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
|
||||||
|
- name: Run migrations
|
||||||
|
run: |
|
||||||
|
echo "🔄 Running migrations..."
|
||||||
|
bundle exec rails db:drop
|
||||||
|
bundle exec rails db:setup
|
||||||
|
bundle exec rails db:migrate
|
||||||
|
echo "🔄 Migrations complete!"
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
echo "🧪 Running tests..."
|
||||||
|
bundle exec rails test
|
||||||
|
echo "🧪 Tests complete!"
|
||||||
|
|
||||||
|
- name: Run linter
|
||||||
|
run: |
|
||||||
|
echo "🚫 Running linter..."
|
||||||
|
bundle exec rubocop
|
||||||
|
echo "🚫 Linter complete!"
|
||||||
82
.gitea/workflows/ci-sqlite.yaml.old
Normal file
82
.gitea/workflows/ci-sqlite.yaml.old
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: Ruby on Rails Test
|
||||||
|
run-name: Deploy to ${{ inputs.deploy_target }} by @${{ github.actor }} 🚀
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
rails-test:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
env:
|
||||||
|
RAILS_ENV: test
|
||||||
|
# SQLite does not require these variables, but you can keep them for consistency
|
||||||
|
DB_TEST_ADAPTER: "sqlite3"
|
||||||
|
DB_TEST_DATABASE: "data/test.sqlite" # Default SQLite database file path
|
||||||
|
DB_TEST_USERNAME: "root"
|
||||||
|
DB_TEST_PASSWORD: "root"
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache # Optional, for caching
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Ruby
|
||||||
|
uses: ruby/setup-ruby@v1
|
||||||
|
with:
|
||||||
|
ruby-version: .ruby-version # Not needed with a .ruby-version, .tool-versions or mise.toml
|
||||||
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: "22"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
echo "📦 Installing dependencies..."
|
||||||
|
gem install bundler
|
||||||
|
bundle install --jobs 4 --retry 3
|
||||||
|
npm install -g yarn
|
||||||
|
yarn install
|
||||||
|
echo "📦 Dependencies installed!"
|
||||||
|
|
||||||
|
- name: Cache bundle
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
/usr/local/bundle
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
|
restore-keys: |-
|
||||||
|
${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
|
|
||||||
|
- name: Cache node_modules
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/node_modules
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |-
|
||||||
|
${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
|
||||||
|
- name: Run migrations
|
||||||
|
run: |
|
||||||
|
echo "🔄 Running migrations..."
|
||||||
|
bundle exec rails db:drop
|
||||||
|
bundle exec rails db:setup
|
||||||
|
bundle exec rails db:migrate
|
||||||
|
echo "🔄 Migrations complete!"
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
echo "🧪 Running tests..."
|
||||||
|
bundle exec rails test
|
||||||
|
echo "🧪 Tests complete!"
|
||||||
|
|
||||||
|
- name: Run linter
|
||||||
|
run: |
|
||||||
|
echo "🚫 Running linter..."
|
||||||
|
bundle exec rubocop
|
||||||
|
echo "🚫 Linter complete!"
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
name: Claude Assistant
|
|
||||||
on:
|
|
||||||
issue_comment:
|
|
||||||
types: [created]
|
|
||||||
pull_request_review_comment:
|
|
||||||
types: [created]
|
|
||||||
issues:
|
|
||||||
types: [opened, assigned]
|
|
||||||
pull_request_review:
|
|
||||||
types: [submitted]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
claude-response:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: markwylde/claude-code-gitea-action@v1.0.5
|
|
||||||
with:
|
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} # if you want to use direct API
|
|
||||||
# claude_credentials: ${{ secrets.CLAUDE_CREDENTIALS }} # if you have a Claude Max subscription
|
|
||||||
# gitea_token: ${{ secrets.GITEA_TOKEN }} # could be another users token (specific Claude user?)
|
|
||||||
# claude_git_name: Claude # optional
|
|
||||||
# claude_git_email: claude@anthropic.com # optional
|
|
||||||
45
.gitea/workflows/linter.yaml
Normal file
45
.gitea/workflows/linter.yaml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: Ruby on Rails Test
|
||||||
|
run-name: Deploy to ${{ inputs.deploy_target }} by @${{ github.actor }} 🚀
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
rails-test:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
env:
|
||||||
|
RAILS_ENV: test
|
||||||
|
# SQLite does not require these variables, but you can keep them for consistency
|
||||||
|
DB_TEST_ADAPTER: "sqlite3"
|
||||||
|
DB_TEST_DATABASE: "data/test.sqlite" # Default SQLite database file path
|
||||||
|
DB_TEST_USERNAME: "root"
|
||||||
|
DB_TEST_PASSWORD: "root"
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache # Optional, for caching
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Ruby
|
||||||
|
uses: ruby/setup-ruby@v1
|
||||||
|
with:
|
||||||
|
ruby-version: .ruby-version # Not needed with a .ruby-version, .tool-versions or mise.toml
|
||||||
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
echo "📦 Installing dependencies..."
|
||||||
|
gem install bundler
|
||||||
|
bundle install --jobs 4 --retry 3
|
||||||
|
npm install -g yarn
|
||||||
|
yarn install
|
||||||
|
echo "📦 Dependencies installed!"
|
||||||
|
|
||||||
|
- name: Run linter
|
||||||
|
run: |
|
||||||
|
echo "🚫 Running linter..."
|
||||||
|
bundle exec rubocop
|
||||||
|
echo "🚫 Linter complete!"
|
||||||
Reference in New Issue
Block a user