Lab: Report Deployment

Steven J Zeil

Last modified: May 3, 2023
Contents:

Abstract

In this lab, you will automate report generation and deployment (to GitHub Pages) for your project.

Make sure that you have your GitHub repository from this earlier assignment.

1 Review your documentation

  1. Rebuild your project and examine your working directory again. In build/reports/tests/test, you should find a nice little collection of files providing a web-ready summary of your unit test performance.

    • If you are running on your own PC, use your typical operating system file explorer tool to view the contents of that directory. Launch the the index.html file to view the report.
    • If you are working on one of the Cs Linus servers, open a session with X2Go, cd to your project directory, and view the report with the command:
      firefox build/reports/tests/test/index.html &
      
  2. Similarly, examine the report in build/reports/javadoc/.

2 GitHub Setup

Suppose that we wanted to put that up on a project website…

  1. Delete the file .github/workflows/request.yml. This will prevent your work on this lab from overwriting your grades for the prior assignment.

    Commit and push this change.

  2. Now set up a gh-pages branch in your repository and push it to github.

  3. Go to your repository page on GitHub. Enter the Settings area for your repository, select “Pages” in the left column.

    Under Source, select your gh-pages branch. Leave the folder at root.

    Click Save.

  4. Optionally, choose a Theme for your website. This theme will determine the appearance of Markdown files on your site.

  5. In the gh-pages branch, commit and push a Markdown file named index.md containing simply the word “Hello”.

    • This should be the only file in that branch.
  6. Use a web browser to verify that you now have a web site at https://yourGitHubLogin.github.io/yourProjectName/

    You should recognize your “index” page.

3 Report Generation

Next, you will add the steps to automatically publish your test and javadoc reports.

  1. Create a new directory src/main/html to hold new web content.

  2. In that directory, create a file named index.md with the following content:

    # Project Reports
    
    Your Name
    
    * [Tests](./reports/tests/test/)
    * [JavaDoc](./reports/javadoc/)
    
  3. Modify your build.gradle file to add a task named reports. The reports task should ensure that both the build tasks has been executed, and then

    • copy all files and directories from src/main/html/ directory to the reports/ directory.

  4. Test your new task by running

    gradle reports
    

    and verify that all of your content has moved into the build/reports directory.

  5. Modify your build.gradle file to add a task named deployReports. This task should

    • Guarantee that the reports task has been run.
    • Use gradle to transfer the reports/ directory to your website repository.
  6. Test your new tasks by running

    gradle deployReports
    
  7. Use a web browser to verify that your website at https://yourGitHubLogin.github.io/yourProjectName/ has been updated. You should immediately see that your index page no longer merely says “Hello”. Follow the links to observe your reports.

    Again, you should recognize your “index” page. Verify that the links now work and lead to the appropriate reports.

  8. You can play with this as you like. Maybe add some additional content to the src/main/html directory, change the number of unit tests, or alter the JavaDoc documentation in your .java files. Then see if you can observe the changes after running the deployReports task again.