Skip to content

Commit cbf6389

Browse files
committed
Restructured Repository.
Signed-off-by: AraHaan <seandhunt_7@yahoo.com>
1 parent 28b34ba commit cbf6389

19 files changed

+412
-278
lines changed

.github/workflows/codacy-analysis.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ jobs:
3232
run: dotnet restore
3333
shell: bash
3434

35+
- name: Test
36+
run: dotnet test --configuration Release --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage.codacy.opencover.xml
37+
shell: bash
38+
39+
- name: Run codacy-coverage-reporter
40+
uses: codacy/codacy-coverage-reporter-action@master
41+
with:
42+
api-token: ${{ secrets.CODACY_API_TOKEN }}
43+
coverage-reports: tests/coverage.codacy.opencover.xml
44+
3545
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
3646
- name: Run Codacy Analysis CLI
3747
uses: codacy/codacy-analysis-cli-action@3.0.1
3848
with:
39-
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
40-
# You can also omit the token and run the tools that support default configurations
41-
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
49+
api-token: ${{ secrets.CODACY_API_TOKEN }}
4250
verbose: true
4351
output: results.sarif
4452
format: sarif

.github/workflows/dotnetcore-build.yml

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ jobs:
2727
dotnet build --configuration Release --no-restore
2828
dotnet pack --configuration Release --no-build
2929
shell: bash
30+
31+
- name: Test
32+
run: dotnet test --configuration Release --no-build --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage.codacy.opencover.xml
33+
shell: bash

.github/workflows/dotnetcore-publish.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ jobs:
2929
dotnet pack --configuration Release --no-build
3030
shell: bash
3131

32+
- name: Test
33+
run: dotnet test --configuration Release --no-build --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage.codacy.opencover.xml
34+
shell: bash
35+
3236
- name: Publish Release
3337
id: publish_nuget
3438
uses: rohith/publish-nuget@v2
3539
with:
3640
# Filepath of the project to be packaged, relative to root of repository
37-
PROJECT_FILE_PATH: GitBuildInfo.SourceGenerator.csproj
41+
PROJECT_FILE_PATH: src/GitBuildInfo.SourceGenerator/GitBuildInfo.SourceGenerator.csproj
3842
# Flag to toggle git tagging, enabled by default
3943
TAG_COMMIT: false
4044
# API key to authenticate with NuGet server

.github/workflows/dotnetcore.yml

+4
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ jobs:
2525
dotnet build --configuration Release --no-restore
2626
dotnet pack --configuration Release --no-build
2727
shell: bash
28+
29+
- name: Test
30+
run: dotnet test --configuration Release --no-build --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage.codacy.opencover.xml
31+
shell: bash

GitBuildInfo.SourceGenerator.sln

+23-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.6.30114.105
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitBuildInfo.SourceGenerator", "GitBuildInfo.SourceGenerator.csproj", "{D769E982-58EE-436B-B2A8-C35D4D55BA8D}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitBuildInfo.SourceGenerator", "src/GitBuildInfo.SourceGenerator.csproj", "{D769E982-58EE-436B-B2A8-C35D4D55BA8D}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{99761A41-8AED-49B5-AF0F-CF6CCAE482E8}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{B84AD34C-E5C4-418F-A58A-195C9F89A961}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitBuildInfo.SourceGenerator.Tests", "tests/GitBuildInfo.SourceGenerator.Tests.csproj", "{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}"
713
EndProject
814
Global
915
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -30,5 +36,21 @@ Global
3036
{D769E982-58EE-436B-B2A8-C35D4D55BA8D}.Release|x64.Build.0 = Release|Any CPU
3137
{D769E982-58EE-436B-B2A8-C35D4D55BA8D}.Release|x86.ActiveCfg = Release|Any CPU
3238
{D769E982-58EE-436B-B2A8-C35D4D55BA8D}.Release|x86.Build.0 = Release|Any CPU
39+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Debug|x64.ActiveCfg = Debug|Any CPU
42+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Debug|x64.Build.0 = Debug|Any CPU
43+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Debug|x86.ActiveCfg = Debug|Any CPU
44+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Debug|x86.Build.0 = Debug|Any CPU
45+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Release|x64.ActiveCfg = Release|Any CPU
48+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Release|x64.Build.0 = Release|Any CPU
49+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Release|x86.ActiveCfg = Release|Any CPU
50+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9}.Release|x86.Build.0 = Release|Any CPU
51+
EndGlobalSection
52+
GlobalSection(NestedProjects) = preSolution
53+
{D769E982-58EE-436B-B2A8-C35D4D55BA8D} = {99761A41-8AED-49B5-AF0F-CF6CCAE482E8}
54+
{5A9FCC65-752B-499B-A86B-ABCC6F4666D9} = {B84AD34C-E5C4-418F-A58A-195C9F89A961}
3355
EndGlobalSection
3456
EndGlobal

