-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-added group of folders -created basic examples (model, endpoints, db) -configuration of mysql
- Loading branch information
github-actions
committed
Nov 15, 2024
1 parent
1850928
commit 08ebeb6
Showing
14 changed files
with
366 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Spring mvn tests pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- spring/** | ||
pull_request: | ||
paths: | ||
- spring/** | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
# services: | ||
# db: | ||
# image: mysql:8.0 | ||
# ports: | ||
# - 3306:3306 | ||
# env: | ||
# MYSQL_ROOT_PASSWORD: root_password | ||
# MYSQL_DATABASE: foo | ||
# MYSQL_USER: user1 | ||
# MYSQL_PASSWORD: user1_password | ||
# options: >- | ||
# --health-cmd "mysqladmin ping" | ||
# --health-interval 10s | ||
# --health-timeout 5s | ||
# --health-retries 5 | ||
# steps: | ||
# - name: Show Docker containers | ||
# run: docker ps -a | ||
# - name: Show databases for root user | ||
# run: mysql --protocol=tcp -h localhost -P 3306 -u root -proot_password -e "SHOW DATABASES" | ||
# - name: Show databases for user1 | ||
# run: mysql --protocol=tcp -h localhost -P 3306 -u user1 -puser1_password -e "SHOW DATABASES" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Run mvn tests | ||
working-directory: ./spring | ||
run: mvn test | ||
|
||
- name: Spring format check | ||
working-directory: ./spring | ||
run: mvn formatter:validate |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: CI with Spring Boot and MySQL | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- spring/** | ||
pull_request: | ||
paths: | ||
- spring/** | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
mysql: | ||
image: mysql:8.0 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: testdb | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping --host 127.0.0.1 --silent" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
- name: Cache Maven dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Build with Maven | ||
run: mvn clean install -DskipTests | ||
|
||
- name: Run tests | ||
run: mvn test | ||
env: | ||
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/testdb | ||
SPRING_DATASOURCE_USERNAME: root | ||
SPRING_DATASOURCE_PASSWORD: root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE DATABASE Weather; | ||
CREATE USER 'WeatherServer'@'localhost' IDENTIFIED BY 't4jn3h4sL0'; | ||
GRANT ALL PRIVILEGES ON Weather.* TO 'WeatherServer'@'localhost'; | ||
FLUSH PRIVILEGES; | ||
SHOW GRANTS FOR 'WeatherServer'@'localhost'; | ||
|
||
|
||
|
||
odpalanie: mvn spring-boot:run | ||
|
||
dopisanie w controller wiecej getow (i wiecej metod w ) | ||
|
||
stworzenie w model nowych obiektow (tych co jest w projekcie bazy danych) | ||
do nich wlasne interface | ||
i wlasne repa w data | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
spring/src/main/java/com/pogoda/weather/controller/Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.pogoda.weather.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.pogoda.weather.data.EspMeasurementsRepo; | ||
import com.pogoda.weather.model.EspMeasurements; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@RestController | ||
@RequestMapping("/weather") | ||
public class Controller { | ||
|
||
@Autowired | ||
EspMeasurementsRepo espDataRepo; | ||
|
||
@GetMapping("/test") | ||
public String aja() { | ||
return "cos tam"; | ||
} | ||
|
||
@PostMapping("/test") | ||
public void ajaa() { | ||
System.out.println("DOSTALEM"); | ||
} | ||
|
||
@PostMapping("/measurments") | ||
public ResponseEntity<EspMeasurements> zapis(@RequestBody EspMeasurements espMeasurements) { | ||
return ResponseEntity.ok(espDataRepo.saveMeasurements(espMeasurements)); | ||
} | ||
|
||
@GetMapping("/measurments/{id}") | ||
public ResponseEntity<EspMeasurements> odczyty(@PathVariable String id) { | ||
return ResponseEntity.ok(espDataRepo.getMeasurements(id)); | ||
} | ||
} |
Oops, something went wrong.