Exemple #1
0
        public async Task UpdateRepository(GithubRepository repo)
        {
            if (repo.Branches.Count == 0)
            {
                await UpdateRepositoryBranches(repo);
            }

            foreach (var branch in repo.Branches)
            {
                var info = await github.Repository.GetBranch(repo.Owner,
                                                             repo.Name, branch.Name);

                if (branch.GetCommitByReference(info.Commit.Sha) != null)
                {
                    continue;
                }

                var commit = GetCommitFromGithubCommit(info.Commit);
                commit.Branch = new WeakReference <Branch>(branch);

                branch.AddCommit(commit);

                if (RepositoryChanged != null)
                {
                    RepositoryChanged(repo, new List <Commit> {
                        commit
                    });
                }
            }
        }
Exemple #2
0
        public async Task UpdateRepositoryBranches(GithubRepository repo)
        {
            Log.Debug("Getting {0} repository branches...", repo.Name);
            var branches = await github.Repository.GetAllBranches(repo.Owner,
                repo.Name);

            foreach (var branch in branches)
            {
                var repoBranch = new Branch
                {
                    Name = branch.Name,
                    Repository = new WeakReference<Repository>(repo)
                };

                repo.Branches.Add(repoBranch);
            }
        }
Exemple #3
0
        public async Task UpdateRepositoryBranches(GithubRepository repo)
        {
            Log.Debug("Getting {0} repository branches...", repo.Name);
            var branches = await github.Repository.GetAllBranches(repo.Owner,
                                                                  repo.Name);

            foreach (var branch in branches)
            {
                var repoBranch = new Branch
                {
                    Name       = branch.Name,
                    Repository = new WeakReference <Repository>(repo)
                };

                repo.Branches.Add(repoBranch);
            }
        }
Exemple #4
0
        public async Task UpdateRepository(GithubRepository repo)
        {
            if (repo.Branches.Count == 0)
                await UpdateRepositoryBranches(repo);

            foreach (var branch in repo.Branches)
            {
                var info = await github.Repository.GetBranch(repo.Owner,
                    repo.Name, branch.Name);

                if (branch.GetCommitByReference(info.Commit.Sha) != null)
                    continue;

                var commit = GetCommitFromGithubCommit(info.Commit);
                commit.Branch = new WeakReference<Branch>(branch);

                branch.AddCommit(commit);

                if (RepositoryChanged != null)
                    RepositoryChanged(repo, new List<Commit> {commit});
            }
        }
Exemple #5
0
        void OnRepositoryChange(GithubRepository repository, List<Commit> commits)
        {
            foreach (var commit in commits)
            {
                if (commit.BuildSet != null)
                    continue;

                // Spawn a set of builds for this commit.
                var buildSet = new BuildSet { Commit = commit };

                commit.BuildSet = buildSet;

                Branch branch;
                commit.Branch.TryGetTarget(out branch);

                Repository repo;
                branch.Repository.TryGetTarget(out repo);

                var buildConfiguration = repo.Project.DefaultBuildConfiguration;
                buildConfiguration.Directory = Options.OutputDir;

                Log.Message("Spawning new build for {0}/{1}", repo.Project.Name,
                    commit.ToString());

                var build = new Build(repo.Project, commit, buildConfiguration);
                buildSet.Builds.Add(build);

                Database.AddBuild(build);

                BuildQueue.AddBuild(build);
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            var project = new Project { Name = "CppSharp" };
            var repo = new GithubRepository(project)
            {
                Owner = "mono",
                Name = "CppSharp",
                URL = @"https://github.com/mono/CppSharp.git",
                MinRevision = new Commit("cd3e729d3873a845eacee4260480e4c3dfe14579")
            };
            project.Repositories.Add(repo);

            var config = new BuildConfiguration();
            project.Configurations.Add(config);

            var options = new Options
            {
                OutputDir = @"C:\builds\",
                Username = "******",
                Token = "a32086c82fb50fc7acc4b33a5d183e23d4efa997"
            };

            Task.Run((() => LaunchBuildAgent(options)));

            using (var server = new BuildServer(options))
            {
                ConsoleUtils.SetupExitHandler(sig =>
                {
                    server.IsExiting = true;
                    return true;
                });

                server.Projects.Add(project);
                server.RunServer();
            }
        }