CI is the second assignment in the course DD2480 Software Engineering Fundamentals. The goal of the assignment is to implement a continuous integration server which first clones a repository on GitHub when there are any changes pushed to it, builds the project, runs the tests in the project and notifies the user of the results.
This implementation of a CI-server is made with Java SDK 11 and IntelliJ; therefore make sure you have these installed. The project that uses the CI-server needs to have Gradle
installed. For the project to build and run, there must exist a build.gradle
file in the project, containing the dependencies needed.
You can easily generate all the JavaDoc
with the command gradlew javadoc
. Then go to build/docs/javadoc
where you can find the allclasses.html
that you can open in your favorite browser.
There are two main branches: master
and assessment
. The master branch contains the CI-server. The assessment branch is simulating a project with a main class and a simple test for it. The purpose of the assessment branch is to use it to test the functionality of the CI-server.
Tests for the CI-server are written using the JUnit
library. If you want to run the tests locally, there are two ways.
- Using the terminal: first navigate to the the project folder, then use the command
./gradlew build
. This command builds and tests the project. If you only want to test and not build, use the command./gradlew test
. For windows machines you can usegradlew test/build
. - Using IntelliJ: Open the project in IntelliJ. Right-click on the src-folder and choose
Run 'Tests in DD2480-Big-Brain-CI.test'
. To build the project right-click on the src-folder and chooseBuild module DD2480-Big-Brain-CI
.
If the build was successful there will be a new directory in the project named 'build' that contains the generated classes. If it does not succeed the directory will not contain any generated classes.
Using ngrok we can make the server visible on the internet. If you don't have it installed write the following in the terminal:
#For linux users:
curl -LO --tlsv1 https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
unzip ngrok-stable-linux-amd64.zip
#For Mac users:
curl -LO --tlsv1 https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-386.zip
unzip ngrok-stable-darwin-386.zip
All you have to do is open a new terminal window and use the command ./ngrok http 8083
. The ngrok service provides a forwarding URL that works for 8 hours.
After this you have to set up a Webhook. This can be done on the Github repository online.
- Go to
Settings >> Webhooks
, click onAdd webhook
. - Paste the forwarding URL that
ngrok
provides (for examplehttps://7al9b010.ngrok.io
) in the payload field and proceed to clickAdd webhook
. Nothing else is required than the URL.
Now the CI-server should be ready to be used.
To test the CI-server there is a specific branch prepared. Follow the steps below in the terminal to proceed. These steps assumes you have already cloned the repository.
- Go to the assessment branch using the command
git checkout -b assessment origin/assessment
- Make a change somewhere
- Commit and push the changes to
GitHub
- The CI-server will do its part and notify about the results of the build and tests using Slack
- Clones the branch assessment in the project by executing commands and saves it to a directory named 'assessmentDir'.
- Builds the cloned project and runs the tests defined in the project. This is done by executing the command
./gradlew build
. - The results of the build and tests are sent via a notification on Slack. This is done using the
XML-file
that is generated byGradle
when building the project.
Each issue should be worked on separately in its own branch; issue #420 should only be worked on in the branch issue-420
. Solutions to issues can only be merged to master
after a successful review of a pull request.
- Every method should have a
JavaDoc
comment explaining what it does, the parameters and the return value.
Axel Kennedal
- created the Slack app
- implemented Slack integration for notifications
- implemented parsing Gradle test results XML
My Helmisaari
- this README
- debugging and testing the server
- fixed bugs
Henrik Mellin
- Webhook GitHub
- Cloning the project
Mathieu Desponds
- this README
- The structure of the project including the Gradle part
- The assessment branch
If the source and test folders are not showing up in the project view, try following these instructions.