Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 4f4a7cdd authored by Daya Adianto's avatar Daya Adianto
Browse files

Finalise code template for internal workshop

parent 8d35a36c
No related branches found
No related tags found
1 merge request!11Finalise code template for internal workshop
......@@ -37,6 +37,7 @@ stages:
- post-deploy
- report
# Only run the deployment CI job on the original, upstream repository
.upstream-deploy-production-rules:
rules:
- if: $CI_PROJECT_NAMESPACE != "pmpl/examples"
......@@ -67,15 +68,6 @@ build:
test:
stage: test
image: docker.io/library/maven:3.9.5-eclipse-temurin-17-focal
services:
- name: docker.io/library/postgres:14-alpine
alias: database
variables:
SPRING_DATASOURCE_URL: jdbc:postgresql://database:5432/sitodo
SPRING_DATASOURCE_USERNAME: sitodo
SPRING_DATASOURCE_PASSWORD: sitodo_cicd
POSTGRES_USER: sitodo
POSTGRES_PASSWORD: sitodo_cicd
needs:
- build
before_script:
......
web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/*.jar
web: java -Dserver.port=$PORT $JAVA_OPTS -jar sitodo-*.jar
......@@ -25,12 +25,12 @@ Python" book by Harry Percival.
The following tools need to be installed in order to build and run the project:
- [Java 17 JDK (Java Development Kit)](https://adoptium.net/temurin/releases/)
- PostgreSQL 14
- You can install PostgreSQL system-wide or use container (Docker/Podman)
- A [`docker-compose.yml`](./docker-compose.yml) has been provided to quickly start a PostgreSQL and pgAdmin containers
- [Apache Maven 3.8.5](https://maven.apache.org/download.cgi)
- [Mozilla Firefox](https://www.mozilla.org/en-US/firefox/)
- Required by the functional (Selenium) test suite and BDD test suite
- (Optional) PostgreSQL 14
- You can install PostgreSQL system-wide or use container (Docker/Podman)
- A [`docker-compose.yml`](./docker-compose.yml) has been provided to quickly start a PostgreSQL and pgAdmin containers
Ensure `java`, `javac`, and `mvn` commands can be invoked from inside the shell:
......@@ -60,7 +60,7 @@ 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`.
> execute `mvn test -Dgroups=func`.
To build an executable Spring Boot application, execute:
......@@ -90,22 +90,23 @@ Following Spring Boot convention, properties are named in all uppercase and dot
For instance, `spring.datasource.url` becomes `SPRING_DATASOURCE_URL` when configured using an environment variable.
See the example in the [GitLab CI/CD configuration](./.gitlab-ci.yml), specifically in the job for running tests.
The project includes a Spring profile that lets you test and run the application using an in-memory database (HSQLDB).
To test and run the application using HSQLDB as the backing database, enable the profile using the following command:
The project includes a Spring profile that lets you test and run the application using PostgreSQL database.
To test and run the application using PostgreSQL as the backing database, enable the profile using the following command:
```shell
# When running a Maven task
mvn -D"spring.profiles.active=hsqldb" [task]
mvn -D"spring.profiles.active=postgresql" [task]
# When running the app as standalone JAR
java -D"spring.profiles.active=hsqldb" sitodo.jar
java -D"spring.profiles.active=postgresql" sitodo.jar
# Or configure via environment variable
export SPRING_PROFILES_ACTIVE=hsqldb
export SPRING_PROFILES_ACTIVE=postgresql
java -jar sitodo.jar
```
### Running Example
See the running example based on the [upstream's `main` branch](https://gitlab.cs.ui.ac.id/pmpl/examples/sitodo-pmpl/-/tree/main) at [Fly.io](https://sitodo-pmpl.fly.dev).
See the running example based on the [upstream's `main` branch](https://gitlab.cs.ui.ac.id/pmpl/examples/sitodo-pmpl/-/tree/main) at [Fly.io](https://sitodo-pmpl.fly.dev)
or [self-hosted Dokku](http://sitodo-pmpl.dokku-ppl.cs.ui.ac.id:8080).
## License
......
......@@ -10,7 +10,7 @@
</parent>
<groupId>com.example</groupId>
<artifactId>sitodo</artifactId>
<version>0.1.3-SNAPSHOT</version>
<version>0.1.4-SNAPSHOT</version>
<name>sitodo-pmpl</name>
<description>A basic todo app for teaching basic Web programming, Git workflows, and CI/CD. Heavily inspired by the
running example in &quot;Test-Driven Development with Python&quot; book by Harry Percival.
......
......@@ -18,9 +18,9 @@ sitodo.motivation.manyItemsThreshold=10
# Database connection configuration
## Warning: The following configurations are for development environment!
## Use different values when deploying to production environment!
spring.datasource.url=jdbc:hsqldb:mem:sitodo
spring.datasource.url=jdbc:postgresql://localhost:5432/sitodo
spring.datasource.username=sitodo
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
spring.datasource.password=R83Moz74
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=classpath:db/changelog/db.changelog-hsqldb.yaml
spring.liquibase.change-log=classpath:db/changelog/db.changelog-postgresql.yaml
......@@ -18,9 +18,9 @@ sitodo.motivation.manyItemsThreshold=10
# Database connection configuration
## Warning: The following configurations are for development environment!
## Use different values when deploying to production environment!
spring.datasource.url=jdbc:postgresql://localhost:5432/sitodo
spring.datasource.url=jdbc:hsqldb:mem:sitodo
spring.datasource.username=sitodo
spring.datasource.password=R83Moz74
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=classpath:db/changelog/db.changelog-postgresql.yaml
spring.liquibase.change-log=classpath:db/changelog/db.changelog-hsqldb.yaml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment