public void ListArtifactNames() { GithubActionsClient client = new GithubActionsClient(DataConstants.RepoOwnerUserName, DataConstants.RepoName); int number = 1; client.ListArtifactInfos().Each(artifact => { Message.PrintLine($"{number++}. {artifact.Name}"); }); }
public void CanGetArtifact() { GithubActionsClient client = new GithubActionsClient(DataConstants.RepoOwnerUserName, DataConstants.RepoName); GithubArtifactInfo[] artifacts = client.ListArtifactInfos(DataConstants.RepoOwnerUserName, DataConstants.RepoName).ToArray(); uint artifactId = artifacts[0].Id; GithubArtifactInfo artifactInfo = client.GetArtifactInfo(artifactId); artifactInfo.ShouldNotBeNull(); Message.PrintLine(artifactInfo.ToJson(true)); }
public void CanGetArtifacts() { GithubActionsClient client = new GithubActionsClient(); GithubArtifactInfo[] artifacts = client.ListArtifactInfos(DataConstants.RepoOwnerUserName, DataConstants.RepoName).ToArray(); artifacts.ShouldNotBeNull("artifacts was null"); artifacts.Length.ShouldBeGreaterThan(0, "No artifacts were returned"); artifacts.Each(artifact => { Message.PrintLine(artifact.ToJson(true), ConsoleColor.Cyan); }); Pass(nameof(CanGetArtifacts)); }
public void CanDownloadArtifact() { GithubActionsClient client = new GithubActionsClient(); GithubArtifactInfo[] artifacts = client.ListArtifactInfos(DataConstants.RepoOwnerUserName, DataConstants.RepoName).ToArray(); artifacts.Length.ShouldBeGreaterThan(0, "No artifacts were returned"); GithubArtifactInfo artifactInfo = artifacts.First(); string fileName = $"./{nameof(CanDownloadArtifact)}.zip"; FileInfo fileInfo = artifactInfo.DownloadTo(fileName); fileInfo.Exists.ShouldBeTrue("file doesn't exist after attempted download"); Message.PrintLine("Artifact Size Unzipped: {0}, File Size Zipped: {1}", artifactInfo.SizeInBytes, fileInfo.Length); fileInfo.Delete(); Pass(nameof(CanDownloadArtifact)); }
public void DeleteArtifactsNamedWrong() { GithubActionsClient client = new GithubActionsClient(DataConstants.RepoOwnerUserName, DataConstants.RepoName); int number = 1; client.ListArtifactInfos().Each(artifact => { string name = artifact.Name; string[] nameSegments = name.Split('-'); if (nameSegments[^ 1].Length != 7) { Message.PrintLine($"{number++}. {artifact.Name} {artifact.Id}"); if (Confirm("Delete?")) { if (client.DeleteArtifact(artifact.Id)) { Message.PrintLine("Deleted artifact {0}", ConsoleColor.Yellow, artifact.Name); } } } });