Skip to content

Commit 4992940

Browse files
authored
Add comprehensive GitHub Copilot instructions for development workflow (#842)
1 parent 746493c commit 4992940

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed

.github/copilot-instructions.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# Redmine Git Hosting Plugin
2+
3+
A Redmine plugin that enables Git hosting through Gitolite, providing repository management, SSH key handling, and Git Smart-HTTP functionality.
4+
5+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
6+
7+
## Critical: This is a Redmine Plugin, NOT a Standalone Application
8+
9+
**IMPORTANT**: This codebase is a Redmine plugin that requires a full Redmine installation to run. You cannot run this plugin independently. The plugin extends Redmine's functionality but must be installed within an existing Redmine application.
10+
11+
## Working Effectively
12+
13+
### Development Setup (Linting and Code Quality Only)
14+
- Bootstrap development environment:
15+
- `sudo gem install bundler`
16+
- `touch .enable_dev` (enables development gems)
17+
- `bundle config set --local path 'vendor/bundle'`
18+
- `bundle install --jobs 4 --retry 3` -- takes 80 seconds. Set timeout to 120+ seconds.
19+
- `yarn install` -- takes 30 seconds. Set timeout to 60+ seconds.
20+
21+
### Linting and Code Quality (NEVER CANCEL - All Required for CI)
22+
- `bundle exec rubocop -S` -- Ruby code linting, takes 2 seconds. NEVER CANCEL.
23+
- `bundle exec slim-lint app/views` -- View template linting, takes 3 seconds. NEVER CANCEL.
24+
- `node_modules/.bin/stylelint "assets/stylesheets/*.css"` -- CSS linting, takes 1 second. NEVER CANCEL.
25+
- `bundle exec brakeman` -- Security scanning, takes 3 seconds. NEVER CANCEL.
26+
27+
### What You CANNOT Do (Plugin Limitations)
28+
- **DO NOT** try to run this as a standalone Rails application
29+
- **DO NOT** attempt `rails server` or similar - there is no main application
30+
- **DO NOT** run `rake` commands directly - they require Redmine context
31+
- **DO NOT** try to run RSpec tests without full Redmine setup
32+
- **DO NOT** expect database migrations to work without Redmine
33+
34+
### Full Plugin Testing (Requires Redmine Installation)
35+
**WARNING**: The following requires a complete Redmine setup and takes 45+ minutes:
36+
37+
Complete setup process (from .github/workflows/test.yml):
38+
1. Install system dependencies:
39+
```bash
40+
sudo apt-get update --yes --quiet
41+
sudo apt-get install --yes --quiet build-essential cmake libgpg-error-dev libicu-dev libpq-dev libmysqlclient-dev libssh2-1 libssh2-1-dev pkg-config subversion
42+
```
43+
44+
2. Setup Redmine (clone redmine/redmine repository):
45+
```bash
46+
git clone https://github.com/redmine/redmine.git /path/to/redmine
47+
cd /path/to/redmine
48+
```
49+
50+
3. Install plugin and dependencies:
51+
```bash
52+
# Clone this plugin into redmine/plugins/redmine_git_hosting
53+
# Clone required plugins:
54+
git clone https://github.com/AlphaNodes/additionals.git plugins/additionals
55+
git clone https://github.com/dosyfier/redmine_sidekiq.git plugins/redmine_sidekiq -b fix-rails-6
56+
```
57+
58+
4. Setup Gitolite:
59+
```bash
60+
# Install and configure Gitolite (see CI workflow for complete steps)
61+
ssh-keygen -N '' -f plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa
62+
# Full Gitolite setup required...
63+
```
64+
65+
5. Run tests (45+ minutes total):
66+
```bash
67+
bundle exec rake redmine_git_hosting:ci:all
68+
```
69+
**NEVER CANCEL** - Tests take 45+ minutes. Set timeout to 60+ minutes.
70+
71+
## Validation
72+
73+
### Always Run These Before Committing
74+
- `bundle exec rubocop -S` -- fixes most style issues automatically
75+
- `bundle exec slim-lint app/views` -- checks view templates
76+
- `node_modules/.bin/stylelint "assets/stylesheets/*.css"` -- checks CSS
77+
- `bundle exec brakeman` -- security scanning
78+
79+
### Validation Scenarios (Requires Full Redmine Setup)
80+
Since this is a plugin, validation requires:
81+
1. Full Redmine installation with this plugin
82+
2. Gitolite server setup with SSH keys
83+
3. Database configured (PostgreSQL or MySQL)
84+
4. Test scenarios include:
85+
- Repository creation and management
86+
- SSH key management
87+
- Git Smart-HTTP functionality
88+
- Mirror and deployment credential management
89+
90+
## Common Tasks
91+
92+
### Repo Structure (ls -la output)
93+
```
94+
total 248
95+
drwxr-xr-x 15 runner docker 4096 Aug 11 11:52 .
96+
drwxr-xr-x 3 runner docker 4096 Aug 11 11:38 ..
97+
drwxr-xr-x 2 runner docker 4096 Aug 11 11:41 .bundle
98+
-rw-r--r-- 1 runner docker 0 Aug 11 11:49 .enable_dev
99+
drwxr-xr-x 7 runner docker 4096 Aug 11 11:47 .git
100+
drwxr-xr-x 3 runner docker 4096 Aug 11 11:49 .github
101+
-rw-r--r-- 1 runner docker 183 Aug 11 11:38 .gitignore
102+
-rw-r--r-- 1 runner docker 2121 Aug 11 11:38 .rubocop.yml
103+
-rw-r--r-- 1 runner docker 8299 Aug 11 11:38 .rubocop_todo.yml
104+
-rw-r--r-- 1 runner docker 1270 Aug 11 11:38 .slim-lint.yml
105+
-rw-r--r-- 1 runner docker 5635 Aug 11 11:38 .stylelintrc.json
106+
-rw-r--r-- 1 runner docker 2478 Aug 11 11:38 AUTHORS
107+
-rw-r--r-- 1 runner docker 36496 Aug 11 11:38 CHANGELOG.md
108+
-rw-r--r-- 1 runner docker 1573 Aug 11 11:38 Gemfile
109+
-rw-r--r-- 1 runner docker 9468 Aug 11 11:51 Gemfile.lock
110+
-rw-r--r-- 1 runner docker 1046 Aug 11 11:38 LICENSE
111+
-rw-r--r-- 1 runner docker 1527 Aug 11 11:38 README.md
112+
drwxr-xr-x 13 runner docker 4096 Aug 11 11:38 app
113+
drwxr-xr-x 5 runner docker 4096 Aug 11 11:38 assets
114+
drwxr-xr-x 3 runner docker 4096 Aug 11 11:38 config
115+
drwxr-xr-x 5 runner docker 4096 Aug 11 11:38 contrib
116+
-rw-r--r-- 1 runner docker 1289 Aug 11 11:38 custom_hooks.rb.example
117+
drwxr-xr-x 3 runner docker 4096 Aug 11 11:38 db
118+
-rw-r--r-- 1 runner docker 3561 Aug 11 11:38 init.rb
119+
drwxr-xr-x 6 runner docker 4096 Aug 11 11:38 lib
120+
drwxr-xr-x 79 runner docker 4096 Aug 11 11:52 node_modules
121+
-rw-r--r-- 1 runner docker 104 Aug 11 11:38 package.json
122+
drwxr-xr-x 11 runner docker 4096 Aug 11 11:38 spec
123+
drwxr-xr-x 2 runner docker 4096 Aug 11 11:38 ssh_keys
124+
drwxr-xr-x 3 runner docker 4096 Aug 11 11:51 vendor
125+
-rw-r--r-- 1 runner docker 55068 Aug 11 11:52 yarn.lock
126+
```
127+
128+
### Expected Linting Output Examples
129+
130+
RuboCop output (partial):
131+
```
132+
328 files inspected, 114 offenses detected, 75 offenses autocorrectable
133+
```
134+
135+
Slim-lint output (partial):
136+
```
137+
app/views/repositories/_git_hosting_sidebar.html.slim:9 [W] RuboCop: Style/RedundantLineContinuation
138+
app/views/settings/redmine_git_hosting/_gitolite_config_test.html.slim:95 [W] RuboCop: Style/RedundantRegexpArgument
139+
```
140+
141+
StyleLint typically produces no output when CSS is clean.
142+
143+
Brakeman output (partial):
144+
```
145+
Confidence: Weak
146+
Category: Dangerous Eval
147+
Check: Evaluation
148+
Message: Dynamic string evaluated as code
149+
```
150+
151+
## Common Tasks
152+
153+
### Repo Structure
154+
```
155+
.
156+
├── .github/workflows/ # CI/CD workflows
157+
├── .rubocop.yml # Ruby linting configuration
158+
├── .slim-lint.yml # Slim template linting
159+
├── .stylelintrc.json # CSS linting configuration
160+
├── app/ # Rails application components
161+
│ ├── controllers/ # Plugin controllers
162+
│ ├── models/ # Plugin models
163+
│ ├── views/ # Slim templates
164+
│ └── workers/ # Background job workers
165+
├── assets/ # Static assets
166+
│ ├── javascripts/ # JavaScript files
167+
│ └── stylesheets/ # CSS files
168+
├── lib/ # Ruby libraries and core plugin code
169+
├── spec/ # RSpec tests
170+
├── Gemfile # Ruby dependencies
171+
├── init.rb # Plugin initialization
172+
└── package.json # Node.js dependencies (for linting)
173+
```
174+
175+
### Key Plugin Components
176+
- **Gitolite Integration**: Repository hosting through Gitolite
177+
- **SSH Key Management**: User SSH key handling
178+
- **Git Smart-HTTP**: Web-based Git access
179+
- **Repository Mirrors**: Repository mirroring functionality
180+
- **Background Jobs**: Sidekiq-based async processing
181+
182+
### CI Requirements
183+
The CI pipeline (.github/workflows/) requires:
184+
- Ruby 2.7+ (supports up to 3.1)
185+
- Redmine 4.1+ (supports up to master)
186+
- PostgreSQL or MySQL database
187+
- Gitolite installation
188+
- System dependencies for Git/SSH operations
189+
190+
### Dependencies
191+
- **Ruby Gems**: Defined in Gemfile (gitolite-rugged, gitlab-grack, etc.)
192+
- **Node.js**: Only for development linting tools
193+
- **System**: Git, SSH, Gitolite, database, build tools
194+
195+
### Development Notes
196+
- Uses Slim templates for views
197+
- Follows Rails/Redmine conventions
198+
- Extensive test coverage with RSpec
199+
- Security scanning with Brakeman
200+
- Code style enforced with RuboCop
201+
202+
## Important Files to Check After Changes
203+
- Always run all linting tools before committing
204+
- Check `init.rb` when modifying plugin structure
205+
- Review `lib/redmine_git_hosting.rb` for core functionality changes
206+
- Update tests in `spec/` when adding new features
207+
- Check `assets/` for frontend changes requiring CSS linting

0 commit comments

Comments
 (0)