Customize classroom.yml from template repo?

I’ve been messing around with GitHub Classroom autograder that uses GitHub actions. I see that it creates a .github folder that has a classroom and workflows folders, which contain the autograding.json and classroom.yml files respectively. I was able to set up the assignment template repos with their own version of autograding.json to call a testing file instead of setting up all the tests individually. So I thought that I could do the same with the classroom.yml file, but it’s getting overwritten with the default file. GitHub actions is running my python testing file with python 2.7 and I need python 3.8, so I changed the files as follows:
Default

 name: GitHub Classroom Workflow
    on: [push]
    jobs:
      build:
        name: Autograding
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          - uses: education/autograding@v1

My version


name: GitHub Classroom Workflow
on: [push]
jobs:
      build:
        name: Autograding
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          - name: Setup Python
            uses: actions/setup-python@v2
            with:
                python-version: 3.8
          - uses: education/autograding@v1

I’ve been testing this using my own github account but accepting the Classroom link to create a student version of the repo.

Does anyone have any ideas on how to get my version to stick, or am I going to need student to update the classroom.yml file for each assignment?

run your script through a classroom autograding test

1 Like

I’m also interested on this. I have set up pytest, which fails the install due to Python 2.7 issues. It would be very useful to know how to install other relevant packages (e.g. numpy and family), ideally via e.g. miniconda (sometimes we need complex binary libraries that aren’t really pip friendly).

Using python3 calls within classroom autograding tests worked for me

Ok, so the root of the problem isn’t that it doesn’t run python 3, it’s that it runs python 3.6 and I need it to run python 3.8 (or at least 3.7) since that’s when Python’s subprocess module changed their run method to include the capture_output parameter.

    Traceback (most recent call last):
    File "test_00.py", line 10, in test_1
      result = Tests.catchOutput()[:len(correct)]
    File "test_00.py", line 27, in catchOutput
      p = run(f"python {Tests.file} {seed}", capture_output=True, text=True, cwd=cwd, shell=True, input=inputs)
    File "/usr/lib/python3.6/subprocess.py", line 423, in run
      with Popen(*popenargs, **kwargs) as process:
  TypeError: __init__() got an unexpected keyword argument 'capture_output'

I could rewrite my tests to be 3.6 compatible, but it would be much better if the tests were run in the same version as what the students are working on in Repl.it (Python 3.8.2 as of Feb 26, 2020).
The setup options in the audograding tests are for pip installs which doesn’t do me any good since I need to modify the setup of the CI (can’t pip --upgrade python)

I think I have found a solution: don’t enable autograding through github classroom, but have my own version of the .yml file in the template repo. It’s a simple solution that took too long for me to come to. Here’s a copy of my yml code:

name: Autograding
on: [push]
jobs:
      build:
        name: Autograding
        runs-on: ubuntu-latest
        steps:
          - uses: actions/setup-python@v2
            with:
                python-version: 3.8
          - uses: actions/checkout@v2
          - uses: education/autograding@v1    

I suggest for any others the may have a similar problem to follow these steps:

  1. Create your template repo
  2. Set up an assignment with autograding (put some rubbish in, since you’ll need the format of the files to edit.) in github classroom
  3. Create a ‘student’ repo by using the assignment url (can be done with your original github, don’t need a new account)
  4. Copy the .github folder to your template repo
  5. Edit the classroom/autograding.json file to select your premade testing file(s)
  6. Edit the workflows/classroom.yml file to add steps before the checkout and autograding steps (there are many premade github actions that can help setup your environment)
  7. Delete the assignment in classroom and recreate without autograding enabled.

These steps only need to be done once for the first assignment repo, then the .github folder can easily be copied and edited into other assignment repos without needing to make a ‘student’ repo to get the template.

© 2017 GitHub, Inc.
with by
GitHub Education