Lab: Report Deployment
Steven J Zeil
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
-
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 yourproject
directory, and view the report with the command:firefox build/reports/tests/test/index.html &
- 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
-
Similarly, examine the report in
build/reports/javadoc/
.
2 GitHub Setup
Suppose that we wanted to put that up on a project website…
-
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.
-
Now set up a gh-pages branch in your repository and push it to github.
-
Go to your repository page on GitHub. Enter the Settings area for your repository, select “Pages” in the left column.
Under
Source
, select yourgh-pages
branch. Leave the folder at root.Click
Save
. -
Optionally, choose a Theme for your website. This theme will determine the appearance of Markdown files on your site.
-
In the
gh-pages
branch, commit and push a Markdown file namedindex.md
containing simply the word “Hello”.- This should be the only file in that branch.
-
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.
-
Create a new directory
src/main/html
to hold new web content. -
In that directory, create a file named
index.md
with the following content:# Project Reports Your Name * [Tests](./reports/tests/test/) * [JavaDoc](./reports/javadoc/)
-
Modify your
build.gradle
file to add a task namedreports
. Thereports
task should ensure that both thebuild
tasks has been executed, and then-
copy all files and directories from
src/main/html/
directory to thereports/
directory.
-
-
Test your new task by running
gradle reports
and verify that all of your content has moved into the
build/reports
directory. -
Modify your
build.gradle
file to add a task nameddeployReports
. This task should- Guarantee that the
reports
task has been run. - Use gradle to transfer the
reports/
directory to your website repository.
- Guarantee that the
-
Test your new tasks by running
gradle deployReports
-
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.
-
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 thedeployReports
task again.