release code to existing repositories
My use case:
- I manage an organization for a class
- I want to give students (who have an existing assignment repository) new code to that repository
This is useful for longer, semester-long projects that are released in bits and pieces.
Currently, I use github-backup (the Python version) to clone all the repositories, then use another Python script I wrote to insert new files into each repository, commit the new changes (if any; I made it idempotent), and push the repository.
This is not ideal because it doesn't deal with edge cases (e.g. what if students already have a file at a given path?), but this feature would be very useful to automate, especially with a better mechanism.
A possible way would be to have similar behavior like normal GitHub forks (e.g. with upstream, iirc). Students would have to learn about multiple remotes, but I don't think that would be too much for beginner git users.
Hi Sam, @samwhitlock
I believe this is a pretty complex feature to implement.
Maybe you can try this approach:
-
Create a repo
assignmentand a reporesources. -
resourceswill be the repo where you put new code & instructions. -
Set the repo
resourcesas a submodule ofassignment. For example:git submodule add https://github.com/samwhitlock/resources.git -
Use the repo
assignmentas your starter code repo when creating new assignments.
Thus, each assignment repo contains a submodule repo resources. When you want to release new code & instructions, just put those into the repo resources, and students can simply pull the submodule to see the latest version.
I want to give students (who have an existing assignment repository) new code to that repository
I think this is a common enough workflow that we should investigate supporting it. I'd be interested to know if anyone is distributing code updates using different mechanisms. If you know all the steps up front, you could create the commits on branches and push each branch step by step.
Set the repo resources as a submodule of assignment
Submodules are hard to use, I generally avoid them and definitely would not recommend them to people just learning git.
I'd like this feature too. Currently I'm going with the approach of having the "future" code on other branches, but it would be nice to completely hide these branches until the students are "ready" for the new code (because it may be distracting/intimidating to have that code right off the bat).
I'm thinking along the lines of what you mentioned in https://github.com/education/classroom/issues/260#issuecomment-148315797:
I could imagine a case where there's one repository and each assignment pushes an additional branch to the student's repo.
Basically, there would be a way to declare branches to be withheld from the initial clones of the starter code repo. (For me, those would be all branches other than master, but that could be too limiting for others that may have great reasons to distribute multiple branches from the beginning.) And then a future assignment could optionally specify a branch from the starter code repo to push to all the student repos.
Any ideas about how this could be implemented? Since the student repos aren't forks of the starter code project, here's how I'd do it manually:
- Push starter code repo without the "future" branches
- Have students start working from this
- Push the first "future" branch to the starter code repo
- Have students manually add a new remote pointing to the starter code repo so they could checkout the new branch.
I have not actually tried that, but I'm just thinking out loud and it seems like it'd work. So how I could see this working in the web UI is:
When creating the first assignment:
- After specifying a starter code repo, you'd also be able to specify any branches to withhold.
- When student repos are generated, they would not have these branches.
Those steps are nice, but they wouldn't be necessary for an "MVP" of the feature. As the teacher, I could still do steps 1-3 from the above manual flow. The part that's really beneficial is automating step 4 of that flow -- that's the step that currently needs every student to do something (the same thing), so the savings are significant. Just dealing with that, here's how I'd see it working in the web UI:
When creating subsequent assignments:
- In addition to "Add your starter code from GitHub: _______", there would be an option like "This assignment builds on the previous assignment: _______".
- You'd select a previous assignment from a dropdown, and then you could specify one or more branches from the starter code repo associated with that previous assignment.
- After you click "Create Assignment", the specified branch(es) would automatically appear in all the student repos associated with the previous assignment (without students having to deal with adding a new remote).
I fear that accomplishing (3) in an automated fashion is not easy. From the looks of it, distributing the initial starter code heavily leverages start_source_import from Octokit::Client::SourceImport. I don't think they've built anything there we can leverage to migrate a single branch from one repo to another ('cause that's not what SourceImport is designed for). One way I could see this working is (after you click "Create Assignment"), the backend would:
- Clone the starter code repo.
- Iterate through all the associated student repos and add each one as a remote.
- Push the specified branch(es) to all remotes.
Again, I'm just thinking out loud here, but it seems like that would work. The crappy part is that this involves actually cloning a repo instead of just doing everything magically via GitHub APIs. I'm interested in hearing your thoughts. Maybe you can think of a simpler/more elegant way to accomplish this? (If it's not already clear, I'm interested in this idea enough that I would take a stab at it - just want to have some more discussion before I attempt any specific approach.)
Thanks for all the great ideas, please keep them coming. I do want us to support this use case, but I want to make it as simple as possible. The more ideas for solutions we can get at this stage the better.
After you click "Create Assignment", the specified branch(es) would automatically appear in all the student repos associated with the previous assignment (without students having to deal with adding a new remote).
@rmacklin I assume that the 2nd assignment won't only build up on top of the 1st assignment's starter code, but also on top of the student's "solution" for it. Is the intention to have the students merge the 2nd assignment's branch into master? If so, automatically creating a friendly pull request for the 2nd assignment's resources in each student repo could helpful.
The pull request could have a short summary of the assignment, and (as any PR) it can only be merged if there are no conflicts (maybe add a link for help on conflict solving if a conflict is detected). The pull requests' status could also be tracked for metrics purposes, knowing when students have advanced to the following assignment, etc.
It could be made so that the pull request is only sent once the student has explicitly marked the previous assignment as complete. And an assignment can only be completed once tests pass. Assignment enrolment dependencies!
@dasilvacontin Really like those ideas, especially the idea of sending a pull request to build up the assignment over time.
I'm looking forward to use Classroom for a course I'll be giving in early July. I'm laying out some thoughts here.
For my use case, at first I thought that I would like to build up assignments on top of earlier ones, meaning I would create multiple assignments and somehow link them in Classroom's interface. But then I examined what I actually like about that idea:
- having the students reuse their code for some tasks / tests that work around the same problem / topic
- being able to track progress for each of those tasks / tests via CI. Pass or fail. Done or not. And then to be able to check CI status for all of them in a Dashboard.
In case those are the reasons why you want to create multiple assignments that build up on top of earlier ones, I think being able to check student progress for a single assignment is a better solution. Less assignment bloat, and student's progress for the related tests is in the same place, whether you are looking at Classroom's UI or GitHub's UI. (vs having to look for CI status for the student's submission for the different assignments)
If provided, Repository metadata shouldn't only contain CI status as a boolean, but also the actual number of passed tests / total tests. If you are worried about spoiling future tasks / tests or overwhelming the students with code that won't be used since the beginning, the Pull Request solution mentioned above could work. You could even trigger those Pull Requests while the 'required'/'previous' tests have passed.
If the assignments can be built on top of one another, couldn't their tasks be grouped under the same assignment? They are probably part of the same project, and you could consider the project to be the actual assignment.
Right now, I can't come up with cases where you want to reuse code unless:
- it's part of the same project or
- that code forms a library.
And in the latter such case, a library is a project by itself, and you should consider reusing it as an actual library. All package managers I know have an option to install dependencies directly from GitHub repos, so earlier assignments can easily be reused as libraries, since they are fully implemented in the same repo. For JS, npm lets you publish personal scoped packages, in case you want them to actually publish it (even if it's just to learn about publishing packages). Otherwise, you can provide an implementation of the library as part of the starting code for the new assignment.
tl;dr: my temporal opinion is each project should be a single assignment. Unless you can modularise it into libraries, which can be considered individual projects, individual assignments. Looking forward to hear your opinions! (and sorry for the bloat / long text!)
@dasilvacontin I agree. I no longer like the suggestion I had previously made where you'd have to create a new Assignment in order to release new code. Right now I'm just using one assignment for the long-term project and I'll manually push branches to the student repos to "release new code" (unless Classroom adds support for that before I need it).
I am not sure if this is still being considered, but I would really like this feature (the ability to push changes to student repos after they were created). I don't know enough about GitHub and Classrooms to suggest implementations, but this would be a big help. My use case is that I need to make changes / modifications / corrections to the assignment after the students have created their repos.
I actually was surprised when that was not available. To others reading this forum, I did accomplish this manually by:
- Used git clone to clone the student's assignment repo to my local computer.
- Used git remote add to add the CourseRepo (The one from which the student repo was created by classroom) as a remote on my local clone of the student repo.
- Used git fetch CourseRepo/master to get the changes from the master branch of the CourseRepo to my local computer
- Used git merge CourseRepo/master to incorporate the changes.
- Used git push to post the changes to the student's online repository.
I like the idea of creating pull requests.
My prior use case is adding something to the starter code. For example a fix which is needed after some upgrade of the dev tools or the operting system.
Any idea whether we'll see movement on this issue?
A related idea would be to simply set up the starter code repository as a separate remote during initial repository creation (name it "starter" or something). That way students could still pull changes from upstream after they begin work, allowing the course staff to push new things or (equally if not more importantly) fixes, while leaving students in control over the integration process and being a lot more Git-like than some other approaches.
Running a large class I know that at some point we're going to push a broken assignment, students are going to start working on it, and then we're going to have to push a fix. I'm opposed to doing anything that involves automatically modifying their repositories, since (a) that seems like a git antipattern and (b) they're the right person to handle merge conflicts, not me. So what we'll end up doing at that point is:
- Having students add a remote to their project (
git remote add starter url) git pull starter master- Students clean up the mess. Hopefully not much, particularly if we're modifying staff-maintained parts of assignments (like configuration files, test cases, etc.). But hey, merge conflicts are part of using
git.
If Classroom could help out by at least setting up the extra remote properly, that would be a help.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.