Skip to content

Commit

Permalink
fix(application): use channel in version link
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomgrus committed Dec 20, 2021
1 parent b62fadf commit 721ffb2
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 48 deletions.
30 changes: 13 additions & 17 deletions .github/workflows/build-core-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ on:
- main

jobs:
code_app_change:
name: Code core-api Change Detection
build-core-api:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v3.4.0
Expand All @@ -23,38 +19,38 @@ jobs:
paths: '["code/core-api/**", ".github/workflows/build-core-api.yaml"]'
cancel_others: 'true'
do_not_skip: '["push", "workflow_dispatch"]'
build-core-api:
name: Tests, Analysis and Build
needs: code_app_change
if: ${{ needs.code_app_change.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- if: ${{ steps.skip_check.outputs.should_skip }}
uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK
- if: ${{ steps.skip_check.outputs.should_skip }}
name: Set up JDK
uses: actions/setup-java@v2.3.1
with:
distribution: 'adopt'
java-version: '17'
cache: 'maven'

- name: Cache SonarCloud packages
- if: ${{ steps.skip_check.outputs.should_skip }}
name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build, unit test and analyze
- if: ${{ steps.skip_check.outputs.should_skip }}
name: Build, unit test and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -f code/core-api/ -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

- name: Set up Docker Buildx
- if: ${{ steps.skip_check.outputs.should_skip }}
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build image
- if: ${{ steps.skip_check.outputs.should_skip }}
name: Build image
run: mvn -f code/core-api/ spring-boot:build-image -Dmaven.test.skip=true -Dspring-boot.build-image.imageName=decathlon/ara-core-api:${{ github.sha }}
39 changes: 11 additions & 28 deletions .github/workflows/build-oauth2-dev-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ on:
branches:
- main

jobs:
code_app_change:
# continue-on-error: true # Uncomment once integration is finished
jobs:
build-oauth2-dev-server:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v3.4.0
Expand All @@ -23,35 +19,23 @@ jobs:
paths: '["code/oauth2-dev-server/**", ".github/workflows/build-oauth2-dev-server.yaml"]'
cancel_others: 'true'
do_not_skip: '["push", "workflow_dispatch"]'
build-oauth2-dev-server:
needs: code_app_change
if: ${{ needs.code_app_change.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Checkout
uses: actions/checkout@v2
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Install xmllint
run: sudo apt-get install libxml2-utils
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Set up JDK
uses: actions/setup-java@v2.3.1
with:
distribution: 'adopt'
java-version: '17'
cache: 'maven'
-
name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Build
run: mvn -f code/oauth2-dev-server -B clean install
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Prepare
id: prep
run: |
Expand All @@ -75,20 +59,19 @@ jobs:
fi
echo ::set-output name=push::${PUSH}
echo ::set-output name=suffix::${SUFFIX}
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' && steps.prep.outputs.push == 'true'}}
name: Login to DockerHub
if: ${{ steps.prep.outputs.push == 'true' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Build and push
run: |
cd code
Expand Down
8 changes: 8 additions & 0 deletions charts/candidate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart channel.
*/}}
{{- define "ara.channel" -}}
{{- $parts := split "-" .Chart.Name -}}
{{ $parts._1 }}
{{- end -}}

{{/*
Create configmap name.
*/}}
Expand Down
8 changes: 8 additions & 0 deletions charts/candidate/templates/deploy-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,18 @@ spec:
configMapKeyRef:
name: {{ include "ara.configmap.name" . }}
key: oauth2_mode
{{- if eq .Values.api.authentication "oauth2-mock" }}
- name: SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI
value: {{ printf "http://%s-oauth2-mock.%s.svc.cluster.local:9000" .Release.Name .Release.Namespace }}
- name: SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_SPRING_ISSUERURI
value: {{ printf "http://%s-oauth2-mock.%s.svc.cluster.local:9000" .Release.Name .Release.Namespace }}
{{- end }}
- name: SPRING_CONFIG_IMPORT
value: optional:file:/app/config/config-custom.yaml,optional:file:/app/config/config-authentication.yaml
- name: INFO_APP_VERSION
value: "{{ .Chart.Version }}"
- name: INFO_APP_CHANNEL
value: {{ include "ara.channel" . | quote }}
volumeMounts:
- name: config
mountPath: "/app/config"
Expand Down
6 changes: 4 additions & 2 deletions charts/candidate/templates/oauth2-mock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ spec:
spec:
containers:
- name: {{ $name }}
image: "decathlon/ara-oads:1.0.0"
image: "decathlon/ara-oads:1.1.0"
imagePullPolicy: IfNotPresent
env:
- name: CLIENT_URL
valueFrom:
configMapKeyRef:
name: {{ include "ara.configmap.name" . }}
key: app_url
- name: PROVIDER_URL
value: {{ printf "http://%s-oauth2-mock.%s.svc.cluster.local:9000" .Release.Name .Release.Namespace }}
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 9000
port: 9001
initialDelaySeconds: 40
timeoutSeconds: 2
periodSeconds: 3
Expand Down
1 change: 1 addition & 0 deletions code/api/api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
info:
app:
version: version
channel: main
api:
version: @project.version@

Expand Down
10 changes: 9 additions & 1 deletion code/web-ui/src/components/top-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
</DropdownMenu>
</Dropdown>
<Tooltip content="What's new in ARA?" placement="bottom-end" :transfer="false">
<a :href="$sanitizeUrl('https://github.com/Decathlon/ara/releases/tag/ara-' + appVersion)"
<a :href="$sanitizeUrl('https://github.com/Decathlon/ara/releases/tag/ara-' + channel + '-v' + appVersion)"
@click="setLatestChangelogVersion"
rel="noopener" target="_blank"><Badge dot :count="changelogCount"><Icon type="md-notifications" size="24"/></Badge></a>
</Tooltip>
Expand Down Expand Up @@ -193,6 +193,7 @@
]
},
appVersion: undefined,
channel: undefined,
apiVersion: undefined,
webUIVersion: process.env.VERSION,
latestChangelogVersion: this.getCookie(LATEST_CHANGELOG_VERSION_COOKIE_NAME),
Expand Down Expand Up @@ -353,6 +354,12 @@
}
},

extractChannel (data) {
if (data?.hasOwnProperty('app')) {
return data['app'].channel
}
},

logout () {
AuthenticationService.logout()
}
Expand All @@ -365,6 +372,7 @@
.then((response) => {
const data = response?.data
this.appVersion = this.extractVersion(data, 'app')
this.channel = this.extractChannel(data)
this.apiVersion = this.extractVersion(data, 'api')
// If it is the first time the user opens ARA, make sure to remember the current version for future notification badge
if (!this.latestChangelogVersion) {
Expand Down

0 comments on commit 721ffb2

Please sign in to comment.