Merge pull request 'Structure - Build job pour MAUI, Sonar et exemple de code' (#15) from structure into dev
continuous-integration/drone/push Build is passing Details

Reviewed-on: #15
pull/29/head
Alexandre AGOSTINHO 2 years ago
commit 60f5a3484a

@ -7,44 +7,56 @@ trigger:
- push - push
steps: steps:
# - name: build
# image: mcr.microsoft.com/dotnet/sdk:7.0
# volumes:
# - name: docs
# path: /docs
# commands:
# - cd MCTG/
# - dotnet restore CI-CD.sln
# - dotnet build CI-CD.sln -c Release --no-restore
# - dotnet publish CI-CD.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
- name: build - name: build
image: mcr.microsoft.com/dotnet/sdk:7.0 image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest
volumes:
- name: docs
path: /docs
commands: commands:
- cd MCTG/ - cd MCTG/
- dotnet restore CI-CD.sln - dotnet restore SAE-2.01.sln
- dotnet build CI-CD.sln -c Release --no-restore - dotnet build SAE-2.01.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0
- dotnet publish CI-CD.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - dotnet publish MCTGApp/MCTGApp.csproj -c Release --no-restore -o CI_PROJECT_DIR/build/release
- dotnet publish Views/Views.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk
- name: tests - name: tests
image: mcr.microsoft.com/dotnet/sdk:7.0 image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest
commands: commands:
- cd MCTG/ - cd MCTG/
- dotnet restore CI-CD.sln - dotnet restore SAE-2.01.sln
- dotnet test CI-CD.sln --no-restore - dotnet test SAE-2.01.sln --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0
depends_on: [build] depends_on: [ build ]
# - name: code-analysis - name: code-analysis
# image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7
# commands: commands:
# - cd MCTG/ - cd MCTG/
# - dotnet restore CI-CD.sln - cp SAE-2.01.sln CI.sln
# - dotnet sonarscanner begin /k:gitrepotest /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - sed -i '30,35d' CI.sln
# - dotnet build CI-CD.sln -c Release --no-restore - sed -i '10,11d' CI.sln
# - dotnet test CI-CD.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - dotnet restore CI.sln
# - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - dotnet sonarscanner begin /k:SAE-2.01 /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
# - dotnet publish CI-CD.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - dotnet build CI.sln -c Release --no-restore
# - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - dotnet test CI.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage"
# secrets: [ SECRET_SONAR_LOGIN ] - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
# settings: - dotnet publish CI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
# # accessible en ligne de commande par ${PLUGIN_SONAR_HOST} - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
# sonar_host: https://codefirst.iut.uca.fr/sonar/ secrets: [ SECRET_SONAR_LOGIN ]
# # accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN} settings:
# sonar_token: # accessible en ligne de commande par ${PLUGIN_SONAR_HOST}
# from_secret: SECRET_SONAR_LOGIN sonar_host: https://codefirst.iut.uca.fr/sonar/
# depends_on: [ tests ] # accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN}
sonar_token:
from_secret: SECRET_SONAR_LOGIN
depends_on: [ tests ]
- name: generate-and-deploy-docs - name: generate-and-deploy-docs
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer

@ -1,42 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MCTGApp", "MCTGApp\MCTGApp.csproj", "{666C2211-8EBB-4FC8-9484-CB93BC854153}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MCTGLib", "MCTGLib\MCTGLib.csproj", "{42FF86BD-92F9-4A32-A938-68515905378F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MCTGLib_UnitTests", "Tests\MCTGLib_UnitTests\MCTGLib_UnitTests.csproj", "{45AB746A-194B-4E43-81EB-83B06F35AA33}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{08B80CE8-A01D-4D86-8989-AF225D5DA48C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Debug|Any CPU.Build.0 = Debug|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.ActiveCfg = Release|Any CPU
{666C2211-8EBB-4FC8-9484-CB93BC854153}.Release|Any CPU.Build.0 = Release|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42FF86BD-92F9-4A32-A938-68515905378F}.Release|Any CPU.Build.0 = Release|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45AB746A-194B-4E43-81EB-83B06F35AA33}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{45AB746A-194B-4E43-81EB-83B06F35AA33} = {08B80CE8-A01D-4D86-8989-AF225D5DA48C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ADEA5603-1EF6-4D43-9493-7D6D9DE7FA3F}
EndGlobalSection
EndGlobal

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
@ -7,4 +7,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MCTGLib\MCTGLib.csproj" />
</ItemGroup>
</Project> </Project>

@ -1,2 +1,32 @@
// See https://aka.ms/new-console-template for more information using System;
Console.WriteLine("Hello, World!"); using Model;
namespace Program;
public static class Program
{
public static void Main()
{
Console.WriteLine("Helle World!");
Recipe recipe = new Recipe(
1,
"Cookies aux pépites de chocolat",
new List<string>(new string[]{
"2 pommes",
"3L de vin",
"500g de farine"
}),
"Etape 1:\n"
+ "\tCouper les pommes\n"
+ "Etape 2:\n"
+ "\tLes disposer sur le plat et mettre le vin dessus\n"
+ "Etape 3:\n"
+ "\tMettez toute la farine ensuite, puis 4h32 au four.\n"
+ "\nDégustez c'est prêt !"
);
recipe.Display();
}
}

@ -1,7 +0,0 @@
namespace MCTGLib
{
public class Class1
{
}
}

@ -0,0 +1,60 @@
using System.Text;
namespace Model
{
public class Recipe
{
public uint Id { get; set; }
public string Title { get; set; }
public List<string> Ingredients { get; set; }
public string Preparation { get; set; }
/// <summary>
/// Constructor of a Recipe.
/// </summary>
/// <param name="id">Identificator</param>
/// <param name="title">The name of the recipe</param>
/// <param name="ingredients">A list of ingredient needed by the preparation</param>
/// <param name="preparation">The text that explain the preparation of the recipe</param>
public Recipe(uint id, string title, List<string> ingredients, string preparation)
{
Id = id;
Title = title;
Ingredients = ingredients;
Preparation = preparation;
}
/// <summary>
/// Concatenate the list of ingredients in a single string
/// </summary>
/// <returns>The list of ingredients in string format</returns>
private string ConcatIngredients()
{
StringBuilder sb = new StringBuilder();
foreach (string str in Ingredients) sb.Append("\t- " + str + "\n");
return sb.ToString();
}
/// <summary>
/// Build a string with all elements (title, ingredients, preparation, ...)
/// </summary>
/// <returns>A string that represent the recipe</returns>
public override string ToString()
{
return $"{Title} -- id:{Id}\n\n"
+ "List of ingredient:\n"
+ ConcatIngredients() + "\n\n"
+ "Preparation:\n"
+ $"{Preparation}\n";
}
/// <summary>
/// Display the recipe in the console
/// </summary>
public void Display()
{
Console.WriteLine(this.ToString());
}
}
}

@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks> <TargetFrameworks>net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks> <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('ios'))">$(TargetFrameworks);net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('maccatalyst'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --> <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> --> <!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>

