Skip to content

Commit

Permalink
Merge pull request #1017 from puzzle/multitenancy_main-merge
Browse files Browse the repository at this point in the history
Merge multitendancy in main
  • Loading branch information
peggimann authored Oct 14, 2024
2 parents 9355edf + 3782106 commit db6bcdf
Show file tree
Hide file tree
Showing 493 changed files with 23,205 additions and 7,635 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/demo-deploy-action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'Demo-Deploy'

on:
pull_request:
types:
- closed
branches: [ main ]
# pull_request:
# types:
# - closed
# branches: [ main ]

jobs:
update-version:
Expand Down Expand Up @@ -144,12 +144,12 @@ jobs:
with:
build: npm i -D cypress
install: false
wait-on: 'http://localhost:8080/config, http://localhost:8544'
wait-on: 'http://pitc.okr.localhost:8080/config, http://pitc.okr.localhost:4200, http://localhost:8544'
wait-on-timeout: 120
browser: chrome
headed: true
working-directory: frontend
config: baseUrl=http://localhost:8080
config: baseUrl=http://pitc.okr.localhost:8080

- uses: actions/upload-artifact@v4
if: always()
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/frontend-test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
--name my_keycloak \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=keycloak \
-v ./docker/config/realm-export.json:/opt/keycloak/data/import/realm.json \
-v ./docker/config/realm-export-pitc.json:/opt/keycloak/data/import/realm-pitc.json \
-p 8544:8080 \
quay.io/keycloak/keycloak:23.0.1 \
quay.io/keycloak/keycloak:24.0.2 \
start-dev --import-realm
- name: start backend
Expand All @@ -58,10 +58,16 @@ jobs:
with:
working-directory: frontend
start: npm start
wait-on: 'http://localhost:8080/config, http://localhost:4200, http://localhost:8544'
wait-on: 'http://pitc.okr.localhost:8080/config, http://pitc.okr.localhost:4200, http://localhost:8544'
wait-on-timeout: 120
browser: chrome
headed: true

- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-screenshots
path: frontend/cypress/screenshots

- name: remove docker containers
run: docker ps -aq | xargs -r docker rm -f
8 changes: 4 additions & 4 deletions .github/workflows/staging-deploy-action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'Staging-Deploy'

on:
pull_request:
types:
- closed
branches: [ main ]
# pull_request:
# types:
# - closed
# branches: [ main ]

jobs:
update-version:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ sonar-project.properties
/frontend/cypress/downloads/
/frontend/cypress/screenshots/
/toolchains.xml
/backend/src/main/resources/db/okr_schema.sql
2 changes: 1 addition & 1 deletion .run/OkrApplication-E2E.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="OkrApplication-E2E" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" value="integration-test" />
<option name="ALTERNATIVE_JRE_PATH" value="$USER_HOME$/.sdkman/candidates/java/current" />
<option name="ALTERNATIVE_JRE_PATH" value="azul-17" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<module name="backend" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ch.puzzle.okr.OkrApplication" />
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ This is an open source application for managing OKRs, developed by the team of a

This project contains two parts:

## Setup
Add subdomains to hosts file:
```shell
sudo sh -c 'echo "127.0.0.1 pitc.okr.localhost\n127.0.0.1 acme.okr.localhost" >> /etc/hosts'
```

## Frontend

[Frontend description](frontend/README.md)


## Backend
[Backend description](backend/README.md)

Expand All @@ -20,7 +27,7 @@ Path to folder from repository root `cd docker`
Type `docker-compose up` in terminal to start up the docker container, `docker-compose down` to shut the container down.

## Users
All users
All users PITC
```json
{
"gl": {
Expand Down Expand Up @@ -65,3 +72,25 @@ All users
}
}
```
All users ACME
```json
{
"gl": {
"username": "gl-acme",
"password": "gl",
"name": "Jaya Norris"
},
"bl": {
"username": "bl-acme",
"password": "bl",
"name": "Esha Harris"
},
"member": {
"username": "member-acme",
"password": "member",
"name": "Abraham Woodard"
}
}
```


7 changes: 4 additions & 3 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>ch.puzzle.okr</groupId>
<artifactId>parent</artifactId>
<version>2.0.136-SNAPSHOT</version>
<version>2.0.160-SNAPSHOT</version>
</parent>

