-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathCIBuildOnlyReporter.cpp
65 lines (62 loc) · 2.42 KB
/
CIBuildOnlyReporter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "ApprovalTests/reporters/CIBuildOnlyReporter.h"
#include "ApprovalTests/utilities/SystemUtils.h"
namespace ApprovalTests
{
CIBuildOnlyReporter::CIBuildOnlyReporter(std::shared_ptr<Reporter> reporter)
: m_reporter(reporter)
{
}
bool CIBuildOnlyReporter::report(std::string received, std::string approved) const
{
if (!isRunningUnderCI())
{
return false;
}
m_reporter->report(received, approved);
// Return true regardless of whether our report succeeded or not,
// so that no later reporters run.
return true;
}
bool CIBuildOnlyReporter::isRunningUnderCI()
{
/*
auto AppVeyor = {"CI", "APPVEYOR"}; // https://www.appveyor.com/docs/environment-variables/
auto AzurePipelines = {"TF_BUILD"}; // https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&viewFallbackFrom=vsts&tabs=yaml
auto GitHubActions = {"GITHUB_ACTIONS"}; // https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
auto GoCD = {"GO_SERVER_URL"}: // https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html
auto Jenkins = {"JENKINS_URL"}: // https://wiki.jenkins.io/display/JENKINS/Building+a+software+project
auto TeamCity = {"TEAMCITY_VERSION"}; // https://confluence.jetbrains.com/display/TCD18/Predefined+Build+Parameters
auto Travis = {"CI", "TRAVIS", "CONTINUOUS_INTEGRATION"}; // https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
auto environmentVariablesForCI = combine({
// begin-snippet: supported_ci_systems
AppVeyor,
AzurePipelines,
GitHubActions,
GoCD
Jenkins,
TeamCity,
Travis,
// end-snippet
});
*/
auto environmentVariablesForCI = {
// begin-snippet: supported_ci_env_vars
"CI",
"CONTINUOUS_INTEGRATION",
"GITHUB_ACTIONS",
"GO_SERVER_URL",
"JENKINS_URL",
"TEAMCITY_VERSION",
"TF_BUILD"
// end-snippet
};
for (const auto& variable : environmentVariablesForCI)
{
if (!SystemUtils::safeGetEnv(variable).empty())
{
return true;
}
}
return false;
}
}