Skip to content

Commit

Permalink
feat: update pipeline for java backend
Browse files Browse the repository at this point in the history
  • Loading branch information
MCatherine1994 committed Oct 31, 2022
1 parent 8dc3240 commit f163df9
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 92 deletions.
81 changes: 67 additions & 14 deletions .github/openshift/deploy.backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Template
metadata:
name: ${NAME}
annotations:
description: "Nr-Old-Growth"
description: "Nr-Forest-Client"
tags: "nrfc"
iconClass: icon-js
labels:
Expand Down Expand Up @@ -44,6 +44,21 @@ parameters:
- name: X_API_KEY
description: Key to access to the forest client api
required: true
- name: ORACLEDB_USER
description: Oracle database user name
required: true
- name: ORACLEDB_PASSWORD
description: Oracle database password
required: true
- name: ORACLEDB_DATABASE
description: Oracle database database name
required: true
- name: ORACLEDB_HOST
description: Oracle database host
required: true
- name: ORACLEDB_SERVICENAME
description: Oracle database service name
required: true
- name: NODE_ENV
description: environment mode
required: true
Expand All @@ -56,6 +71,11 @@ objects:
app: ${NAME}-${ZONE}
stringData:
x-api-key: "${X_API_KEY}"
oracle-user: "${ORACLEDB_USER}"
oracle-password: "${ORACLEDB_PASSWORD}"
oracle-database: "${ORACLEDB_DATABASE}"
oracle-host: "${ORACLEDB_HOST}"
oracle-service: "${ORACLEDB_SERVICENAME}"
- apiVersion: v1
kind: ImageStream
metadata:
Expand Down Expand Up @@ -100,22 +120,28 @@ objects:
app: ${NAME}-${ZONE}
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
spec:
volumes:
- name: ${NAME}-${ZONE}-${COMPONENT}-ora-wallet-volume
configMap:
name: ora-wallet
# items:
# - key: cwallet.sso.lck
# path: cwallet.sso.lck
containers:
- image: ${NAME}-${ZONE}-${COMPONENT}:${IMAGE_TAG}
imagePullPolicy: Always
name: ${NAME}
volumeMounts:
- name: ${NAME}-${ZONE}-${COMPONENT}-ora-wallet-volume
mountPath: "/opt/oracle/wallet/"
# subPath: cwallet.sso.lck
env:
- name: POSTGRESQL_HOST
value: ${NAME}-${ZONE}-database
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-database
key: database-name
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-database
key: database-password
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-database
key: database-user
- name: FRONTEND_URL
value: https://${NAME}-${ZONE}-frontend.${DOMAIN}
- name: BACKEND_URL
Expand All @@ -127,6 +153,33 @@ objects:
key: x-api-key
- name: API_URL
value: ${API_URL}
- name: ORACLEDB_USER
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: oracle-user
- name: ORACLEDB_PASSWORD
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: oracle-password
- name: ORACLEDB_DATABASE
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: oracle-database
- name: ORACLEDB_HOST
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: oracle-host
- name: ORACLEDB_SERVICENAME
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: oracle-service
- name: ORACLEDB_PORT
value: "1543"
- name: NODE_ENV
value: ${NODE_ENV}

Expand All @@ -145,7 +198,7 @@ objects:
path: /
port: 3000
scheme: HTTP
initialDelaySeconds: 60
initialDelaySeconds: 420
periodSeconds: 15
timeoutSeconds: 5
livenessProbe:
Expand All @@ -155,7 +208,7 @@ objects:
path: /
port: 3000
scheme: HTTP
initialDelaySeconds: 60
initialDelaySeconds: 420
periodSeconds: 30
timeoutSeconds: 5
- apiVersion: v1
Expand Down
52 changes: 32 additions & 20 deletions .github/workflows/merge-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,31 @@ jobs:
uses: github/codeql-action/analyze@v2

# # SonarCloud runs in the main branch are needed to compare against PRs
# sonarcloud:
# name: Static Analysis
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v2
# # Disable shallow clone for SonarCloud analysis
# with:
# fetch-depth: 0
sonarcloud:
name: Static Analysis
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# Disable shallow clone for SonarCloud analysis
with:
fetch-depth: 0

# - name: Backend Tests
# run: |
# cd frontend
# npm ci
# npm run test:cov
- name: Set up JDK 17 and Caching maven dependencies
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

