Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Daya Adianto's avatar
Daya Adianto authored
Fix CI rule for deploying to production environment

Closes #11

See merge request !7
644a4155

Sitodo (PMPL Variant)

pipeline status coverage report

A basic todo app project for teaching basic Web programming, Git workflows, and CI/CD. Heavily inspired by the running example in "Test-Driven Development with Python" book by Harry Percival.

Note: The project has been customised from the upstream in order to be used in PMPL (SQA) course at the Faculty of Computer Science Universitas Indonesia.

Setting Up Development Environment

The following tools need to be installed in order to build and run the project:

Ensure java, javac, and mvn commands can be invoked from inside the shell:

$ java --version
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
$ javac --version
javac 17.0.3
$ mvn --version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)

We recommend IntelliJ IDEA Community Edition as the IDE for developing the project. Other IDE or text editors, such as Eclipse and Visual Studio Code, might work. However, we may not be able to help troubleshoot any IDE-related issues. In addition, we include IntelliJ-specific run configurations in the codebase that will add shortcuts for running the test suites and coverage reporting from within IntelliJ.

Getting Started

To run the whole test suite, execute:

mvn test

To run a select test suite, e.g. unit or functional test, add -Dgroups parameter. For example, to run only the unit test suite, execute mvn test -Dgroups=unit. Similarly, to run only the functional test suite, execute mvn test -Dgroups=e2e.

To build an executable Spring Boot application, execute:

mvn package -DskipTests

The -DskipTests option lets package task to build the app into executable JAR file without running all test suites. If the option was omitted, then all test suites will run, thus increasing the duration of the building process, especially the functional test suite that runs much longer than the unit test suite.

The JAR file will be generated at ./target directory. To run it, execute:

java -jar sitodo.jar

You can customise the configuration by providing an application.properties file in the same directory as the executable JAR file. See the built-in configuration in the source code.

You can also set the configuration during runtime using environment variables. Following Spring Boot convention, properties are named in all uppercase, and dot separators are replaced with underscores. For instance, spring.datasource.url becomes SPRING_DATASOURCE_URL when configured using an environment variable. See the example in the GitLab CI/CD configuration, specifically in the job for running tests.

Practical Tasks

See the TODO items spread across several files in the project:

grep -nr "TODO:"

Note: If you are using Windows, you can use Git Bash or Bash on WSL to execute the command above.

Running Example

See the running example based on the main branch at Fly.io.

License

This project is licensed under the terms of the MIT license.

Exercise Report

TODO: (For SQA/PMPL course participants) Write the URL to your deployed application in this section.

TODO: (For SQA/PMPL course participants) Write your report in this section.