Skip to content

Commit 4229f8e

Browse files
author
Erik Hofer
authored
Merge pull request #42 from codefreak/feature/2-0-0
Upgrade templates for new definition format
2 parents 33062d6 + f29d56e commit 4229f8e

30 files changed

+10247
-664
lines changed

.gitignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@
22
.gradle
33

44
# Ignore Gradle build output directory
5-
build
6-
templates/csharp/**/obj
5+
/build
6+
/templates/java/build
7+
8+
# Ignore C# build artifacts
9+
/templates/csharp/**/obj
10+
11+
__pycache__
12+
node_modules

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
apply plugin: 'java'
1+
plugins {
2+
id "java"
3+
}
4+
5+
group = 'com.github.codefreak'
26

37
jar {
48
dependsOn 'createArchives'

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'codefreak-templates'
1+
rootProject.name = 'templates'

templates/cpp/.codeclimate.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

templates/cpp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
# FetchContent is available since 3.11
2+
cmake_minimum_required(VERSION 3.11)
23
project(ExampleProject)
34

45
set(CMAKE_CXX_STANDARD 11)

templates/cpp/codefreak.yml

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,57 @@
11
---
22
title: Program in C++
3-
description: "# C++ Task Example\n\nThis is a basic C++ task to get you started quickly with Code FREAK.\n\nTo turn this into a useful programming exercise, you have to do the following.\n\n## Provide Code to Students\n\nIf you do not want your students to start completely from scratch, provide some scaffolding code. Look into `src` for some inspiration.\n\n## Setup Automatic Evaluation\n\nThis example comes with a pre-configured evaluation step. You can see it in the _Evaluation_ tab. To try it out, enter _testing mode_ and start the evaluation.\n\n### Unit Tests\n\nUnit tests are your main instrument for automatically validating your students' answers. To get started, look into `test` for example test cases.\n\nThe standard testing framework for C++ is googletest. Refer to the [official documentation](https://github.com/google/googletest) for more information.\n\n## Provide Instructions\n\nClick on this text to edit it. Here you describe to your students what they have to do.\n"
3+
description: |-
4+
# C++ Task Example
5+
6+
This is a basic C++ task to get you started quickly with Code FREAK.
7+
8+
To turn this into a useful programming exercise, you have to do the following.
9+
10+
## Provide Code to Students
11+
12+
If you do not want your students to start completely from scratch, provide some scaffolding code. Look into `src` for some inspiration.
13+
14+
## Setup Automatic Evaluation
15+
16+
This example comes with a pre-configured evaluation step. You can see it in the _Evaluation_ tab. To try it out, enter _testing mode_ and start the evaluation.
17+
18+
### Static Code Analysis
19+
20+
The code is anaylzed using [cpplint](https://github.com/cpplint/cpplint) for proper formatting, which enforces [Google's C++ code styleguide](https://github.com/google/styleguide).
21+
22+
### Unit Tests
23+
24+
Unit tests are your main instrument for automatically validating your students' answers. To get started, look into `test` for example test cases.
25+
26+
The standard testing framework for C++ is googletest. Refer to the [official documentation](https://github.com/google/googletest) for more information.
27+
28+
## Provide Instructions
29+
30+
Click on this text to edit it. Here you describe to your students what they have to do.
431
hidden:
532
- test/**
6-
- .codeclimate.yml
733
protected:
834
- CMakeLists.txt
935
evaluation:
10-
- step: comments
11-
options: {}
12-
title: Comments
13-
- step: junit
14-
options:
15-
image: rikorose/gcc-cmake
16-
results-path: test-results
17-
project-path: /code
18-
commands:
19-
- "rm -rf build # Remove possible build files because there might be conflicting settings (i.e. the compiler path) from external builds"
20-
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles"
21-
- make -C build ExampleProject_tst
22-
- build/test/ExampleProject_tst --gtest_output=xml:test-results/TEST-report.xml
23-
title: Unit Tests
24-
- step: codeclimate
25-
options: {}
26-
title: Code Quality
36+
unit-tests:
37+
title: Unit Tests
38+
script: |-
39+
# Remove possible build files because there might be conflicting settings (i.e. the compiler path) from external builds"
40+
rm -rf build
41+
mkdir -p build
42+
cd build
43+
cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" ..
44+
make ExampleProject_tst
45+
test/ExampleProject_tst --gtest_output=xml:test-results/TEST-report.xml
46+
report:
47+
format: junit-xml
48+
path: build/test-results/TEST-report.xml
49+
code-quality:
50+
title: Code Quality
51+
script: |-
52+
pip3 install cpplint
53+
# Errors will be written to stderr
54+
cpplint --recursive --output=vs7 --root=src --filter=-legal/copyright --quiet src 2> cpplint-report.txt
55+
report:
56+
format: visualstudio
57+
path: cpplint-report.txt

templates/cpp/src/Calculator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#ifndef CALCULATOR_H
2-
#define CALCULATOR_H
1+
#ifndef CALCULATOR_H_
2+
#define CALCULATOR_H_
33

44
class Calculator {
5-
public:
5+
public:
66
/**
77
* Return the sum of a and b
88
* Throws an exception if a and/or b have illegal resultTypes or the result cannot be calculated
@@ -14,4 +14,4 @@ class Calculator {
1414
int add(int a, int b);
1515
};
1616

17-
#endif // CALCULATOR_H
17+
#endif // CALCULATOR_H_

templates/cpp/src/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#include<iostream>
22
#include"Calculator.h"
3-
using namespace std;
43

54
void printSumOf(int a, int b) {
65
Calculator calculator;
7-
cout << a << " + " << b << " = " << calculator.add(a, b) << endl;
6+
std::cout << a << " + " << b << " = " << calculator.add(a, b) << std::endl;
87
}
98

109
int main() {
@@ -13,4 +12,3 @@ int main() {
1312
printSumOf(0, 0);
1413
return 0;
1514
}
16-

templates/csharp/codefreak.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description: |
1616
1717
### Static Code Analysis
1818
19-
The tool [Code Climate](https://github.com/codeclimate/codeclimate) is used to provide your students with tips on how to write better code. It is configured via `.codeclimate.yml` in the task files. See [official documentation](https://docs.codeclimate.com/docs/advanced-configuration) for details.
19+
The code is anaylzed using [dotnet-format](https://github.com/dotnet/format) for proper formatting.
2020
2121
### Unit Tests
2222
@@ -32,11 +32,20 @@ hidden:
3232
protected:
3333
- AddFunction.sln
3434
evaluation:
35-
- step: codeclimate
36-
- step: junit
37-
options:
38-
image: "mcr.microsoft.com/dotnet/core/sdk:3.1"
39-
project-path: /code
40-
results-path: tests/AddFunction.Tests
41-
commands:
42-
- dotnet test tests/AddFunction.Tests/AddFunction.Tests.csproj --logger "junit;LogFilePath=TEST-report.xml"
35+
unit-tests:
36+
title: Unit Tests
37+
script: |-
38+
export PATH="$PATH:$HOME/.dotnet:$HOME/.dotnet/tools"
39+
dotnet test tests/AddFunction.Tests/AddFunction.Tests.csproj --logger "junit;LogFilePath=TEST-report.xml"
40+
report:
41+
format: junit-xml
42+
path: tests/AddFunction.Tests/TEST-report.xml
43+
code-quality:
44+
title: Code Quality
45+
script: |-
46+
export PATH="$PATH:$HOME/.dotnet:$HOME/.dotnet/tools"
47+
dotnet tool install -g dotnet-format
48+
dotnet-format -v quiet --check 2> dotnet-format-report.txt
49+
report:
50+
format: visualstudio
51+
path: dotnet-format-report.txt
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using System;
2-
3-
namespace AddFunction
4-
{
5-
public class Program
6-
{
7-
public static int Add(int a, int b)
8-
{
9-
return 0;
10-
}
11-
static void Main(string[] args)
12-
{
13-
Console.WriteLine("Hello World!");
14-
}
15-
}
16-
}
1+
using System;
2+
3+
namespace AddFunction
4+
{
5+
public class Program
6+
{
7+
public static int Add(int a, int b)
8+
{
9+
return 0;
10+
}
11+
static void Main(string[] args)
12+
{
13+
Console.WriteLine("Hello World!");
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)