Bläddra i källkod

Add build script & instructions for contributors.

John S. Ryan 11 år sedan
förälder
incheckning
f38784aa2d
4 ändrade filer med 237 tillägg och 7 borttagningar
  1. 1
    4
      .travis.yml
  2. 224
    3
      README.md
  3. 0
    0
      _template/src/example/java/.keep
  4. 12
    0
      bin/build.sh

+ 1
- 4
.travis.yml Visa fil

@@ -6,7 +6,4 @@ jdk:
6 6
 sudo: false
7 7
 
8 8
 script:
9
-  - gradle --version
10
-  - TERM=dumb gradle check compileStarterSourceJava --continue
11
-  - bin/fetch-configlet
12
-  - bin/configlet .
9
+  - bin/build.sh

+ 224
- 3
README.md Visa fil

@@ -1,12 +1,233 @@
1 1
 # xJava [![Build Status](https://travis-ci.org/exercism/xjava.svg?branch=master)](https://travis-ci.org/exercism/xjava)
2 2
 
3
-Exercism Exercises in Java
3
+Exercism Exercises in Java.
4 4
 
5 5
 ## Contributing Guide
6 6
 
7
-Please see the [contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data)
7
+For general information about how to contribute to Exercism, please refer to the [Contributing Guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data).
8 8
 