<artifactId>backend</artifactId>
<version>2.0.136-SNAPSHOT</version>
<version>2.0.160-SNAPSHOT</version>
<name>backend</name>
<description>Puzzle OKR Tool</description>

Expand Down Expand Up @@ -107,7 +107,6 @@
<excludes>
<exclude>ch/puzzle/okr/models/**</exclude>
<exclude>ch/puzzle/okr/dto/**</exclude>
<exclude>ch/puzzle/okr/mapper/**</exclude>
<exclude>ch/puzzle/okr/OkrApplication.*</exclude>
<exclude>ch/puzzle/okr/Constants.java</exclude>
<exclude>ch/puzzle/okr/ErrorKey.java</exclude>
Expand Down Expand Up @@ -252,6 +251,8 @@
<id>build-for-docker</id>
<properties>
<maven.test.skip>true</maven.test.skip>
<maven.test.skip>true</maven.test.skip>
<maven.formatter.skip>true</maven.formatter.skip>
<spring.profiles.active>prod</spring.profiles.active>
</properties>
<build>
Expand Down
4 changes: 3 additions & 1 deletion backend/src/main/java/ch/puzzle/okr/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ private Constants() {
public static final String ACTION = "Action";
public static final String ALIGNMENT = "Alignment";
public static final String COMPLETED = "Completed";
public static final String ORGANISATION = "Organisation";
public static final String QUARTER = "Quarter";
public static final String TEAM = "Team";
public static final String USER = "User";
public static final String USER_TEAM = "UserTeam";

public static final String BACK_LOG_QUARTER_LABEL = "Backlog";
}
2 changes: 1 addition & 1 deletion backend/src/main/java/ch/puzzle/okr/ErrorKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public enum ErrorKey {
ATTRIBUTE_NULL, ATTRIBUTE_CHANGED, ATTRIBUTE_SET_FORBIDDEN, ATTRIBUTE_NOT_SET, ATTRIBUTE_CANNOT_CHANGE,
ATTRIBUTE_MUST_BE_DRAFT, KEY_RESULT_CONVERSION, ALREADY_EXISTS_SAME_NAME, CONVERT_TOKEN, DATA_HAS_BEEN_UPDATED,
MODEL_NULL, MODEL_WITH_ID_NOT_FOUND, NOT_AUTHORIZED_TO_READ, NOT_AUTHORIZED_TO_WRITE, NOT_AUTHORIZED_TO_DELETE,
TOKEN_NULL
TOKEN_NULL, TRIED_TO_DELETE_LAST_ADMIN, TRIED_TO_REMOVE_LAST_OKR_CHAMPION
}
22 changes: 22 additions & 0 deletions backend/src/main/java/ch/puzzle/okr/FlywayMultitenantConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ch.puzzle.okr;

import ch.puzzle.okr.multitenancy.FlywayMultitenantMigrationInitializer;
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FlywayMultitenantConfig {

@Bean
public FlywayMigrationStrategy cleanMigrateStrategy(FlywayMultitenantMigrationInitializer flywayMigration) {
return flyway -> flywayMigration.migrateFlyway();
}

@Bean("customKeyGenerator")
public KeyGenerator keyGenerator() {
return new UserKeyGenerator();
}

}
10 changes: 5 additions & 5 deletions backend/src/main/java/ch/puzzle/okr/OkrApplication.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package ch.puzzle.okr;

import ch.puzzle.okr.service.clientconfig.ClientCustomizationProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
@EnableConfigurationProperties(ClientCustomizationProperties.class)
public class OkrApplication {
public static void main(String[] args) {
SpringApplication.run(OkrApplication.class, args);

new SpringApplicationBuilder(OkrApplication.class) //
.initializers(new OkrApplicationContextInitializer()) //
.run(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.puzzle.okr;

import ch.puzzle.okr.multitenancy.HibernateContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OkrApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

private static final Logger logger = LoggerFactory.getLogger(OkrApplicationContextInitializer.class);

@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
logger.info("Loading hibernate configuration from application properties");
HibernateContext.extractAndSetHibernateConfig(applicationContext.getEnvironment());
}

}
Loading

0 comments on commit db6bcdf

Please sign in to comment.