Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejFrnka committed Jan 15, 2024
0 parents commit 35a9d5e
Show file tree
Hide file tree
Showing 13 changed files with 567 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
[push, pull_request]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: build
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Contributing to the project

## Restricted branches
- `development` - all the implemented features which are done and deployed
- `master` - stable version deployed

## Workflow

1. Create a feature branch when you start to work on a story and commit your changes to this
- the branch should be named `<id of the ticket>: <subject>`, for example `TB-3: Add login endpoint`
- the commits should also be named `<id of the ticket>: <subject>`, for example `TB-3: added unit tests`
2. Push this frequently to the remote repository from your local
2. When the feature is done, create a Pull Request from the `feature_branch` to `development`, follow the guidelines
3. When the PR is approved, merge it, and delete your feature branch

## Git Commit Guidelines

Read this article how to write meaningful commit messages:
[How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/)

We follow the rules below:
- **Commit message format**: `TB-{id}: <subject>`
- **id**: Id of the ticket you are working on (in jira)
- **Subject**: Changes in the commit

## Pull Request guidelines

- From `feature_branch` to `development`: add two developers and PM as reviewers, 3 approves needed for merging
- From `development` to `master`: this is managed by the PM
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## Development rules:

- Use `Lombok`
- Only Use Data Transfer Objects (Dto's) for request/response data (e.g. create a `dtos` package (do not put this package into the `models` package).
- Make *everything* configurable (e.g. via values in `.env` and `application.properties`), i.e. no constant value should be hard-coded. The database credentials are already pre-configured this way.
- Unit tests should be a part of pull requests
- Use the object wrapper for primitive types, e.g. `Long` instead of `long`
- Naming
- Entities/Models
- Use camelCase for Java properties and snake_case for the corresponding database column names. For example `private String activationToken` in the User model should be mapped to the `activation_token` column in the `users` table
- Database:
- Use plurals for database tables, e.g. `users`, `posts`, `likes` (and singular for the corresponding models names, i.e. `User`, `Post`, `Like`)
- Use `@GeneratedValue(strategy = GenerationType.IDENTITY)` for auto-incremented fields
- Tests: use descriptive (test) method names (to improve readability):
- : `canCreateModel()`
- : `isEmptyIsFalseForReceiptWithItems()`
- : `canAddPermissionsToUsers()`
- Endpoints: always start with `/api/v1/`
- Endpoints: use all lowercase letters and '-' for spaces
- : `/api/v1/user/vouchers`
- : `/api/v1/forgot-password`
- Create descriptive branch names, e.g. feature-user-registration
- Use `this` keyword only to avoid variable name conflicts
- Use the [code formatting](https://blog.jetbrains.com/idea/2020/06/code-formatting/) feature in Intellij (CTRL+ALT+L / ⌥⌘L)
- Have at least 90% test coverage regarding services (unit test) and controllers (integration tests)
- Use [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)
- Have a look [here](https://stackoverflow.com/questions/42979700/how-to-configure-google-java-code-formatter-in-intellij-idea-17) on how to configure the google java style guides in IntelliJ
- Make sure to use braces {} with `if`, `else`, `for`, `do` and `while` statements, even when the body is empty or contains only a single statement.


## Processes:
- Push only when *all* tests and style checks have passed
- Make sure there are no unresolved conflicts esp. in other than .java files
- see [CONTRIBUTING](CONTRIBUTING.md)

## Useful links

Contributing:

- see [CONTRIBUTING](CONTRIBUTING.md)

Commit messages:

- https://chris.beams.io/posts/git-commit/

Git cheat sheet

https://docs.google.com/spreadsheets/d/1Y6ylJLSbkUqLzn9kN_rQSgDlssRpR-ZFresF46apFWY/edit?usp=sharing

## Git Workflow

See [CONTRIBUTING](CONTRIBUTING.md)
45 changes: 45 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.7'
id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.sportsmatch'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}

tasks.named('bootBuildImage') {
builder = 'paketobuildpacks/builder-jammy-base:latest'
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 35a9d5e

Please sign in to comment.