This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from larzw/develop
Basic support for uploading a coverage report via Git and AppVeyor.
- Loading branch information
Showing
21 changed files
with
135 additions
and
273 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Net; | ||
using codecov.Program; | ||
using codecov.Services.Utils; | ||
|
||
namespace codecov.Coverage | ||
{ | ||
public static class Uploder | ||
{ | ||
public static void Upload(Options options, string report, IService service) | ||
{ | ||
var url = $"https://codecov.io/upload/v4?{service.CreateQuery(options)}"; | ||
|
||
//Post: Ping | ||
var post = new WebClient(); | ||
post.Headers.Add("Content-Type: text/plain"); | ||
var response = post.UploadString(url, "POST", string.Empty); | ||
Console.WriteLine(response); | ||
|
||
// Put: Upload report. | ||
url = response.Trim().Split('\n')[1]; | ||
var put = new WebClient(); | ||
put.Headers.Add("Content-Type: text/plain"); | ||
put.Headers.Add("x-amz-acl: public-read"); | ||
put.Headers.Add("x-amz-storage-class: REDUCED_REDUNDANCY"); | ||
put.UploadString(url, "PUT", report); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using CommandLine; | ||
|
||
namespace codecov.Program | ||
{ | ||
public class Options | ||
{ | ||
[Option('d', "dump", HelpText = "Don't upload and dump to stdin.")] | ||
public string Dump { get; set; } | ||
|
||
[OptionArray('f', "file", Required = true, HelpText = "Target file(s) to upload.")] | ||
public string[] File { get; set; } | ||
|
||
[Option('t', "token", HelpText = "Set the private repository token.")] | ||
public string Token { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using codecov.Coverage; | ||
using codecov.Services.Utils; | ||
|
||
namespace codecov.Program | ||
{ | ||
internal static class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
var options = new Options(); | ||
CommandLine.Parser.Default.ParseArgumentsStrict(args, options); | ||
|
||
var service = ServiceFactory.CreateService; | ||
var report = Report.CreateReport(options.File); | ||
Uploder.Upload(options, report, service); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
namespace codecov.Services.Utils | ||
using codecov.Program; | ||
|
||
namespace codecov.Services.Utils | ||
{ | ||
public interface IService | ||
{ | ||
IUrl Find { get; } | ||
bool Detect { get; } | ||
|
||
string CreateQuery(Options options); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using codecov.Program; | ||
|
||
namespace codecov.Services.Utils | ||
{ | ||
public class Query | ||
{ | ||
protected IDictionary<string, string> QueryParameters { get; } = | ||
new Dictionary<string, string> | ||
{ | ||
{"branch", string.Empty}, | ||
{"commit", string.Empty}, | ||
{"build", string.Empty}, | ||
{"build_url", string.Empty}, | ||
{"tag", string.Empty}, | ||
{"slug", string.Empty}, | ||
{"yaml", string.Empty}, | ||
{"service", string.Empty}, | ||
{"flags", string.Empty}, | ||
{"pr", string.Empty}, | ||
{"job", string.Empty} | ||
}; | ||
|
||
public string CreateQuery(Options options) | ||
{ | ||
var query = string.Join("&", QueryParameters.Select(x => $"{x.Key}={x.Value ?? string.Empty}")); | ||
return $"package=exe-beta&token={options.Token}&{query}"; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace codecov.Services.Utils | ||
{ | ||
public static class ServiceFactory | ||
{ | ||
private static readonly IEnumerable<IService> Services = new IService[] { new AppVeyor(), new Git() }; | ||
|
||
public static IService CreateService => Services.FirstOrDefault(x => x.Detect); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.