This is not the current offering of the course. You may want the next offering at https://ucsd-cse15l-f22.github.io/, or scroll down for the winter 2022 material.

Week 6

Week 6 – Build and Run Automation

Due This Week

Notes from Class

Monday 1pm

Monday 2pm

Lab Tasks

Most of these instructions are Mac/Linux only; run on ieng6 if you have a windows machine.

As usual, this will be in some flux until the lab time on Wednesday, but you can use it to look ahead and think about what you’ll need to do.

The lab report task will be posted Monday evening and will be firm once posted, so you can get started on it before Wednesday!

Setup

Have a member of your group clone a fresh copy of markdown-parse that reflects the work you’ve done so far as a group. Once they have the fresh copy and have opened it in VScode:

  • Start a timer
  • Have them run the tests
  • Have them run MarkdownParse from the command-line with test-file.md as input
  • Stop the timer

How long did it take to do this? Where did they look up the necessary commands? Did they make any typos or small mistakes? Were the commands in their command history?

Makefile

Create a makefile for your fork of markdown-parse. Your makefile should have a target, test, that:

  • Rebuilds the .class files using javac if the corresponding .java file has updated
  • Runs the tests after rebuilding the necessary .class files

Create any other targets you need for this; refer to the notes from class on Monday to help.

Write in notes: Show what the makefile does for make test:

  • When you have no .class files in the directory (delete them if necessary)
  • When you have both of the .class files present, then make a change to MarkdownParse.java, save, and run. How many commands run, and why? Justify why each is necessary.
  • When you have both of the .class files present, then make a change to MarkdownParseTest.java, save, and run. How many commands run, and why? Justify why each is necessary.

Write down in notes: Add the makefile in a commit, push it, and note a link to the commit in your notes.

Write down in notes: Then, change the Github Action on your repository to just use make test instead of running multiple commands. Take a screenshot of the action succeeding while using make test and link to the action’s output.

Bash Scripting

Create a file called mdparse in the current directory.

In it, add this text:

java -cp lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar:. MarkdownParse $1

Then, from the command line, run:

bash mdparse test-file.md

then run

bash mdparse test-file2.md

Write down in notes: What does the $1 mean? If you’re struggling to define this, add the line echo $1 to mdparse and re-run it. What do you see?

A project will often define one or more scripts for command-line programs to avoid having to type out, or deal with, a long classpath or other configuration.

Note that this is distinct from the makefile for a good reason – it’s not nearly so easy to pass a command-line argument to a makefile, and they are indeed not built for that purpose.

Write down in notes: Commit and push mdparse to the repository, and note *the commit link in your notes document so everyone can find it later.

Improvement

Have a member of your group clone a fresh copy of markdown-parse that reflects the work you’ve done so far as a group and includes the makefile and mdparse. Once they have the fresh copy and have opened it in VScode:

  • Start a timer
  • Have them run the tests (use your makefile!)
  • Have them run MarkdownParse from the command-line with test-file.md as input (use your mdparse bash script!)
  • Stop the timer

How long did it take to do this? Where did they look up the necessary commands? Did they make any typos or small mistakes? Were the commands in their command history?

What an Autograder Does

Autograders are often built out of a combination of test files, makefiles, and (bash) scripts.

Imagine that markdown-parse was a class assignment, and you were the tutor designing an automatic grader for it. You get this grading repository from the last quarter’s staff:

https://github.com/ucsd-cse15l-w22/grade-markdown-parse

Clone grade-markdown-parse and try running the provided grade.sh script on your team’s markdown-parse repository (it takes a git repo URL as a command-line argument).

Write down in notes What does grade.sh do? What questions do you have about it?

A typical setup for autograders on e.g. Gradescope is that a script like this one runs, and students are shown the output of that script (there’s some extra work that goes into turning the output into points for Gradescope, but let’s focus on the output for now.)

Think about:

  • What gets printed out for the student? What if there is a compile error? What about a failed test?
  • Does grade.sh you rely on the makefile in the student directory? Should you?
  • What if the student’s repository is missing a file? Can you improve the error message in that case?
  • What if the student’s repository is missing the lib directory? Can/should you make that work?
  • What kind of output might be discouraging or unhelpful to the student?
  • What kind of output might encourage the student to write more of their own tests?

You can try making your own changes to grade.sh.

Remember: You can use all the commands you’re familiar with, like cd, git, make, cp, and so on, in bash scripts. You can also use if statements from class, and feel free to Google! Some useful (or not!) searches might be:

  • “check if file exists bash”
  • “how to copy whole directory”
  • “how to make new directory bash”

Write down in notes: Discuss if this made you learn anything about how autograders might be running on your code in classes like CSE 8B, 11, and 12!

Write down in notes: What new bash commands or techniques did you learn, if any?

Write down in notes: Make sure to save your changes (if any) that you made to grade.sh!

Week 6 Lab Report

Choose one of the Group Choice Options (1-3) from week 5. Complete it for yourself (if you haven’t already), and take the relevant screenshots listed below for your choice. Create a post with a few sentences of description about each. Do this for only one of these options for your lab report.

Create it in a new file called lab-report-3-week-6 so that it gets a new page on your site, and add a link to the page to the index of your site. You will submit it to Gradescope as usual as a few links.

  • Streamlining ssh Configuration
    • Show your .ssh/config file, and how you edited it (with VScode, another program, etc)
    • Show the ssh command logging you into your account using just the alias you chose.
    • Show an scp command copying a file to your account using just the alias you chose.
  • Setup Github Access from ieng6
    • Show where the public key you made is stored on Github and in your user account (screenshot)
    • Show where the private key you made is stored on your user account (but not its contents) as a screenshot
    • Show running git commands to commit and push a change to Github while logged into your ieng6 account
    • Show a link for the resulting commit
  • Copy whole directories with scp -r
    • Show copying your whole markdown-parse directory to your ieng6 account
    • Show logging into your ieng6 account after doing this and compiling and running the tests for your repository
    • Show (like in the last step of the first lab) combining scp, ;, and ssh to copy the whole directory and run the tests in one line.

It’s fine if you’ve done more than one of these, and, for example the alias from your ssh setup shows up in the third step when copying. Make it clear which one you’ve chosen.