Autograder Score on README

I’ve been using the Classroom grading mechanism for two semesters and generally am very happy with it. I am wondering if there is a way to display the score from the latest build at the top of the README, similar to build status badges, so that students can see their grade without having to dig down into the build details and scroll through system output, etc.

So, the final line that reads something like “Points 75/85” is what I want to display atop the README.

1 Like

There is no current way of doing this. Though, you can write an automation script that does this. I am currently building my own version of the GitHub Classroom desktop tool so this is something that I will implement. @stevenbitner

It seems like if it isn’t available it requires either,

  1. Automatically creating commits to update the README to student repos, forcing students to merge before every commit, or
  2. Hosting a remote solution that parses out the build output.

I suppose through non-password protected SSH keys on a server to connect to Github to pull the data, the latter idea is possible, but both approaches feel dirty. I’m sure there are ideas that I just haven’t considered though.

I have a solution to this, using an orphan branch for the points status badge. I also had to fork and slightly modify the education/autograding action. (I’m sure someone else can come up with something better.)

I assume you are looking for something like this: image

Replace (or edit) the .github/workflow/classroom.yml

name: GitHub Classroom Workflow

    - '*'
    - '!badges'

    name: Autograding
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
          fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

      # add id to action so outputs can be used
      - uses: education/autograding@v1
        id: autograder
        continue-on-error: true

      # make dir for badges
      - name: badges branch and make dir
        run: |
          git checkout badges
          mkdir -p .github/badges
      # make points badge
      - name: points badge
        uses: emibcn/badge-action@v1
          LABEL: 'Points'
          STATUS: ${{ steps.autograder.outputs.points }}
          COLOR: cyan
          path: '.github/badges/points.svg'

      - name: Upload badge as artifact
        uses: actions/upload-artifact@v2
          name: badge
          path: '.github/badges/points.svg'
          if-no-files-found: error

      # commit and push badge if score has changed
      - name: Commit badge
        run: |
          git config --local ""
          git config --local "GitHub Action"
          git add '.github/badges/points.svg'
          git commit -m "Add/Update badge"
        continue-on-error: true
      - name: Push badge commit
        uses: ad-m/github-push-action@master
        if: success()
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: badges

For the badge add the following to the README file

![Points badge](../../blob/badges/.github/badges/points.svg)

You can see this working here:

[Edit: having read up a bit more on GH action outputs, I’ve realised points total is already exposed without having to fork the action. I’ve corrected the above .yml to reflect this.]


Just tried this out…brilliant @markpatterson27

I changed

git checkout badges


git checkout -B badges

to ensure the action doesn’t break when I forget to create a badges branch. This solution is exactly what I wanted. Thanks @markpatterson27, if we ever cross paths I owe you a :coffee: or :beer:.

EDIT: the above breaks on subsequent pushes since -B resets the branch. I grabbed this solution from SO - git checkout badges 2>/dev/null || git checkout -b badges.

1 Like
© 2017 GitHub, Inc.
with by
GitHub Education