Skip to content

Commit 0634d29

Browse files
authored
Introduce user service as a separate deployment (#497)
* Introduce user service as a separate deployment * Add required beans to make user creation and login works * Separate pipeline for each service * Fix pipeline * Fix docker repo name * Fix env variable * Rename consent actions files * Remove unused rabbitmq files * Add lock user service test * Add otp attempt test * Added haproxy to route request to user service * Updated dev setup
1 parent e015c5d commit 0634d29

File tree

132 files changed

+5811
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+5811
-123
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
name: GitHub Actions
1+
name: Consent Service Master Actions
22

33
on:
44
push:
55
branches:
66
- master
7+
paths:
8+
- 'consent/**'
79
jobs:
810
build:
911
runs-on: ubuntu-latest
@@ -14,13 +16,13 @@ jobs:
1416
with:
1517
java-version: 11
1618
- name: Build and unit tests
17-
run: ./gradlew clean test
19+
run: ./gradlew clean :consent:test
1820
- name: Code coverage
19-
run: ./gradlew jacocoTestReport
21+
run: ./gradlew :consent:jacocoTestReport
2022
- name: Code analysis
2123
env:
2224
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
run: ./gradlew sonarqube
25+
run: ./gradlew :consent:sonarqube
2426
- name: Generate artefact
2527
run: ./gradlew :consent:bootJar
2628
- name: Set env

.github/workflows/consent-pr.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Consent Service Pull Request Actions
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'consent/**'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Setup java
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 11
19+
- name: Build and unit tests
20+
run: ./gradlew clean :consent:test --info
21+
- name: Code coverage
22+
run: ./gradlew :consent:jacocoTestReport
23+
- name: Sonarcube Analysis
24+
run: ./gradlew :consent:sonarqube
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: GitHub Actions
1+
name: Consent Service Release Actions
22

33
on:
44
push:
@@ -14,7 +14,7 @@ jobs:
1414
with:
1515
java-version: 11
1616
- name: Build and unit tests
17-
run: ./gradlew clean test
17+
run: ./gradlew clean :consent:test
1818
- name: Generate artefact
1919
run: ./gradlew :consent:bootJar
2020
- name: Set env

.github/workflows/user-ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: User Service Master Actions
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'user/**'
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Setup java
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 11
18+
- name: Build and unit tests
19+
run: ./gradlew clean :user:test
20+
- name: Code coverage
21+
run: ./gradlew :user:jacocoTestReport
22+
- name: Code analysis
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: ./gradlew :user:sonarqube
26+
- name: Generate artefact
27+
run: ./gradlew :user:bootJar
28+
- name: Set env
29+
run: echo ::set-env name=RELEASE_VERSION::$(echo $GITHUB_SHA | head -c7)
30+
- name: Docker Registry
31+
env:
32+
DOCKER_REGISTRY_URL: docker.io
33+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
34+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
35+
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
36+
- name: Build docker image
37+
env:
38+
CONTAINER_REPO_NAME: user-service
39+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
40+
run: |
41+
cd user
42+
docker build -t $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION .
43+
- name: Push Docker Container to Registry
44+
env:
45+
CONTAINER_REPO_NAME: user-service
46+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
47+
run: docker push $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
name: GitHub Actions
1+
name: User Service Pull Request Actions
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'user/**'
49

510
jobs:
611
build:
@@ -12,8 +17,8 @@ jobs:
1217
with:
1318
java-version: 11
1419
- name: Build and unit tests
15-
run: ./gradlew clean test --info
20+
run: ./gradlew clean :user:test --info
1621
- name: Code coverage
17-
run: ./gradlew jacocoTestReport
22+
run: ./gradlew :user:jacocoTestReport
1823
- name: Sonarcube Analysis
19-
run: ./gradlew sonarqube
24+
run: ./gradlew :user:sonarqube

.github/workflows/user-release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: User Service Release Actions
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Setup java
13+
uses: actions/setup-java@v1
14+
with:
15+
java-version: 11
16+
- name: Build and unit tests
17+
run: ./gradlew clean :user:test
18+
- name: Generate artefact
19+
run: ./gradlew :user:bootJar
20+
- name: Set env
21+
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10}
22+
- name: Docker Registry
23+
env:
24+
DOCKER_REGISTRY_URL: docker.io
25+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
26+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
27+
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
28+
- name: Build docker image
29+
env:
30+
CONTAINER_REPO_NAME: user-service
31+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
32+
run: |
33+
cd user
34+
docker build -t $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION .
35+
- name: Push Docker Container to Registry
36+
env:
37+
CONTAINER_REPO_NAME: user-service
38+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
39+
run: docker push $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION

build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins {
88
id 'java'
99
id 'org.springframework.boot' version "${springBoot}"
1010
id 'io.spring.dependency-management' version "${dependencyManagement}"
11+
id 'com.avast.gradle.docker-compose' version '0.7.1'
1112
}
1213

1314
allprojects {
@@ -36,6 +37,16 @@ project(':consent') {
3637
}
3738
}
3839

40+
project(':user') {
41+
dependencies {
42+
implementation project(':commons')
43+
}
44+
}
45+
3946
bootJar {
4047
enabled = false
48+
}
49+
50+
dockerCompose {
51+
useComposeFiles = ['haproxy/docker-compose.yml']
4152
}

commons/src/main/java/in/projecteka/library/common/Constants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ public class Constants {
77
public static final String BLACKLIST = "blacklist";
88
public static final String BLACKLIST_FORMAT = "%s:%s";
99
public static final LocalDateTime DEFAULT_CACHE_VALUE = LocalDateTime.MIN;
10+
public static final String SCOPE_CONSENT_APPROVE = "consentrequest.approve";
11+
public static final String SCOPE_CONSENT_REVOKE = "consent.revoke";
12+
public static final String SCOPE_CHANGE_PIN = "profile.changepin";
13+
1014
//APIs
1115
public static final String CURRENT_VERSION = "/" + API_VERSION;
1216

consent/src/main/java/in/projecteka/consentmanager/consent/model/PatientReference.java renamed to commons/src/main/java/in/projecteka/library/common/PatientReference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package in.projecteka.consentmanager.consent.model;
1+
package in.projecteka.library.common;
22

33
import lombok.AllArgsConstructor;
44
import lombok.Builder;

consent/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sonarqube {
1010
property "sonar.host.url", "https://sonarcloud.io"
1111
property "sonar.login", "dd5db84dbf8f6dbd393291c26fe038ab54f00072"
1212

13+
property 'sonar.exclusions', 'src/test/java/in/projecteka/consentmanager/**.java'
1314
property 'sonar.coverage.jacoco.xmlReportPaths', 'build/reports/jacoco/test/jacocoTestReport.xml'
1415
}
1516
}
@@ -37,7 +38,7 @@ dependencies {
3738
compileOnly 'org.projectlombok:lombok'
3839
testCompileOnly 'org.projectlombok:lombok'
3940
annotationProcessor 'org.projectlombok:lombok'
40-
implementation 'org.jeasy:easy-random-core:4.2.0'
41+
testImplementation 'org.jeasy:easy-random-core:4.2.0'
4142
testImplementation "com.squareup.okhttp3:okhttp:4.8.1"
4243
testImplementation "com.squareup.okhttp3:mockwebserver:4.8.1"
4344
implementation 'com.google.guava:guava:29.0-jre'

0 commit comments

Comments
 (0)