- name: Backend Tests
run: |
cd backend
./mvnw test
# - name: Frontend Tests
# run: |
# cd frontend
# npm ci
# npm run test:cov
- name: Frontend Tests
run: |
cd frontend
npm ci
npm run test:cov
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
Expand All @@ -105,7 +110,7 @@ jobs:
needs:
- cleanup-ghcr
- codeql
# - sonarcloud
- sonarcloud
runs-on: ubuntu-22.04
environment:
name: test
Expand All @@ -126,15 +131,22 @@ jobs:
--from-literal=config.js="const config = (() => { return { VITE_BACKEND_URL: 'https://${{ env.NAME }}-${{ env.ZONE }}-backend.apps.silver.devops.gov.bc.ca', VITE_KEYCLOAK_URL: 'https://test.loginproxy.gov.bc.ca/auth', VITE_KEYCLOAK_CLIENT_ID: '${{ secrets.KEYCLOAK_CLIENT_ID }}' }; })();"
# Process and apply deployment templates
oc process -f .github/openshift/deploy.database.yml -p ZONE=${{ env.ZONE }} | oc apply -f -
oc process -f .github/openshift/deploy.backend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-backend \
-p NODE_ENV='development' \
-p API_URL='https://nrfc-api-test.api.gov.bc.ca' \
-p X_API_KEY=${{ secrets.GWA_X_API_KEY }} | oc apply -f -
-p X_API_KEY=${{ secrets.GWA_X_API_KEY }} \
-p ORACLEDB_USER=${{ secrets.ORACLEDB_USER }} \
-p ORACLEDB_PASSWORD=${{ secrets.ORACLEDB_PASSWORD }} \
-p ORACLEDB_DATABASE=${{ secrets.ORACLEDB_DATABASE }} \
-p ORACLEDB_HOST=${{ secrets.ORACLEDB_HOST }} \
-p ORACLEDB_SERVICENAME=${{ secrets.ORACLEDB_SERVICENAME }} | oc apply -f -
oc process -f .github/openshift/deploy.frontend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-frontend | oc apply -f -
# Follow any active rollouts (see deploymentconfigs)
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-database -w
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-backend -w
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-frontend -w
Expand Down
58 changes: 38 additions & 20 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,30 @@ jobs:
uses: github/codeql-action/analyze@v2

# # SonarCloud runs in the main branch are needed to compare against PRs
# sonarcloud:
# name: Static Analysis
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v2
# # Disable shallow clone for SonarCloud analysis
# with:
# fetch-depth: 0
sonarcloud:
name: Static Analysis
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# Disable shallow clone for SonarCloud analysis
with:
fetch-depth: 0

# - name: Backend Tests
# run: |
# cd frontend
# npm ci
# npm run test:cov
- name: Set up JDK 17 and Caching maven dependencies
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

# - name: Frontend Tests
# run: |
# cd frontend
# npm ci
# npm run test:cov
- name: Backend Tests
run: |
./mvnw test
- name: Frontend Tests
run: |
cd frontend
npm ci
npm run test:cov
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
Expand Down Expand Up @@ -126,15 +130,22 @@ jobs:
--from-literal=config.js="const config = (() => { return { VITE_BACKEND_URL: 'https://${{ env.NAME }}-${{ env.ZONE }}-backend.apps.silver.devops.gov.bc.ca', VITE_KEYCLOAK_URL: 'https://test.loginproxy.gov.bc.ca/auth', VITE_KEYCLOAK_CLIENT_ID: '${{ secrets.KEYCLOAK_CLIENT_ID }}' }; })();"
# Process and apply deployment templates
oc process -f .github/openshift/deploy.database.yml -p ZONE=${{ env.ZONE }} | oc apply -f -
oc process -f .github/openshift/deploy.backend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-backend \
-p NODE_ENV='development' \
-p API_URL='https://nrfc-api-test.api.gov.bc.ca' \
-p X_API_KEY=${{ secrets.GWA_X_API_KEY }} | oc apply -f -
-p X_API_KEY=${{ secrets.GWA_X_API_KEY }} \
-p ORACLEDB_USER=${{ secrets.ORACLEDB_USER }} \
-p ORACLEDB_PASSWORD=${{ secrets.ORACLEDB_PASSWORD }} \
-p ORACLEDB_DATABASE=${{ secrets.ORACLEDB_DATABASE }} \
-p ORACLEDB_HOST=${{ secrets.ORACLEDB_HOST }} \
-p ORACLEDB_SERVICENAME=${{ secrets.ORACLEDB_SERVICENAME }} | oc apply -f -
oc process -f .github/openshift/deploy.frontend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-frontend | oc apply -f -
# Follow any active rollouts (see deploymentconfigs)
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-database -w
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-backend -w
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-frontend -w
Expand Down Expand Up @@ -386,15 +397,22 @@ jobs:
--from-literal=config.js="const config = (() => { return { VITE_BACKEND_URL: 'https://${{ env.NAME }}-${{ env.ZONE }}-backend.apps.silver.devops.gov.bc.ca', VITE_KEYCLOAK_URL: 'https://test.loginproxy.gov.bc.ca/auth', VITE_KEYCLOAK_CLIENT_ID: '${{ secrets.KEYCLOAK_CLIENT_ID }}' }; })();"
# Process and apply deployment templates
oc process -f .github/openshift/deploy.database.yml -p ZONE=${{ env.ZONE }} | oc apply -f -
oc process -f .github/openshift/deploy.backend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.PREV }}-backend \
-p NODE_ENV='production' \
-p API_URL='https://nrfc-api-prod.api.gov.bc.ca' \
-p X_API_KEY=${{ secrets.GWA_X_API_KEY }} | oc apply -f -
-p X_API_KEY=${{ secrets.GWA_X_API_KEY }} \
-p ORACLEDB_USER=${{ secrets.ORACLEDB_USER }} \
-p ORACLEDB_PASSWORD=${{ secrets.ORACLEDB_PASSWORD }} \
-p ORACLEDB_DATABASE=${{ secrets.ORACLEDB_DATABASE }} \
-p ORACLEDB_HOST=${{ secrets.ORACLEDB_HOST }} \
-p ORACLEDB_SERVICENAME=${{ secrets.ORACLEDB_SERVICENAME }} | oc apply -f -
oc process -f .github/openshift/deploy.frontend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.PREV }}-frontend | oc apply -f -
# Follow any active rollouts (see deploymentconfigs)
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-database -w
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-backend -w
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-frontend -w
Expand Down
Loading

0 comments on commit f163df9

Please sign in to comment.