@ -1,3 +1,11 @@
[![Build Status](https://codefirst.iut.uca.fr/api/badges/alexandre.agostinho/SAE-2.01/status.svg)](https://codefirst.iut.uca.fr/alexandre.agostinho/SAE-2.01) [![Build Status](https://codefirst.iut.uca.fr/api/badges/alexandre.agostinho/SAE-2.01/status.svg)](https://codefirst.iut.uca.fr/alexandre.agostinho/SAE-2.01)
[![Quality Gate Status](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=gitrepotest&metric=alert_status&token=e2b9d99abef97a250de044cc5e4b9f1d6817b67d)](https://codefirst.iut.uca.fr/sonar/dashboard?id=gitrepotest)
# SAE 2.01 - Développement d'une application [![Code Smells](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=gitrepotest&metric=code_smells&token=e2b9d99abef97a250de044cc5e4b9f1d6817b67d)](https://codefirst.iut.uca.fr/sonar/dashboard?id=gitrepotest)
[![Coverage](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=gitrepotest&metric=coverage&token=e2b9d99abef97a250de044cc5e4b9f1d6817b67d)](https://codefirst.iut.uca.fr/sonar/dashboard?id=gitrepotest)
[![Maintainability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=gitrepotest&metric=sqale_rating&token=e2b9d99abef97a250de044cc5e4b9f1d6817b67d)](https://codefirst.iut.uca.fr/sonar/dashboard?id=gitrepotest)
[![Reliability Rating](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=gitrepotest&metric=reliability_rating&token=e2b9d99abef97a250de044cc5e4b9f1d6817b67d)](https://codefirst.iut.uca.fr/sonar/dashboard?id=gitrepotest)
[![Vulnerabilities](https://codefirst.iut.uca.fr/sonar/api/project_badges/measure?project=gitrepotest&metric=vulnerabilities&token=e2b9d99abef97a250de044cc5e4b9f1d6817b67d)](https://codefirst.iut.uca.fr/sonar/dashboard?id=gitrepotest)
# SAE 2.01 - Développement d'une application

Loading…
Cancel
Save