Skip to main content

Github Actions

Github Actions is part of the CI/CD (continuous integration/continuous deployment) system on Github. This system is normally used to ensure that updates to source code get tested and properly deployed. For education purposes, this system can be used to automatically run unit tests on the programs submitted by your student. When a unit test fails, the action will show an error. When the unit tests are successful, the action will show that it has passed.

There are various ways that this can be done. The simplest is to use the unit tests in the student repositories. However, this does make it possible for students to modify the unit test if you wish.

The method I prefer is to have a separate private repository which hold all the testers for the course. The Action will use only the testers from that private repo to do the testing.

This is the setup for this... some of this is done because I do not have a great understanding of security and I may be doing things that are unnecessary. I just want to be careful about what I allow access to.

  1. Create a second github account who's only job is to read the tester repo.
  2. Create a private tester repo within your organization (the same one the student assignments are under)
  3. Place your testers into the private repository called testers
  4. Add your second github account to the private repo and give that second account read access
  5. Using the second account generate a repo scope classic token
  6. Add the token as an Organization Secret naming the secret Tester-Access
  7. Modify the following yml file to
    • copy out the student's programming file(s) and your tester file(s)
    • compile and/or run program
    • in this file the program name is a1.py and the tester is test_a1.py
# This is a basic workflow to help you get started with Actions

name: Assignment 1

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
paths:
- 'a1.py'

pull_request:
branches: [ main ]
paths:
- 'a1.py'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
path: ./assignment

- name: Checkout Tester
uses: actions/checkout@v2
with:
repository: CEMC-GitDemo/testers
token: ${{ secrets.TESTER_ACCESS }}
path: ./tester

- name: Copy python tester files
run: cp ./tester/test_a1.py ./

- name: Copy assignment files
run: cp ./assignment/a1.py ./


- name: Run tester
run: python test_a1.py
  1. Create a .github folder into your assignment template repository
  2. Within the .github folder add a workflows folder
  3. Within the workflows folder add the yml file you created in step 7