9
-## License
9
+## Table of Contents
10
+
11
+* [Overview](#overview)
12
+* [Getting Setup](#getting-setup)
13
+* [Getting Familiar With the Codebase](#getting-familiar-with-the-codebase)
14
+  * [The Rootproject](#the-rootproject)
15
+  * [The Problem Subprojects](#the-problem-subprojects)
16
+  * [Running The Build](#running-the-build)
17
+* [Submitting Your Contribution](#submitting-your-contribution)
18
+  * [Doing the Commit Dance](#doing-the-commit-dance)
19
+  * [Making the Pull Request](#making-the-pull-request)
20
+* [Reverting Your CLI Config](#reverting-your-cli-config)
21
+
22
+
23
+## Overview
24
+----
25
+
26
+This guide walks you through how to contribute to the Java language track.  It is opinionated and specific to allow those who are relatively new to Free Open Source Software to have a fighting chance of being successful.  However, if you know what you're doing, we intent these instructions to be guidelines.
27
+
28
+The steps described herein were composed on OS X.  They will presumably work with no change on any *nix distro.  Almost all of them will work on Windows; though you might want to use cygwin or some other Unix support for creating soft-links.  Otherwise, you'll need to improvise on some steps.  If you *do* find a nice workflow for Windows, please feel free to submit a PR for changes to this doc.  Thanks!
29
+
30
+This guide flows chronologically, from setting-up your environment, taking a quick tour of the build process to finally what it takes to successfully submit.
31
+
32
+If, at any point, you're having any trouble, pop in the [Gitter exercism/dev room](https://gitter.im/exercism/dev) for help.
33
+
34
+
35
+## Getting Setup
36
+----
37
+
38
+You'll *need* the following:
39
+
40
+* Java 1.8+
41
+* Gradle 2.x
42
+* Git 1.x
43
+
44
+If you haven't already, please read our advice on [Git Workflow](http://help.exercism.io/git-workflow.html).
45
+
46
+
47
+Here's one way to get setup:
48
+
49
+1. **Stand-up the x-api, locally.**  You should ultimate verify your work by delivering your problem through the exercism CLI and solving it from that `exercism fetch`'ed copy.  The CLI fetches problems from the x-api.  You'll need your own instance of the x-api running locally.
50
+
51
+	```
52
+	cd ~
53
+	mkdir -p workspace/exercism && cd workspace/exercism
54
+	git clone https://github.com/exercism/x-api
55
+	cd x-api
56
+	bundle install
57
+	git submodule init
58
+	git submodule update
59
+	rackup
60
+	```
61
+
62
+If you want more details, check out the [x-api README](https://github.com/exercism/x-api).
63
+
64
+2. **Configure your exercism CLI to point to that x-api.** Out of the box, the CLI is configured to point to the production instances of the API (for account-specific data) and X-API (for problem data).  You need to configure your CLI to point to the X-API instance you stood up in the prior step.
65
+	
66
+	If you haven't already, you'll need need to [install the CLI](http://help.exercism.io/installing-the-cli.html).
67
+
68
+	```
69
+	cd ~
70
+	mkdir -p workspace/exercism/exercises
71
+	cd ~/workspace/exercism/exercises
72
+	exercism configure --dir=~/workspace/exercism/exercises
73
+	exercism configure --api http://localhost:9292
74
+	exercism debug
75
+	exercism fetch java bob
76
+	tree java
77
+	```
78
+
79
+	If things are properly setup:
80
+	* `exercism debug` output will include "`XAPI: http://localhost:9292 [connected]`"
81
+	* `tree java` will look something like this:
82
+	
83
+		```
84
+		java
85
+		└── bob
86
+		    ├── README.md
87
+		    ├── build.gradle
88
+		    └── src
89
+		        └── test
90
+		            └── java
91
+		                └── BobTest.java
92
+		```
93
+
94
+3. **Point your local x-api to your xjava fork.**  Most people contribute by submitting pull request from their fork of the track repo (covered below).  To make it easy to develop, replace the java problem set in your local x-api with your fork:
95
+
96
+	If you haven't already, fork the track repo: [exercism/xjava](https://github.com/exercism/xjava).
97
+
98
+	```
99
+	cd ~/workspace/exercism/
100
+	git clone git@github.com:jtigger/xjava.git
101
+	git remote add upstream https://github.com/exercism/xjava.git
102
+	git pull --rebase upstream/master
103
+	cd ~/workspace/exercism/x-api/problems
104
+	rm -rf java
105
+	ln -s ../../xjava java
106
+	```
107
+
108
+You are now ready to go!
109
+
110
+## Getting Familiar With the Codebase
111
+----
112
+
113
+There are two objectives to the design of this build:
114
+
115
+1. when a problem is built from within the xjava repo, the tests run against the "example" code.
116
+2. when a problem is built outside the xjava repo (namely, when it has been served through the CLI on a user's computer), the tests run against the "main" code.
117
+
118
+This repo is a mulit-project gradle build.
119
+
120
+### The Rootproject
121
+
122
+The rootproject is a container for the problem subprojects.
123
+
124
+  * it's `build.gradle` points the "main" sourceset to the example code.
125
+  * it's `settings.gradle` names each of the subprojects, one for each problem in the set.
126
+
127
+
128
+### The Problem Subprojects
129
+
130
+Each problem/subproject is a subdirectory of the same name as its slug.
131
+
132
+  * it's `build.gradle` names dependencies required to work that problem.
133
+
134
+Each problem/subproject has three source sets:
135
+
136
+* `src/test/java/` — a test suite defining the edges of the problem
137
+* `src/example/java/` — an example solution that passes all the tests
138
+* `src/main/java/` — starter source files, if required/desired *(this directory usually only has a `.keep` file in it)*.
139
+
140
+### Running The Build
141
+
142
+To run all the tests against example code:
143
+
144
+```
145
+cd ~/workspace/exercism/xjava
146
+gradle assemble check
147
+```
148
+
149
+To run the test against just one problem, run gradle from within that directory:
150
+
151
+```
152
+cd ~/workspace/exercism/xjava/bob
153
+gradle assemble check
154
+```
155
+
156
+To run the complete build as done on CI (which includes compiling any "starter" code and running the configlet tool):
157
+
158
+```
159
+cd ~/workspace/exercism/xjava
160
+./bin/build.sh
161
+```
162
+
163
+## Submitting Your Contribution
164
+----
165
+
166
+First of all... Exercism is meant help programmers, world-wide, to develop their skills and in doing so help raise the bar on our industry as a whole.  Your contribution is making that experience even better.  Thank you!
167
+
168
+Before you submit a pull request, please ensure:
169
+
170
+- the test suite covers the essential parts of the problem and interesting corner cases.
171
+- your example solution represents your best attempt at exemplary code. 
172
+- the build script (`./bin/build.sh`) compiles and tests your code successfully.
173
+
174
+
175
+### Doing the Commit Dance
176
+*(These instructions assume you setup your development environment using the instructions above.)*
177
+
178
+1. **Run the build script, locally.**
179
+ 
180
+   ```
181
+   cd ~/workspace/exercism/xjava
182
+   ./bin/build.sh
183
+   ```
184
+
185
+   verify that the script runs successfully.
186
+   
187
+2. **Fetch the problem from your local x-api, using the CLI.**
188
+
189
+   ```
190
+   cd ~/workspace/exercism/exercises
191
+   exercism fetch java <problem-slug>
192
+   ```
193
+   
194
+   verify that the fetched problem does *not* contain any files not needed for the problem.
195
+   
196
+3. **Run the tests against the example source.**
197
+
198
+   ```
199
+   cd ~/workspace/exercism/exercises/java/<problem-slug>
200
+   cp ../../../xjava/<problem-slug>/src/example/java/* src/main/java
201
+   gradle check
202
+   ```
203
+
204
+   verify that all tests pass.
205
+   
206
+If you've successfully navigated to this point, you're ready to make that pull request!
207
+
208
+### Making the Pull Request
209
+
210
+Hopefully you've read our [Git Workflow](http://help.exercism.io/git-workflow.html) and done your work on a clone of a fork of the exercism xjava repo.
211
+
212
+After you've pushed your changes to your fork (best done on a branch, remember), it's a matter of going to GitHub and submitting a pull request.
213
+
214
+When you do so, notice that it automatically kicks off a CI build on Travis.  This is an important step: **be sure to wait for the CI results to come back before you leave!**  Pull Requests that do no pass CI will not be merged in.
215
+
216
+One of the track maintainers will review your PR as soon as we can.
217
+
218
+If you need help, drop in on the [Gitter exercism/dev room](https://gitter.im/exercism/dev).
219
+
220
+
221
+## Reverting Your CLI Config
222
+
223
+In the setup, above, we configured the CLI client to point to your local x-api instance.  Presumably, you like to submit solutions, yourself.  To revert your CLI back to the the production x-api:
224
+
225
+```
226
+exercism configure --api http://x.exercism.io
227
+```
228
+
229
+
230
+# License
10 231
 
11 232
 The MIT License (MIT)
12 233
 

+ 0
- 0
_template/src/example/java/.keep Visa fil


+ 12
- 0
bin/build.sh Visa fil

@@ -0,0 +1,12 @@
1
+#!/bin/bash
2
+set -e
3
+gradle --version
4
+echo ""
5
+echo ">>> Running tests..."
6
+TERM=dumb gradle check compileStarterSourceJava --continue
7
+
8
+
9
+echo ""
10
+echo ">>> Running configlet..."
11
+bin/fetch-configlet
12
+bin/configlet .