Debian Codegraph @

CONTRIBUTING.md

raw
1 # Contributing
2
3 This guide has been written to help anyone interested in contributing
4 to the development of Dancer2.
5
6 First of all - thank you for your interest in the project! It's the
7 community of helpful contributors who've helped Dancer grow
8 phenomenally. Without the community we wouldn't be where we are today!
9
10 Please read this guide before contributing to Dancer2 to avoid wasted
11 or duplicated effort, and to maximize the chances of your contributions
12 being used.
13
14 There are many ways to contribute to the project beyond what is in this
15 document. Dancer2 is an active project and any kind of help is very much
16 appreciated!
17
18 ### Asking Questions
19
20 Yes, asking questions contributes to our overall community! Please use
21 IRC or StackOverflow if possible. If these other options don't work for
22 you, or it's taking too long to get an answer, you can leave a question on
23 our [GitHub issues page](https://github.com/PerlDancer/Dancer2/issues).
24
25 ### Reporting Bugs
26
27 We prefer to have all our bug reports on GitHub, in the
28 [issues section](https://github.com/PerlDancer/Dancer2/issues).
29
30 Please make sure the bug you're reporting does not yet exist. If in doubt
31 please ask on IRC.
32
33 When reporting an issue, please include the following information in
34 your post:
35
36 - Describe what you expected to happen.
37 - Describe what actually happened.
38 - If possible, include a minimal reproducible example of the problem to
39 help us identify and fix the issue. This also helps us make sure it's
40 not an issue with your code.
41 - List the Perl and Dancer2 versions you are using. If you can, see if
42 this has already been reported and fixed with the latest code in
43 GitHub.
44
45 ### Improve Documentation
46
47 We value documentation very much, but it's difficult to keep it
48 up-to-date. If you find a typo or an error in the documentation
49 please do let us know - ideally by submitting a patch (pull request)
50 with your fix or suggestion (see
51 [Patch Submission](#environment-and-patch-submission)).
52
53 ### Writing Code
54
55 You can write extensions (plugins) for Dancer2 extending core
56 functionality or contribute to Dancer2's core code, see
57 [Patch Submission](#environment-and-patch-submission) below.
58
59 ### Blog or Write Articles
60
61 Some of the best ways to spread the word about Dancer2 is to blog or
62 write articles. Consider DEV.to, Medium, your personal blog, or even the
63 [Perl blogs site](https://blogs.perl.org).
64
65 ## General Development Guidelines
66
67 This section lists high-level recommendations for developing Dancer2,
68 for more detailed guidelines, see [Coding Guidelines](#coding-guidelines)
69 below.
70
71 ### Quality Assurance
72
73 Dancer2 should be able to install for all Perl versions since 5.14, on
74 any platform for which Perl exists. We focus mainly on GNU/Linux (any
75 distribution), \*BSD and Windows (native and Cygwin).
76
77 We should avoid regressions as much as possible and keep backwards
78 compatibility in mind when refactoring. Just because the minimum
79 supported version of Perl changes doesn't mean that existing code should
80 immediately be rewritten to include new language features. For new code,
81 or code that is being refactored for other reasons, it is acceptable to
82 use language features that are new to the minimum supported version of
83 Perl supported by the Dancer Core Team.
84
85 Stable releases should not break functionality and new releases should
86 provide an upgrade path and upgrade tips such as warning the user
87 about deprecated functionality.
88
89 ### Quality Supervision
90
91 We can measure our quality using the
92 [CPAN testers platform](https://www.cpantesters.org).
93
94 A good way to help the project is to find a failing build log on the
95 [CPAN testers](https://www.cpantesters.org/distro/D/Dancer2.html).
96
97 If you find a failing test report, feel free to report it as a
98 [GitHub issue](https://github.com/PerlDancer/Dancer2/issues).
99
100 ## Environment and Patch Submission
101
102 ### Set up a development environment
103
104 If you want to submit a patch for Dancer2, you need git and very
105 likely also [_Dist::Zilla_](https://metacpan.org/module/Dist::Zilla).
106 We also recommend perlbrew (see below) or,
107 alternatively, [_App::Plenv_](https://github.com/tokuhirom/plenv))
108 to test and develop Dancer2 on a recent
109 version of Perl. We also suggest
110 [_App::cpanminus_](https://metacpan.org/module/App::cpanminus)
111 to quickly and comfortably install Perl modules.
112
113 In the following sections we provide tips for the installation of some
114 of these tools together with Dancer. Please also see the documentation
115 that comes with these tools for more info.
116
117 #### Perlbrew tips (Optional)
118
119 Install perlbrew for example with
120
121 $ cpanm App::perlbrew
122
123 Check which Perls are available
124
125 $ perlbrew available
126
127 It should list the available Perl versions, like this (incomplete) list:
128
129 perl-5.17.1
130 perl-5.16.0
131 perl-5.14.2
132 ...
133
134 Now run the init command for perlbrew. The init command initializes and controls
135 processes. The init command is run as the last step of any startup
136 process.
137
138 $ perlbrew init
139
140 Then install a version inside perlbrew. We recommend you
141 give a name to the installation (`--as` option), as well as compiling
142 without the tests (`--n` option) to speed it up.
143
144 $ perlbrew install -n perl-5.14.4 --as dancer_development -j 3
145
146 Wait a while, and it should be done. Switch to your new Perl with:
147
148 $ perlbrew switch dancer_development
149
150 Now you are using the fresh Perl, you can check it with:
151
152 $ which perl
153
154 Install cpanm on your brewed version of Perl.
155
156 $ perlbrew install-cpanm
157
158 ### Install various dependencies (required)
159
160 Install Dist::Zilla
161
162 $ cpanm Dist::Zilla
163
164 ### Get Dancer2 sources
165
166 Get the Dancer sources from github (for a more complete git workflow
167 see below):
168
169 Clone your fork to have a local copy using the following command:
170
171 $ git clone git://github.com/yourname/Dancer2.git
172
173 The Dancer2 sources come with a `dist.ini`. That's the configuration
174 file for _Dist::Zilla_, so that it knows how to build Dancer2. Let's
175 use dist.ini to install additional `Dist::Zilla` plugins which are
176 not yet installed on your system (or Perl installation):
177
178 $ dzil authordeps | cpanm -n
179
180 That should install a bunch of stuff. Now that _Dist::Zilla_ is up and
181 running, you should install the dependencies required by Dancer2:
182
183 $ dzil listdeps | cpanm -n
184
185 When that is done, you're good to go! You can use `dzil` to build and test
186 Dancer2:
187
188 $ dzil build
189 $ dzil test --no-author
190
191 ### Running your modified version
192
193 If you have any version of Dancer2 installed on your system you will likely
194 run into problems when you try and run the "Dancer2" binary due to the wrong
195 lib's being used.
196 The following command should resolve that.
197 ```bash
198 perl -Ilib script/dancer2 gen -s share/skel --overwrite --path /tmp/d2app -a MyApp::App
199 ```
200 - It assumes we are in the git repo root dir
201 - `-Ilib` - tells perl to include the lib dir in it's search path
202 - in this case we run "gen" and
203 - `-s share/skel` - specify the use of the local copy of the skel dir
204 - `--overwrite` - we want to overwrite the generated scaffold project
205 - `--path /tmp/d2app` - the dir to write the generated scaffold project dir to
206 - `-a MyApp::App` - the name of the app project we want to generate
207
208
209 ### Patch Submission (Github workflow)
210
211 The Dancer2 development team uses GitHub to collaborate. We greatly
212 appreciate contributions submitted via GitHub, as it makes tracking
213 these contributions and applying them much, much easier. This gives
214 your contribution a much better chance of being integrated into
215 Dancer2 quickly!
216
217 **NOTE:** All active development is performed in the _main_ branch.
218 Therefore, all your contribution work should be done in a fork of the
219 _main_ branch.
220
221 Here is the workflow for submitting a patch:
222
223 1. Fork the repository: https://github.com/PerlDancer/Dancer2 and click "Fork";
224
225 2. Clone your fork to have a local copy using the following command:
226
227 $ git clone git://github.com/yourname/Dancer2.git
228
229 3. As a contributor, you should **always** work on the `main` branch of
230 your clone.
231
232 $ git remote add upstream https://github.com/PerlDancer/Dancer2.git
233 $ git fetch upstream
234
235 This will create a local branch in your clone named _main_ and
236 that will track the official _main_ branch. That way, if you have
237 more or less commits than the upstream repo, you'll be immediately
238 notified by git.
239
240 4. You want to isolate all your commits in a _topic_ branch, this
241 will make the reviewing much easier for the core team and will
242 allow you to continue working on your clone without worrying about
243 different commits mixing together.
244
245 To do that, first create a local branch to build your pull request:
246
247 # you should be in main here
248 $ git checkout -b pr/$name
249
250 Now you have created a local branch named _pr/$name_ where _$name_
251 is the name you want (it should describe the purpose of the pull
252 request you're preparing).
253
254 In that branch, do all the commits you need (the more the better)
255 and when done, push the branch to your fork:
256
257 # ... commits ...
258 git push origin pr/$name
259
260 You are now ready to send a pull request.
261
262 5. Run the test suite! Pull requests with failing tests will not be
263 considered. You have two ways to run tests, either with prove:
264
265 $ prove -lvr t/
266
267 or via _Dist::Zilla_:
268
269 $ dzil test --all
270
271 6. Send a _pull request_ via the GitHub interface. Make sure your pull
272 request is based on the _pr/$name_ branch you've just pushed, so
273 that it incorporates the appropriate commits only.
274
275 It's also a good idea to summarize your work in a report sent to
276 the users' mailing list (see below), in order to make sure the team
277 is aware of it.
278
279 You could also notify the core team on IRC, on `irc.perl.org`,
280 channel `#dancer` or via [web client](https://www.perldancer.org/irc).
281
282 7. When the core team reviews your pull request, it will either accept
283 (and then merge into _main_) or refuse your request.
284
285 If it's refused, try to understand the reasons explained by the
286 team for the denial. Most of the time, communicating with the core
287 team is enough to understand what the mistake was. Above all,
288 please don't be offended.
289
290 If your pull request is merged into _main_, then all you have to
291 do is remove your local and remote _pr/$name_ branch:
292
293 $ git checkout main
294 $ git branch -D pr/$name
295 $ git push origin :pr/$name
296
297 And then, of course, you need to sync your local devel branch with
298 upstream:
299
300 $ git pull upstream main
301 $ git push origin main
302
303 You're now ready to start working on a new pull request!
304
305 ### Pull Request Review Guidelines
306
307 This is a non-exhaustive list of things that may cause the Dancer Core
308 Team to request modifications to (or reject) your pull request:
309
310 - Insufficient documentation
311 - Failing tests in the test suite
312 - Lack of tests provided covering new/changed functionality
313 - Merge conflicts in git
314 - Poor commit messages
315 - Code or feature does not fit with the Core Team's vision or values for
316 Dancer
317 - Code introduces new bugs, or does not completely resolve an issue
318