Skip to content

Commit

Permalink
Merge pull request #42 from codefreak/feature/2-0-0
Browse files Browse the repository at this point in the history
Upgrade templates for new definition format
  • Loading branch information
Erik Hofer authored Aug 20, 2021
2 parents 33062d6 + f29d56e commit 4229f8e
Show file tree
Hide file tree
Showing 30 changed files with 10,247 additions and 664 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
.gradle

# Ignore Gradle build output directory
build
templates/csharp/**/obj
/build
/templates/java/build

# Ignore C# build artifacts
/templates/csharp/**/obj

__pycache__
node_modules
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
apply plugin: 'java'
plugins {
id "java"
}

group = 'com.github.codefreak'

jar {
dependsOn 'createArchives'
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'codefreak-templates'
rootProject.name = 'templates'
10 changes: 0 additions & 10 deletions templates/cpp/.codeclimate.yml

This file was deleted.

3 changes: 2 additions & 1 deletion templates/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.10)
# FetchContent is available since 3.11
cmake_minimum_required(VERSION 3.11)
project(ExampleProject)

set(CMAKE_CXX_STANDARD 11)
Expand Down
69 changes: 50 additions & 19 deletions templates/cpp/codefreak.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,57 @@
---
title: Program in C++
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"
description: |-
# C++ Task Example
This is a basic C++ task to get you started quickly with Code FREAK.
To turn this into a useful programming exercise, you have to do the following.
## Provide Code to Students
If you do not want your students to start completely from scratch, provide some scaffolding code. Look into `src` for some inspiration.
## Setup Automatic Evaluation
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.
### Static Code Analysis
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).
### Unit Tests
Unit tests are your main instrument for automatically validating your students' answers. To get started, look into `test` for example test cases.
The standard testing framework for C++ is googletest. Refer to the [official documentation](https://github.com/google/googletest) for more information.
## Provide Instructions
Click on this text to edit it. Here you describe to your students what they have to do.
hidden:
- test/**
- .codeclimate.yml
protected:
- CMakeLists.txt
evaluation:
- step: comments
options: {}
title: Comments
- step: junit
options:
image: rikorose/gcc-cmake
results-path: test-results
project-path: /code
commands:
- "rm -rf build # Remove possible build files because there might be conflicting settings (i.e. the compiler path) from external builds"
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles"
- make -C build ExampleProject_tst
- build/test/ExampleProject_tst --gtest_output=xml:test-results/TEST-report.xml
title: Unit Tests
- step: codeclimate
options: {}
title: Code Quality
unit-tests:
title: Unit Tests
script: |-
# Remove possible build files because there might be conflicting settings (i.e. the compiler path) from external builds"
rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" ..
make ExampleProject_tst
test/ExampleProject_tst --gtest_output=xml:test-results/TEST-report.xml
report:
format: junit-xml
path: build/test-results/TEST-report.xml
code-quality:
title: Code Quality
script: |-
pip3 install cpplint
# Errors will be written to stderr
cpplint --recursive --output=vs7 --root=src --filter=-legal/copyright --quiet src 2> cpplint-report.txt
report:
format: visualstudio
path: cpplint-report.txt
8 changes: 4 additions & 4 deletions templates/cpp/src/Calculator.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef CALCULATOR_H
#define CALCULATOR_H
#ifndef CALCULATOR_H_
#define CALCULATOR_H_

class Calculator {
public:
public:
/**
* Return the sum of a and b
* Throws an exception if a and/or b have illegal resultTypes or the result cannot be calculated
Expand All @@ -14,4 +14,4 @@ class Calculator {
int add(int a, int b);
};

#endif // CALCULATOR_H
#endif // CALCULATOR_H_
4 changes: 1 addition & 3 deletions templates/cpp/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include<iostream>
#include"Calculator.h"
using namespace std;

void printSumOf(int a, int b) {
Calculator calculator;
cout << a << " + " << b << " = " << calculator.add(a, b) << endl;
std::cout << a << " + " << b << " = " << calculator.add(a, b) << std::endl;
}

int main() {
Expand All @@ -13,4 +12,3 @@ int main() {
printSumOf(0, 0);
return 0;
}

27 changes: 18 additions & 9 deletions templates/csharp/codefreak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description: |
### Static Code Analysis
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.
The code is anaylzed using [dotnet-format](https://github.com/dotnet/format) for proper formatting.
### Unit Tests
Expand All @@ -32,11 +32,20 @@ hidden:
protected:
- AddFunction.sln
evaluation:
- step: codeclimate
- step: junit
options:
image: "mcr.microsoft.com/dotnet/core/sdk:3.1"
project-path: /code
results-path: tests/AddFunction.Tests
commands:
- dotnet test tests/AddFunction.Tests/AddFunction.Tests.csproj --logger "junit;LogFilePath=TEST-report.xml"
unit-tests:
title: Unit Tests
script: |-
export PATH="$PATH:$HOME/.dotnet:$HOME/.dotnet/tools"
dotnet test tests/AddFunction.Tests/AddFunction.Tests.csproj --logger "junit;LogFilePath=TEST-report.xml"
report:
format: junit-xml
path: tests/AddFunction.Tests/TEST-report.xml
code-quality:
title: Code Quality
script: |-
export PATH="$PATH:$HOME/.dotnet:$HOME/.dotnet/tools"
dotnet tool install -g dotnet-format
dotnet-format -v quiet --check 2> dotnet-format-report.txt
report:
format: visualstudio
path: dotnet-format-report.txt
32 changes: 16 additions & 16 deletions templates/csharp/src/AddFunction/AddFunction.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;

namespace AddFunction
{
public class Program
{
public static int Add(int a, int b)
{
return 0;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
using System;

namespace AddFunction
{
public class Program
{
public static int Add(int a, int b)
{
return 0;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
16 changes: 8 additions & 8 deletions templates/csharp/src/AddFunction/AddFunction.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

</Project>
3 changes: 0 additions & 3 deletions templates/java/.codeclimate.yml

This file was deleted.

16 changes: 16 additions & 0 deletions templates/java/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id "application"
id "checkstyle"
}

dependencies {
Expand All @@ -22,3 +23,18 @@ test {
exceptionFormat "full"
}
}

checkstyle {
// Explicitly define a tool version as checkstyle is a Gradle core plugin
// which might not support recent configurations.
toolVersion = '8.45.1'
// Make build fail on warnings
ignoreFailures = false
maxWarnings = 0
}

tasks.withType(Checkstyle) {
reports {
xml.required = true
}
}
33 changes: 22 additions & 11 deletions templates/java/codefreak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description: |
### Static Code Analysis
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.
The Code is analyzed for proper formatting using the Tool [`Checkstyle`](https://github.com/checkstyle/checkstyle) and [Google's code style for Java](https://google.github.io/styleguide/javaguide.html).
### Unit Tests
Expand All @@ -29,17 +29,28 @@ description: |
Click on this text to edit it. Here you describe to your students what they have to do.
hidden:
- src/test/**
- .codeclimate.yml
protected:
- build.gradle
- settings.gradle
- gradlew
- gradlew.bat
- gradle/**
- config/**
evaluation:
- step: codeclimate
- step: junit
options:
image: gradle
project-path: /home/gradle/project
stop-on-fail: true
commands:
- gradle testClasses
- gradle test
unit-tests:
title: Unit Tests
script: |-
# This is only to make sure the gradlew is executable
chmod u+x gradlew
./gradlew test
report:
format: junit-xml
path: build/test-results/test/TEST-*.xml
code-quality:
title: Code Quality
script: |-
chmod u+x gradlew
./gradlew checkstyleMain
report:
format: checkstyle-xml
path: build/reports/checkstyle/main.xml
Loading

0 comments on commit 4229f8e

Please sign in to comment.