コード例 #1
0
        public void ListArtifactNames()
        {
            GithubActionsClient client = new GithubActionsClient(DataConstants.RepoOwnerUserName, DataConstants.RepoName);
            int number = 1;

            client.ListArtifactInfos().Each(artifact =>
            {
                Message.PrintLine($"{number++}. {artifact.Name}");
            });
        }
コード例 #2
0
        public void ConfigKeyShouldBeSet()
        {
            GithubActionsClient          client = new GithubActionsClient();
            IAuthorizationHeaderProvider authorizationHeaderProvider = client.AuthorizationHeaderProvider;
            string configKey = authorizationHeaderProvider.ConfigKey;

            configKey.ShouldNotBeNull();
            configKey.ShouldNotBeBlank();
            Pass(nameof(ConfigKeyShouldBeSet));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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);
                        }
                    }
                }
            });