Skip to content

Commit 1de2f10

Browse files
committed
(test) Added basic test script
This is just to quickly prove out that things are still working. This requires an environment variable to be configured to communicate with AppVeyor. To start with, all it does is list the projects and environments, and attempts to clear the cache of a project.
1 parent b098c1b commit 1de2f10

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

test.cake

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#reference "BuildArtifacts/temp/_PublishedLibraries/Cake.AppVeyor/net6.0/Cake.AppVeyor.dll"
2+
#addin nuget:?package=Refit&version=4.6.58
3+
#addin nuget:?package=Newtonsoft.Json&version=11.0.2
4+
5+
public class BuildData
6+
{
7+
public string AppVeyorApiToken { get; set; }
8+
public string AccountName { get; set; }
9+
public string ProjectSlug { get; set; }
10+
11+
public BuildData()
12+
{
13+
AccountName = "GaryEwanPark";
14+
ProjectSlug = "resharperreports";
15+
}
16+
}
17+
18+
Setup<BuildData>(setupContext => {
19+
return new BuildData()
20+
{
21+
AppVeyorApiToken = EnvironmentVariable<string>("APPVEYOR_API_TOKEN", "")
22+
};
23+
});
24+
25+
Task("Default")
26+
.IsDependentOn("Get-Projects")
27+
.IsDependentOn("Get-Environments")
28+
.IsDependentOn("Clear-Cache");
29+
30+
Task("Get-Projects")
31+
.Does<BuildData>((data) =>
32+
{
33+
if (string.IsNullOrEmpty(data.AppVeyorApiToken))
34+
{
35+
Error("Unable to find AppVeyor API Token");
36+
return;
37+
}
38+
39+
Information("Found the following projects:");
40+
41+
foreach(var project in AppVeyorProjects(data.AppVeyorApiToken))
42+
{
43+
Information("Name: {0}, Repository: {1}, Slug: {2}", project.Name, project.RepositoryName, project.Slug);
44+
}
45+
});
46+
47+
Task("Get-Environments")
48+
.Does<BuildData>((data) =>
49+
{
50+
if (string.IsNullOrEmpty(data.AppVeyorApiToken))
51+
{
52+
Error("Unable to find AppVeyor API Token");
53+
return;
54+
}
55+
56+
Information("Found the following environments:");
57+
58+
foreach(var environment in AppVeyorEnvironments(data.AppVeyorApiToken))
59+
{
60+
Information("Name: {0}, Provider: {1}", environment.Name, environment.Provider);
61+
}
62+
});
63+
64+
Task("Clear-Cache")
65+
.Does<BuildData>((data) =>
66+
{
67+
if (string.IsNullOrEmpty(data.AppVeyorApiToken))
68+
{
69+
Error("Unable to find AppVeyor API Token");
70+
return;
71+
}
72+
73+
Information("Clearing Project Cache...");
74+
75+
AppVeyorClearCache(data.AppVeyorApiToken, data.AccountName, data.ProjectSlug);
76+
});
77+
78+
RunTarget("Default");

0 commit comments

Comments
 (0)