Skip to content

Commit b7afa2f

Browse files
authored
Merge pull request #1 from CodinGame/init-runner
feat(runner): Init runner
2 parents 63eb496 + bcce7ea commit b7afa2f

File tree

4 files changed

+124
-1
lines changed

4 files changed

+124
-1
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM mono:4.8
2+
MAINTAINER CodinGame <coders@codingame.com>
3+
COPY entrypoint.sh /
4+
COPY build.sh /project/build
5+
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,90 @@
1-
# mono-nuget-nunit-runner
1+
# mono-nuget-nunit-runner
2+
3+
This standalone runner works with a Nunit project.
4+
5+
First, this runner installs all dependencies using `nuget install` in `/project/packages`. Dependencies must be specified in the `packages.config` file at the project root. It will install the `NUnit-ConsoleRunner` package too. In order to be valid, the 'HintPath' for your dependencies should be `../packages`, which is the default value.
6+
7+
At each play, it copies the user's answer and builds the project. It then runs the provided testcase using NUnit with a `--where "$@"` filter.
8+
9+
The filter syntax can be found here: [https://github.com/nunit/docs/wiki/Test-Selection-Language](https://github.com/nunit/docs/wiki/Test-Selection-Language)
10+
11+
# How to Use
12+
13+
To use this runner for your project, edit the `codingame.yml` file and add the following lines to your project:
14+
15+
```yaml
16+
runner:
17+
name: codingame/mono-nuget-nunit-runner
18+
version: 1.0.0-mono-4.8
19+
```
20+
21+
## Example
22+
23+
**A Git Course Example**
24+
25+
```
26+
.
27+
├── about.md
28+
├── codingame.yml
29+
├── markdowns
30+
│   └── <YOUR_LESSONS>.md
31+
└── projects
32+
└── example #Your project root
33+
├── Example.cs #Your UnitTest Class
34+
├── Example.csproj
35+
├── Exercises
36+
│ ├── Exercise1.cs #The stub provided to the user
37+
│ └── <MORE_EXERCISES>.cs
38+
   └── packages.config
39+
```
40+
41+
**In your CS project:**
42+
43+
*CourseExample.cs*
44+
```cs
45+
using Answer;
46+
using NUnit.Framework;
47+
using System;
48+
49+
namespace CourseExample
50+
{
51+
[TestFixture ()]
52+
public class CourseExample
53+
{
54+
[Test]
55+
public void VerifySum() {
56+
Assert.AreEqual (0, Exercise1.DoSum (0, 0));
57+
/* [...] */
58+
}
59+
}
60+
}
61+
```
62+
63+
*Exercise1.cs*
64+
```cs
65+
using System;
66+
namespace Anwser
67+
{
68+
public class Exercise1 {
69+
/**
70+
* This function should return the sum between a and b
71+
**/
72+
public static int DoSum(int a, int b){
73+
return 1;
74+
}
75+
}
76+
}
77+
```
78+
79+
**In your lesson:**
80+
```md
81+
@[Fix the following code so that the function DoSum returns a sum of integer]({"stubs": ["Exercises/Exercise1.cs"],"command": "'name == VerifySum'"})
82+
```
83+
84+
# Technologies
85+
86+
| Technology | Version |
87+
| ------------- | --------------- |
88+
| **Mono** | [4.8.0](http://www.mono-project.com/docs/about-mono/releases/4.8.0) |
89+
| **Nuget** | lastest |
90+
| **Nunit** | [lastest](https://github.com/nunit/docs/wiki/NUnit-Documentation) |

build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
cd /project/target
4+
5+
nuget update -self
6+
nuget config -set repositoryPath=/project/packages
7+
8+
9+
if [ -f packages.config ]; then
10+
nuget install packages.config
11+
fi
12+
13+
nuget install NUnit.ConsoleRunner

entrypoint.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
cp -a /project/answer/. /project/target
4+
5+
cd /project/target
6+
7+
xbuild /verbosity:quiet /nologo /p:AssemblyName=Solution /p:OutDir=bin/> buildError.txt
8+
9+
if [ -s buildError.txt ]
10+
then
11+
cat buildError.txt
12+
exit -1
13+
else
14+
nunit_console=$(find /project/packages/ -wholename "/project/packages/NUnit.ConsoleRunner*/tools/nunit3-console.exe" -print -quit)
15+
mono $nunit_console --noh --where "$@" ./bin/Solution.dll
16+
fi

0 commit comments

Comments
 (0)