project-anacapa / course-github-org-tool

PLEASE USE: https://github.com/project-anacapa/github-roster-tool instead!
https://github.com/project-anacapa/github-roster-tool
MIT License
1 stars 4 forks source link

Visibility into Jenkins-readiness of instructor assignment repos #35

Open ncbrown1 opened 7 years ago

ncbrown1 commented 7 years ago

In the assignments index page for instructors, we would like to be able to know the "build status" of each assignment. This allows instructors to know whether they have properly set up their assignment repos for auto-grading.

We would like to be able to see an icon to the right of each assignment list item in the index page of the assignments view:

https://github.com/project-anacapa/course-github-org-tool/blob/feature/assignment-view/app/views/assignments/_index_instructor.html.erb#L5

The icons for each status are as follows:

PENDING == yellow hourglass SUCCESS == green checkmark FAILURE == red X ERROR == red ?

ncbrown1 commented 7 years ago

You may want to add methods to the Git Strategy for accessing & updating the commit/build status for a given repository. You can add those to the files in this folder:

https://github.com/project-anacapa/course-github-org-tool/tree/feature/assignment-view/lib/strategies

ncbrown1 commented 7 years ago

Commit Status API for GitHub: https://developer.github.com/v3/repos/statuses/

Build Status API for GitLab: https://docs.gitlab.com/ce/api/commits.html#post-the-build-status-to-a-commit

ncbrown1 commented 7 years ago

Operations needed given a Repo object:

Set Commit Status Get Commit Status

For example, to set the status in the rails console, we might type the following:

machine_octokit.set_commit_status('ucsb-cs-test-org-1/assignment-lab00', {
   :state => :pending,
   :target_url => 'https://localhost:8000/',
   :description => 'Test'
})

status = machine_octokit.get_commit_status('ucsb-cs-test-org-1/assignment-lab00')

Note: the Octokit method you might need is this: https://octokit.github.io/octokit.rb/Octokit/Client/Statuses.html#create_status-instance_method

pconrad commented 7 years ago

You probably want to add this method to the base class git_strategy.rb:

create_status(repo, sha, state)

You'll pass through an empty hash to the underlying octokit method documented o this page

http://octokit.github.io/octokit.rb/Octokit/Client/Statuses.html#create_status-instance_method

create_status(repo, sha, state, options = {})

For gitlab, we can just leave it alone for now, since we aren't using it yet. The "not implemented yet" error will get thrown and that's ok for now.

That method comes directly from

pconrad commented 7 years ago

We also need a get_most_recent_status(repo, sha) which wraps the

(Array<Sawyer::Resource>) statuses(repo, sha, options = {})

method but only returns the most recent status.