Skip to content

Commit

Permalink
Merge pull request #899 from puzzle/main
Browse files Browse the repository at this point in the history
Release 2.0.1
  • Loading branch information
lkleisa authored Apr 29, 2024
2 parents 6dae89a + f499ca8 commit c6cd315
Show file tree
Hide file tree
Showing 46 changed files with 1,800 additions and 1,058 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/addIssueToProject.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v0.5.0
- uses: actions/add-to-project@v1.0.1
with:
project-url: https://github.com/orgs/puzzle/projects/3
github-token: ${{ secrets.ADD_ISSUE_TO_PROJECT_CLASSIC }}
32 changes: 7 additions & 25 deletions .github/workflows/deploy-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,42 +97,24 @@ jobs:
- name: Push
run: docker push ${{ needs.extract-version.outputs.okr-docker-image}}

- name: Trigger Deployment Workflow with latest Version
uses: actions/checkout@v4
with:
repository: ${{ vars.TARGET_REPOSITORY }}
ref: ${{ vars.TARGET_REFERENCE }}
path: ccy-repo
token: ${{secrets.VERSION_TOKEN}}

- name: Change Yaml
- name: Install yq
shell: bash
env:
FILEPATH: ${{ vars.FILEPATH }}
YAMLPATH: ${{ vars.YAML_PATH }}
NEWVALUE: ${{ needs.extract-version.outputs.okr-docker-image}}
VERSION: v4.25.2
BINARY: yq_linux_amd64
run: |
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
tar xz && mv ${BINARY} /usr/local/bin/yq
yq -i "${YAMLPATH} = \"${NEWVALUE}\"" ccy-repo/${FILEPATH}
- name: Commit and Push Changes
working-directory: ccy-repo
- name: Update YAML file
shell: bash
env:
COMMITPREFIX: '[CTS]'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add ${{ vars.FILEPATH }} || {
echo "No files were changed, so we did not commit anything"
exit 1
} && \
git commit -m "$COMMITPREFIX Automated changes to ${{ vars.FILEPATH }}" && \
git push origin ${{ vars.TARGET_REFERENCE }}
- run: rm -rf ccy-repo
shell: bash
curl -s --header "PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml
yq -i "${{vars.YAML_PATH}} = \"${{needs.extract-version.outputs.okr-docker-image}}\"" response.yaml
UPDATED_CONTENT=$(cat response.yaml)
curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}"
generate-and-push-sbom:
runs-on: ubuntu-latest
Expand Down
32 changes: 6 additions & 26 deletions .github/workflows/staging-deploy-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,44 +179,24 @@ jobs:
- name: Push
run: docker push ${{ needs.update-version.outputs.okr-docker-image}}

- name: Trigger Deployment Workflow with latest Version
uses: actions/checkout@v4
with:
repository: ${{ vars.TARGET_REPOSITORY }}
ref: ${{ vars.TARGET_REFERENCE }}
path: ccy-repo
token: ${{secrets.VERSION_TOKEN}}

- name: Change Yaml
- name: Install yq
shell: bash
env:
FILEPATH: ${{ vars.FILEPATH }}
YAMLPATH: ${{ vars.YAML_PATH }}
NEWVALUE: ${{ needs.update-version.outputs.okr-docker-image}}
VERSION: v4.25.2
BINARY: yq_linux_amd64
run: |
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
tar xz && mv ${BINARY} /usr/local/bin/yq
yq -i "${YAMLPATH} = \"${NEWVALUE}\"" ccy-repo/${FILEPATH}
- name: Commit and Push Changes
working-directory: ccy-repo
- name: Update YAML file
shell: bash
env:
COMMITPREFIX: '[CTS]'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add ${{ vars.FILEPATH }} || {
echo "No files were changed, so we did not commit anything"
exit 1
} && \
git commit -m "$COMMITPREFIX Automated changes to ${{ vars.FILEPATH }}" && \
git push origin ${{ vars.TARGET_REFERENCE }}
- run: rm -rf ccy-repo
shell: bash
curl -s --header "PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml
yq -i "${{vars.YAML_PATH}} = \"${{needs.update-version.outputs.okr-docker-image}}\"" response.yaml
UPDATED_CONTENT=$(cat response.yaml)
curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}"
generate-and-push-sbom:
runs-on: ubuntu-latest
Expand Down
16 changes: 8 additions & 8 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.39-SNAPSHOT</version>
<version>2.0.112-SNAPSHOT</version>
</parent>

<artifactId>backend</artifactId>
<version>2.0.39-SNAPSHOT</version>
<version>2.0.112-SNAPSHOT</version>
<name>backend</name>
<description>Puzzle OKR Tool</description>

