cs107-lecture-examples

Example codes used during Harvard CS107 lectures
git clone https://git.0xfab.ch/cs107-lecture-examples.git
Log | Files | Refs | README | LICENSE

lecture16.yml (2211B)


      1 # This is a basic workflow to help you get started with Actions
      2 # You find out more at: https://docs.github.com/en/actions
      3 name: Lecture16 Continuous Integration Test Coverage (with custom container)
      4 
      5 # Controls when the workflow will run
      6 on:
      7   # Triggers the workflow on push or pull request events but only for the master
      8   # branch
      9   push:
     10     branches:
     11       - main
     12   pull_request:
     13     branches:
     14       - main
     15 
     16   # Allows you to run this workflow manually from the Actions tab
     17   workflow_dispatch:
     18 
     19 # A workflow run is made up of one or more jobs that can run sequentially or in
     20 # parallel. For more on jobs:
     21 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobs
     22 jobs:
     23   # This workflow contains a single job called "test_coverage"
     24   test_coverage:
     25 
     26     # The type of runner that the job will run on
     27     runs-on: ubuntu-latest
     28 
     29     # here we specify the container image that we have built ourselves.  The
     30     # image already contains the Python environment for our needs and we can
     31     # skip to install a Python environment and dependencies below.  Procedure is
     32     # similar for other CI providers.
     33     # https://hub.docker.com/r/iacs/cs107_lecture16/tags
     34     container:
     35       image: iacs/cs107_lecture16:latest
     36 
     37     # Steps represent a sequence of tasks that will be executed as part of the
     38     # job. For more on steps:
     39     # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idsteps
     40     steps:
     41       # Check out your repository under $GITHUB_WORKSPACE (job needs access to it)
     42       # See: https://github.com/actions/checkout
     43       - uses: actions/checkout@v3
     44 
     45       # Check what Python installation we are using (installed in custom
     46       # container)
     47       - name: Check Python installation
     48         run: python3 -VV
     49 
     50       # Build and install our package in the container
     51       - name: Build and install the cs107_project in the container (using PEP517/518)
     52         run: (python3 -m build --wheel && python3 -m pip install dist/*)
     53 
     54       # Run the test coverage for the build
     55       - name: Run tests and generate coverage html
     56         run: (cd tests && ./run_tests.sh CI --cov=cs107_package --cov-report=term-missing)