Skip to content

Commit

Permalink
feat: oauth refacto2 dev server (#518)
Browse files Browse the repository at this point in the history
* feat: oauth-refacto2

feat: ARA-124

* feat: add functionalities

* feat: dev

* feat: refactor oauth urls

* feat: docker compose dev works

* feat: compose works

* feat: candidate chart

* feat: chart in helm

* feat: make helm with local values

* feat: AC + CC in local

* chore: upgrade dependencies

* chore: fix ci

* fix: ci

* chore: sonar project fix

* chore: commit local config

* chore: api build with mock dev server

* chore: Fix Oauth2 Sonar Issue (#520)

Co-authored-by: regislegrand <regis.legrand.partner@decathlon.com>
Co-authored-by: TroyonGuillaume <49478724+TroyonGuillaume@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 25, 2021
1 parent 575ee29 commit 65aeb1d
Show file tree
Hide file tree
Showing 135 changed files with 1,842 additions and 7,935 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/build-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
uses: actions/setup-java@v2.1.0
with:
distribution: 'adopt'
java-version: '16'
java-version: '17'
-
name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand All @@ -72,12 +72,32 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
-
name: Add host binding
run: sudo echo "127.0.0.1 oauth2.dev.localhost" >> sudo tee -a /etc/hosts
-
name: Set up QEMU
if: ${{ steps.skip_check.outputs.docker_skip != 'true' }}
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
if: ${{ steps.skip_check.outputs.docker_skip != 'true' }}
uses: docker/setup-buildx-action@v1
-
name: start oauth2-dev-server
run: docker-compose -f code/docker-compose.dev.yaml up -d oauth2-dev-server
-
name: check oauth2-dev-server is running
run: docker run --rm --network host aligor/wait-for-url --url http://oauth2.dev.localhost:9001/actuator/health
-
name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -f code/api -B clean install org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
-
name: stop oauth2-dev-server
run: docker-compose -f code/docker-compose.dev.yaml down
-
name: Install xmllint
run: sudo apt-get install libxml2-utils
Expand Down Expand Up @@ -114,14 +134,6 @@ jobs:
fi
echo ::set-output name=push::${PUSH}
echo ::set-output name=suffix::${SUFFIX}
-
name: Set up QEMU
if: ${{ steps.skip_check.outputs.docker_skip != 'true' }}
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
if: ${{ steps.skip_check.outputs.docker_skip != 'true' }}
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
if: ${{ steps.skip_check.outputs.docker_skip != 'true' && steps.prep.outputs.push == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-core-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/setup-java@v2.2.0
with:
distribution: 'adopt'
java-version: '16'
java-version: '17'

- name: Cache SonarCloud packages
uses: actions/cache@v2.1.6
Expand Down
102 changes: 0 additions & 102 deletions .github/workflows/build-gateway.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build gateway
name: build oauth2-dev-server

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- main

jobs:
code_gw_change:
code_app_change:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
Expand All @@ -20,7 +20,7 @@ jobs:
uses: fkirc/skip-duplicate-actions@v3.4.0
with:
github_token: ${{ github.token }}
paths: '["code/gateway/**"]'
paths: '["code/oauth2-dev-server/**"]'
cancel_others: 'true'
do_not_skip: '["push", "workflow_dispatch"]'
docker_image:
Expand All @@ -35,18 +35,18 @@ jobs:
- id: skip_check
run: |
if [[ $GITHUB_REF == refs/pull/* ]]; then
GW_EXISTS=false
APP_EXISTS=false
else
pushd code
GW_EXISTS=$(make -s check-gw-image)
APP_EXISTS=$(make -s check-oads-image)
popd
fi
echo ::set-output name=should_skip::${GW_EXISTS}
build-gw:
echo ::set-output name=should_skip::${APP_EXISTS}
build-app:
needs:
- code_gw_change
- code_app_change
- docker_image
if: ${{ needs.code_gw_change.outputs.should_skip != 'true' && needs.docker_image.outputs.should_skip != 'true' }}
if: ${{ needs.code_app_change.outputs.should_skip != 'true' && needs.docker_image.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
-
Expand All @@ -59,7 +59,24 @@ jobs:
name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '16'
java-version: '17'
-
name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
-
name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
-
name: Build
run: mvn -f code/oauth2-dev-server -B clean install
-
name: Prepare
id: prep
Expand Down Expand Up @@ -98,5 +115,4 @@ jobs:
name: Build and push
run: |
cd code
make build-gw SUFFIX=${{ steps.prep.outputs.suffix }} PUBLISH=${{ steps.prep.outputs.push }}

make build-oads SUFFIX=${{ steps.prep.outputs.suffix }} PUBLISH=${{ steps.prep.outputs.push }}
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ target/
node_modules/
*dependency-reduced-pom.xml
client/*.vscode
*.old
*.old

### Containers Conf ###
.env
charts/local-values.yaml



2 changes: 1 addition & 1 deletion charts/candidate/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: ara
version: 9.4.1-rc.1
version: 10.0.0-rc.1
home: https://github.com/Decathlon/ara
description: |
ARA helps you to fight against regressions by letting it preanalyze your non-regression tests runs,
Expand Down
73 changes: 8 additions & 65 deletions charts/candidate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Create configmap name.
Secret name for database.
*/}}
{{- define "ara.database.secret.name" -}}
{{- if .Values.database.existingSecret.enabled -}}
{{ .Values.database.existingSecret.secretName }}
{{- if .Values.database.secretConfig.external -}}
{{ .Values.database.secretConfig.secretName }}
{{- else -}}
{{ printf "%s-%s-%s" .Release.Name .Chart.Name "db" }}
{{- end -}}
Expand All @@ -41,76 +41,19 @@ Secret name for database.
Secret name for api.
*/}}
{{- define "ara.api.secret.name" -}}
{{- if .Values.api.configExistingSecret.enabled -}}
{{ .Values.api.configExistingSecret.secretName }}
{{- if .Values.api.secretConfig.external -}}
{{ .Values.api.secretConfig.secretName }}
{{- else -}}
{{ printf "%s-%s-%s" .Release.Name .Chart.Name "api" }}
{{- end -}}
{{- end -}}

{{/*
Secret auth config key for api.
Define db host url
*/}}
{{- define "ara.api.secret.authconfigkey" -}}
{{- if .Values.api.configExistingSecret.enabled -}}
{{ .Values.api.configExistingSecret.authConfigKey }}
{{- else -}}
config-authentication.yaml
{{- end -}}
{{- end -}}

{{/*
Secret custom config key for api.
*/}}
{{- define "ara.api.secret.customconfigkey" -}}
{{- if .Values.api.configExistingSecret.enabled -}}
{{ .Values.api.configExistingSecret.customConfigKey }}
{{- else -}}
config-custom.yaml
{{- end -}}
{{- end -}}

{{/*
Secret username key for database.
*/}}
{{- define "ara.database.secret.usernamekey" -}}
{{- if .Values.database.existingSecret.enabled -}}
{{ .Values.database.existingSecret.usernameKey }}
{{- else -}}
db-username
{{- end -}}
{{- end -}}

{{/*
Secret password key for database.
*/}}
{{- define "ara.database.secret.passwordkey" -}}
{{- if .Values.database.existingSecret.enabled -}}
{{ .Values.database.existingSecret.passwordKey }}
{{- else -}}
db-password
{{- end -}}
{{- end -}}

{{/*
Secret database name key for database.
*/}}
{{- define "ara.database.secret.databasenamekey" -}}
{{- if .Values.database.existingSecret.enabled -}}
{{ .Values.database.existingSecret.databaseNameKey }}
{{- else -}}
db-name
{{- end -}}
{{- end -}}

{{/*
Define host url
*/}}
{{- define "ara.db.host" -}}
{{- if .Values.database.embedded -}}
mem
{{- else if not .Values.database.host -}}
{{ printf "%s-%s-db.%s.svc.cluster.local:3306" .Release.Name .Chart.Name .Release.Namespace }}
{{- define "ara.database.host" -}}
{{- if eq .Values.database.mode "cluster" -}}
{{ printf "%s-%s-db.%s.svc.cluster.local:5432" .Release.Name .Chart.Name .Release.Namespace }}
{{- else -}}
{{ .Values.database.host }}
{{- end -}}
Expand Down
9 changes: 4 additions & 5 deletions charts/candidate/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ metadata:
app.kubernetes.io/version: {{ .Chart.Version }}
app.kubernetes.io/component: configuration
data:
database_host: {{ include "ara.db.host" . | quote }}
database_type: {{ .Values.database.type }}
liquibase_active: {{ .Values.database.liquibaseActive | quote }}
logging_mode: {{ include "ara.api.loggingmode" . | quote }}
oauth2_mode: {{ .Values.api.authentication }}
app_url: {{ .Values.api.appUrl }}
ui_port: {{ printf "%.0f" .Values.ui.port | quote }}
api_host: {{ printf "%s-%s-api.%s.svc.cluster.local" .Release.Name .Chart.Name .Release.Namespace }}
api_port: {{ printf "%.0f" .Values.api.port | quote }}
api_management_port: {{ printf "%.0f" .Values.api.management.port | quote }}

{{- if not .Values.api.configExistingSecret.enabled }}
{{- if not .Values.api.secretConfig.external }}
---
apiVersion: v1
kind: Secret
Expand All @@ -34,8 +35,6 @@ metadata:
app.kubernetes.io/component: api-secret
type: Opaque
stringData:
{{ template "ara.api.secret.authconfigkey" }}: |
{{ toYaml .Values.api.authConfig | indent 4 }}
{{ template "ara.api.secret.customconfigkey" }}: |
{{ .Values.api.secretConfig.customConfigKey }}: |
{{ toYaml .Values.api.customConfig | indent 4 }}
{{- end }}
Loading

0 comments on commit 65aeb1d

Please sign in to comment.