Expand Down Expand Up @@ -54,17 +54,17 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.3.0</version>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>10.6.0</version>
<version>10.11.1</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
<version>10.6.0</version>
<version>10.11.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand All @@ -78,13 +78,13 @@
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>1.2.1</version>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.1</version>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -102,7 +102,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<version>0.8.12</version>
<configuration>
<excludes>
<exclude>ch/puzzle/okr/models/**</exclude>
Expand Down
3 changes: 3 additions & 0 deletions backend/src/main/java/ch/puzzle/okr/OkrApplication.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
@EnableConfigurationProperties(ClientCustomizationProperties.class)
public class OkrApplication {
public static void main(String[] args) {
SpringApplication.run(OkrApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package ch.puzzle.okr.controller;

import ch.puzzle.okr.service.ClientConfigService;
import ch.puzzle.okr.dto.ClientConfigDto;
import ch.puzzle.okr.service.clientconfig.ClientConfigService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/config")
public class ClientConfigController {
Expand All @@ -20,7 +19,7 @@ public ClientConfigController(ClientConfigService configService) {
}

@GetMapping
public ResponseEntity<Map<String, String>> getConfig() {
public ResponseEntity<ClientConfigDto> getConfig() {
return ResponseEntity.status(HttpStatus.OK).body(configService.getConfigBasedOnActiveEnv());
}
}
7 changes: 7 additions & 0 deletions backend/src/main/java/ch/puzzle/okr/dto/ClientConfigDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ch.puzzle.okr.dto;

import java.util.HashMap;

public record ClientConfigDto(String activeProfile, String issuer, String clientId, String favicon, String logo,
String title, HashMap<String, String> customStyles) {
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ch.puzzle.okr.service.clientconfig;

import ch.puzzle.okr.dto.ClientConfigDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class ClientConfigService {

@Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}")
private String issuer;

@Value("${spring.profiles.active}")
private String activeProfile;

@Value("${spring.security.oauth2.resourceserver.opaquetoken.client-id}")
private String clientId;

private final ClientCustomizationProperties clientCustomizationProperties;

public ClientConfigService(ClientCustomizationProperties clientCustomizationProperties) {
this.clientCustomizationProperties = clientCustomizationProperties;
}

public ClientConfigDto getConfigBasedOnActiveEnv() {
return new ClientConfigDto(activeProfile, issuer, clientId, this.clientCustomizationProperties.getFavicon(),
this.clientCustomizationProperties.getLogo(), this.clientCustomizationProperties.getTitle(),
this.clientCustomizationProperties.getCustomStyles());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ch.puzzle.okr.service.clientconfig;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;

@ConfigurationProperties("okr.clientcustomization")
public class ClientCustomizationProperties {
private String favicon;
private String logo;
private String title;
private HashMap<String, String> customStyles = new HashMap<>();

public void setCustomStyles(HashMap<String, String> customStyles) {
this.customStyles = customStyles;
}

public String getFavicon() {
return favicon;
}

public void setFavicon(String favicon) {
this.favicon = favicon;
}

public String getLogo() {
return logo;
}

public void setLogo(String logo) {
this.logo = logo;
}

public HashMap<String, String> getCustomStyles() {
return customStyles;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}
}
3 changes: 3 additions & 0 deletions backend/src/main/resources/application-staging.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# logging level for staging
logging.level.org.springframework=debug

spring.security.oauth2.resourceserver.opaquetoken.client-id=pitc_okr_staging

okr.user.champion.usernames=peggimann
okr.clientcustomization.customstyles.okr-topbar-background-color=#ab31ad
4 changes: 4 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ okr.jwt.user.username=preferred_username
okr.jwt.user.firstname=given_name
okr.jwt.user.lastname=family_name
okr.jwt.user.email=email

okr.clientcustomization.favicon=assets/favicon.png
okr.clientcustomization.logo=assets/images/okr-logo.svg
okr.clientcustomization.title=Puzzle OKR
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ values (21, 1,
13, 1, 31, 3, 'metric', null);

insert into quarter (id, label, start_date, end_date)
values (8, 'GJ 23/24-Q3', '2024-01-01', '2024-03-31');
values (8, 'GJ 23/24-Q3', '2024-01-01', '2024-03-31'),
(9, 'GJ 23/24-Q4', '2024-04-01', '2024-06-30'),
(10, 'GJ 24/25-Q1', '2024-07-01', '2024-09-30');

delete
from team_organisation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ values (1, 'GJ 22/23-Q4', '2023-04-01', '2023-06-30'),
(6, 'GJ 21/22-Q4', '2022-04-01', '2022-06-30'),
(7, 'GJ 23/24-Q2', '2023-10-01', '2023-12-31'),
(8, 'GJ 23/24-Q3', '2024-01-01', '2024-03-31'),
(9, 'GJ 23/24-Q4', '2024-04-01', '2024-06-30'),
(199, 'Backlog', null, null);

insert into team (id, version, name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ch.puzzle.okr.controller;

import ch.puzzle.okr.service.ClientConfigService;
import ch.puzzle.okr.service.clientconfig.ClientConfigService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down
Loading

0 comments on commit c6cd315

Please sign in to comment.