SourceGenerator.cs

-185
This file was deleted.

build/GitBuildInfo.SourceGenerator.targets

+1-83
Original file line numberDiff line numberDiff line change
@@ -8,89 +8,7 @@
88
<OutputPath Required="true" />
99
</ParameterGroup>
1010
<Task>
11-
<Using Namespace="System" />
12-
<Using Namespace="System.ComponentModel" />
13-
<Using Namespace="System.Diagnostics" />
14-
<Using Namespace="System.IO" />
15-
<Using Namespace="System.Text" />
16-
<Using Namespace="Microsoft.Build.Framework" />
17-
<Using Namespace="Microsoft.Build.Utilities" />
18-
<Code Type="Class" Language="cs">
19-
<![CDATA[
20-
namespace GitBuildInfo
21-
{
22-
using System;
23-
using System.ComponentModel;
24-
using System.Diagnostics;
25-
using System.IO;
26-
using System.Text;
27-
using Microsoft.Build.Framework;
28-
using Microsoft.Build.Utilities;
29-
30-
/// <summary>
31-
/// A MSBuild task that generates the msbuild information for an assembly.
32-
///
33-
/// Note: use in the BeforeBuild target.
34-
/// </summary>
35-
public class GitInfoTask : Task
36-
{
37-
/// <summary>
38-
/// Gets or sets the generated output file path.
39-
/// </summary>
40-
[Required]
41-
public string OutputPath { get; set; }
42-
43-
/// <inheritdoc/>
44-
public override bool Execute()
45-
{
46-
this.RunGit("describe --all --always --dirty", out var git_out1);
47-
this.RunGit("rev-parse --short HEAD", out var git_out2);
48-
this.RunGit("name-rev --name-only HEAD", out var git_out3);
49-
var outputData = $"{{{Environment.NewLine} \"GitHead\": \"{git_out1}\",{Environment.NewLine} \"CommitHash\": \"{git_out2}\",{Environment.NewLine} \"GitBranch\": \"{git_out3}\"{Environment.NewLine}}}";
50-
// patch 112019: only print the getting build info from git message from the initial call to this task.
51-
// all other calls will not print anything to avoid spamming up the build output.
52-
try
53-
{
54-
if (!File.Exists(this.OutputPath) || (File.Exists(this.OutputPath) && !string.Equals(outputData, File.ReadAllText(this.OutputPath), StringComparison.Ordinal)))
55-
{
56-
this.Log.LogMessage(MessageImportance.High, "Getting build info from git");
57-
File.WriteAllText(this.OutputPath, outputData);
58-
}
59-
}
60-
catch (IOException)
61-
{
62-
// catch I/O error from being unable to open the file for checking it's contents.
63-
}
64-
return true;
65-
}
66-
67-
private void RunGit(string arguments, out string git_out)
68-
{
69-
using var pro1 = new Process();
70-
pro1.StartInfo.FileName = "git";
71-
pro1.StartInfo.Arguments = arguments;
72-
pro1.StartInfo.RedirectStandardOutput = true;
73-
pro1.StartInfo.UseShellExecute = false;
74-
pro1.StartInfo.CreateNoWindow = true;
75-
pro1.StartInfo.WorkingDirectory = Path.GetFullPath(this.OutputPath).Replace(Path.GetFileName(this.OutputPath), string.Empty);
76-
try
77-
{
78-
_ = pro1.Start();
79-
git_out = pro1.StandardOutput.ReadToEnd();
80-
pro1.WaitForExit();
81-
// handle all cases of possible endlines.
82-
git_out = git_out.Replace("\r\n", string.Empty);
83-
git_out = git_out.Replace("\n", string.Empty);
84-
git_out = git_out.Replace("\r", string.Empty);
85-
}
86-
catch (Win32Exception)
87-
{
88-
git_out = "Not a git clone or git is not in Path.";
89-
}
90-
}
91-
}
92-
}]]>
93-
</Code>
11+
<Code Source="GitInfoTask.cs" />
9412
</Task>
9513
</UsingTask>
9614

0 commit comments

Comments
 (0)