Beispiel #1
0
        public RepositoryCreateResponse Create([FromBody] RepositoryCreateRequest request)
        {
            RepositoryCreateResponse response = new RepositoryCreateResponse();

            repositoryRepository.Create(repositoryConvertor.toEntity(request));

            response.Status = 1;
            return(response);
        }
Beispiel #2
0
        public RepositoryEntity toEntity(RepositoryCreateRequest request)
        {
            RepositoryEntity entity = new RepositoryEntity();

            entity.RepositoryName        = request.RepositoryName;
            entity.RepositoryTypeId      = request.RepositoryTypeId != null ? request.RepositoryTypeId.Value : 0;
            entity.GitlabProjectFullname = request.GitlabProjectFullname;
            entity.DataStatus            = request.DataStatus != null ? request.DataStatus.Value : 0;
            entity.Description           = request.Description;

            return(entity);
        }
Beispiel #3
0
 /// <inheritdoc />
 public Task <RepositoryResponse> Clone(RepositoryCreateRequest repository, CancellationToken cancellationToken) => apiClient.Create <RepositoryCreateRequest, RepositoryResponse>(Routes.Repository, repository, instance.Id !.Value, cancellationToken);
Beispiel #4
0
        public async Task RunPreWatchdog(CancellationToken cancellationToken)
        {
            const string TestRefEnvVar = "TGS4_GITHUB_REF";
            var          envVar        = Environment.GetEnvironmentVariable(TestRefEnvVar);
            string       workingBranch = null;

            if (!String.IsNullOrWhiteSpace(envVar))
            {
                workingBranch = envVar;
                Console.WriteLine($"TEST: Set working branch to '{workingBranch}' from env var '{TestRefEnvVar}'");
            }

            if (workingBranch == null)
            {
                workingBranch = "master";
                Console.WriteLine($"TEST: Set working branch to default '{workingBranch}'");
            }

            var initalRepo = await repositoryClient.Read(cancellationToken);

            Assert.IsNotNull(initalRepo);
            Assert.IsNull(initalRepo.Origin);
            Assert.IsNull(initalRepo.Reference);
            Assert.IsNull(initalRepo.RevisionInformation);
            Assert.IsNull(initalRepo.ActiveJob);

            const string Origin       = "https://github.com/tgstation/tgstation-server";
            var          cloneRequest = new RepositoryCreateRequest
            {
                Origin    = new Uri(Origin),
                Reference = workingBranch,
            };

            var clone = await repositoryClient.Clone(cloneRequest, cancellationToken).ConfigureAwait(false);

            await ApiAssert.ThrowsException <ConflictException>(() => repositoryClient.Read(cancellationToken), ErrorCode.RepoCloning);

            Assert.IsNotNull(clone);
            Assert.AreEqual(cloneRequest.Origin, clone.Origin);
            Assert.AreEqual(workingBranch, clone.Reference);
            Assert.IsNull(clone.RevisionInformation);
            Assert.IsNotNull(clone.ActiveJob);

            await WaitForJobProgressThenCancel(clone.ActiveJob, 20, cancellationToken).ConfigureAwait(false);

            var secondRead = await repositoryClient.Read(cancellationToken).ConfigureAwait(false);

            Assert.IsNotNull(secondRead);
            Assert.IsNull(secondRead.ActiveJob);

            clone = await repositoryClient.Clone(cloneRequest, cancellationToken).ConfigureAwait(false);

            await WaitForJob(clone.ActiveJob, 9000, false, null, cancellationToken).ConfigureAwait(false);

            var readAfterClone = await repositoryClient.Read(cancellationToken);

            Assert.AreEqual(cloneRequest.Origin, readAfterClone.Origin);
            Assert.AreEqual(workingBranch, readAfterClone.Reference);
            Assert.IsNotNull(readAfterClone.RevisionInformation);
            Assert.IsNotNull(readAfterClone.RevisionInformation.ActiveTestMerges);
            Assert.AreEqual(0, readAfterClone.RevisionInformation.ActiveTestMerges.Count);
            Assert.IsNotNull(readAfterClone.RevisionInformation.CommitSha);
            Assert.IsNotNull(readAfterClone.RevisionInformation.OriginCommitSha);
            Assert.IsNotNull(readAfterClone.RevisionInformation.CompileJobs);
            Assert.AreEqual(0, readAfterClone.RevisionInformation.CompileJobs.Count);
            Assert.IsNotNull(readAfterClone.RevisionInformation.OriginCommitSha);
            Assert.IsNull(readAfterClone.RevisionInformation.PrimaryTestMerge);
            Assert.AreEqual(readAfterClone.RevisionInformation.CommitSha, readAfterClone.RevisionInformation.OriginCommitSha);
            Assert.AreNotEqual(default, readAfterClone.RevisionInformation.Timestamp);