From d5a2d91c4a9d4fcfca4241a738341c615b88ea9c Mon Sep 17 00:00:00 2001 From: Kuan Fan <31664961+kuanfandevops@users.noreply.github.com> Date: Fri, 11 Oct 2024 14:57:35 -0700 Subject: [PATCH] Tracking pull request to merge release-1.62.0 to master (#2283) * fix: 2298 - extraneous data on new credit transfer page (#2299) --------- Co-authored-by: Roger Leung <60829068+rogerlcleung@users.noreply.github.com> Co-authored-by: tim738745 <98717409+tim738745@users.noreply.github.com> --- .github/workflows/dev-build.yaml | 10 +- .github/workflows/dev-ci.yaml | 57 ++++-- .github/workflows/pr-build.yaml | 191 ++++++++++++++++++ .github/workflows/pr-label.yaml | 22 -- .github/workflows/pr-teardown.yaml | 35 ++-- .github/workflows/release-build.yaml | 8 +- .github/workflows/test-ci.yaml | 37 ++-- README.md | 25 +-- backend/Dockerfile | 4 +- backend/api/viewsets/organization.py | 9 +- frontend/package.json | 2 +- .../templates/backend/backend-bc-docker.yaml | 14 +- .../frontend/frontend-bc-docker.yaml | 91 ++++----- 13 files changed, 353 insertions(+), 152 deletions(-) create mode 100644 .github/workflows/pr-build.yaml delete mode 100644 .github/workflows/pr-label.yaml diff --git a/.github/workflows/dev-build.yaml b/.github/workflows/dev-build.yaml index 45e2c5054..90a36479a 100644 --- a/.github/workflows/dev-build.yaml +++ b/.github/workflows/dev-build.yaml @@ -1,11 +1,11 @@ ## For each release, please update the value of workflow name, branches and PR_NUMBER ## Also update frontend/package.json version -name: Dev Build 1.61.0 +name: Dev Build 1.62.0 on: push: - branches: [release-1.61.0] + branches: [release-1.62.0] paths: - frontend/** - backend/** @@ -14,8 +14,8 @@ on: env: ## The pull request number of the Tracking pull request to merge the release branch to main - PR_NUMBER: 2270 - VERSION: 1.61.0 + PR_NUMBER: 2283 + VERSION: 1.62.0 GIT_URL: https://github.com/bcgov/zeva.git TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev @@ -30,7 +30,7 @@ jobs: call-unit-test: uses: ./.github/workflows/unit-test-template.yaml with: - pr-number: 2270 + pr-number: 2283 build: name: Build ZEVA on Openshift diff --git a/.github/workflows/dev-ci.yaml b/.github/workflows/dev-ci.yaml index ac38e3b1a..e0770a0c2 100644 --- a/.github/workflows/dev-ci.yaml +++ b/.github/workflows/dev-ci.yaml @@ -1,17 +1,17 @@ ## For each release, the value of workflow name, branches and VERSION need to be adjusted accordingly -name: Zeva new-pipeline-1.61.0 Dev CI +name: Zeva new-pipeline-1.62.0 Dev CI on: - # push: - # branches: [ new-pipeline-1.61.0 ] - # paths: - # - frontend/** - # - backend/** + push: + branches: [release-1.62.0] + paths: + - frontend/** + - backend/** workflow_dispatch: env: - VERSION: 1.61.0 + VERSION: 1.62.0 GIT_URL: https://github.com/bcgov/zeva.git TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev @@ -30,7 +30,8 @@ jobs: steps: - id: set-pre-release - run: echo "PRE_RELEASE=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT + run: | + echo "PRE_RELEASE=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT build-backend: name: Build Zeva Backend @@ -56,9 +57,15 @@ jobs: - name: Build Zeva Backend run: | cd openshift/templates/backend - oc process -f ./backend-bc-docker.yaml NAME=zeva SUFFIX=-${{ env.VERSION }}-${{ env.PRE_RELEASE }} VERSION=${{ env.VERSION }}-${{ env.PRE_RELEASE }} GIT_URL=${{ env.GIT_URL }} GIT_REF=new-pipeline-${{ env.VERSION }} | oc apply --wait=true -f - -n ${{ env.TOOLS_NAMESPACE }} - sleep 5s - oc -n ${{ env.TOOLS_NAMESPACE }} wait --for=condition=Complete --timeout=900s build/zeva-backend-${{ env.VERSION }}-${{ env.PRE_RELEASE }}-1 + oc process -f ./backend-bc-docker.yaml NAME=zeva SUFFIX=-${{ env.VERSION }}-${{ env.PRE_RELEASE }} VERSION=${{ env.VERSION }}-${{ env.PRE_RELEASE }} GIT_URL=${{ env.GIT_URL }} GIT_REF=release-${{ env.VERSION }} | oc apply --wait=true -f - -n ${{ env.TOOLS_NAMESPACE }} + sleep 2s + for build in $(oc -n ${{ env.TOOLS_NAMESPACE }} get builds -l buildconfig=zeva-backend-${{ env.VERSION }}-${{ env.PRE_RELEASE }} -o jsonpath='{.items[?(@.status.phase=="Running")].metadata.name}'); do + echo "canceling $build" + oc -n ${{ env.TOOLS_NAMESPACE }} cancel-build $build + done + sleep 2s + oc -n ${{ env.TOOLS_NAMESPACE }} start-build zeva-backend-${{ env.VERSION }}-${{ env.PRE_RELEASE }} --wait=true + sleep 2s oc tag ${{ env.TOOLS_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.DEV_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} build-frontend: @@ -85,9 +92,15 @@ jobs: - name: Build ZEVA Frontend run: | cd openshift/templates/frontend - oc process -f ./frontend-bc-docker.yaml NAME=zeva SUFFIX=-${{ env.VERSION }}-${{ env.PRE_RELEASE }} VERSION=${{ env.VERSION }}-${{ env.PRE_RELEASE }} GIT_URL=${{ env.GIT_URL }} GIT_REF=new-pipeline-${{ env.VERSION }} | oc apply --wait=true -f - -n ${{ env.TOOLS_NAMESPACE }} - sleep 5s - oc -n ${{ env.TOOLS_NAMESPACE }} wait --for=condition=Complete --timeout=900s build/zeva-frontend-${{ env.VERSION }}-${{ env.PRE_RELEASE }}-1 + oc process -f ./frontend-bc-docker.yaml NAME=zeva SUFFIX=-${{ env.VERSION }}-${{ env.PRE_RELEASE }} VERSION=${{ env.VERSION }}-${{ env.PRE_RELEASE }} GIT_URL=${{ env.GIT_URL }} GIT_REF=release-${{ env.VERSION }} | oc apply --wait=true -f - -n ${{ env.TOOLS_NAMESPACE }} + sleep 2s + for build in $(oc -n ${{ env.TOOLS_NAMESPACE }} get builds -l buildconfig=zeva-frontend-${{ env.VERSION }}-${{ env.PRE_RELEASE }} -o jsonpath='{.items[?(@.status.phase=="Running")].metadata.name}'); do + echo "canceling $build" + oc -n ${{ env.TOOLS_NAMESPACE }} cancel-build $build + done + sleep 2s + oc -n ${{ env.TOOLS_NAMESPACE }} start-build zeva-frontend-${{ env.VERSION }}-${{ env.PRE_RELEASE }} --wait=true + sleep 2s oc tag ${{ env.TOOLS_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.DEV_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} deploy: @@ -121,3 +134,19 @@ jobs: git add zeva/values-dev.yaml git commit -m "Update the image tag to ${{ env.VERSION }}-${{ env.PRE_RELEASE }} on Dev" git push + + - name: Log in to Openshift + uses: redhat-actions/oc-login@v1.3 + with: + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} + openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} + insecure_skip_tls_verify: true + namespace: ${{ env.TOOLS_NAMESPACE }} + + - name: Tag and deploy to Dev + run: | + helm -n ${{ env.DEV_NAMESPACE }} list + oc tag ${{ env.TOOLS_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.DEV_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} + oc tag ${{ env.TOOLS_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.DEV_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} + cd zeva + helm -n ${{ env.DEV_NAMESPACE }} -f ./values-dev.yaml upgrade --install zeva-dev . diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml new file mode 100644 index 000000000..1e2c0f30d --- /dev/null +++ b/.github/workflows/pr-build.yaml @@ -0,0 +1,191 @@ +name: PR Build on Dev + +on: + pull_request: + types: [labeled, synchronize] + paths: + - frontend/** + - backend/** + +env: + GIT_URL: https://github.com/bcgov/zeva.git + TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools + DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev + PR_NUMBER: ${{ github.event.pull_request.number }} + GIT_REF: ${{ github.event.pull_request.head.ref }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + get-version: + if: > + (github.event.action == 'labeled' && github.event.label.name == 'build' && github.event.pull_request.base.ref == github.event.repository.default_branch) || + (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'build') && github.event.pull_request.base.ref == github.event.repository.default_branch) + name: Retrieve version + runs-on: ubuntu-latest + + outputs: + output1: ${{ steps.get-version.outputs.VERSION }} + + steps: + - name: Log in to Openshift + uses: redhat-actions/oc-login@v1.3 + with: + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} + openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} + insecure_skip_tls_verify: true + namespace: ${{ env.TOOLS_NAMESPACE }} + + - id: get-version + run: | + pr_deployed=$(helm -n ${{ env.DEV_NAMESPACE }} list | grep zeva-frontend-dev- | wc -l | tr -d '[:space:]') + if [ "$pr_deployed" -gt 1 ]; then + echo "There are at least 2 pull requests have been deployed on dev. Please uninstalled one of them in order to to have space to deploy this pull request. Exiting with code 99" + exit 99 + else + echo "There are $pr_deployed pull request builds on dev. Will deploy a new one." + version=$(echo "${{ github.event.repository.default_branch }}" | sed -E 's/release-(.*)/\1/') + echo "VERSION=$version" >> $GITHUB_OUTPUT + fi + + build-backend: + if: > + (github.event.action == 'labeled' && github.event.label.name == 'build' && github.event.pull_request.base.ref == github.event.repository.default_branch) || + (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'build') && github.event.pull_request.base.ref == github.event.repository.default_branch) + name: Build ZEVA Backend + runs-on: ubuntu-latest + needs: [get-version] + timeout-minutes: 60 + + env: + VERSION: ${{ needs.get-version.outputs.output1 }} + + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Log in to Openshift + uses: redhat-actions/oc-login@v1.3 + with: + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} + openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} + insecure_skip_tls_verify: true + namespace: ${{ env.TOOLS_NAMESPACE }} + + - name: Build ZEVA Backend + run: | + cd openshift/templates/backend + oc process -f ./backend-bc-docker.yaml NAME=zeva SUFFIX=-${{ env.VERSION }}-${{ env.PR_NUMBER }} VERSION=${{ env.VERSION }}-${{ env.PR_NUMBER }} GIT_URL=${{ env.GIT_URL }} GIT_REF=${{ env.GIT_REF }} | oc apply --wait=true -f - -n ${{ env.TOOLS_NAMESPACE }} + sleep 2s + for build in $(oc -n ${{ env.TOOLS_NAMESPACE }} get builds -l buildconfig=zeva-backend-${{ env.VERSION }}-${{ env.PR_NUMBER }} -o jsonpath='{.items[?(@.status.phase=="Running")].metadata.name}'); do + echo "canceling $build" + oc -n ${{ env.TOOLS_NAMESPACE }} cancel-build $build + done + sleep 2s + oc -n ${{ env.TOOLS_NAMESPACE }} start-build zeva-backend-${{ env.VERSION }}-${{ env.PR_NUMBER }} --wait=true + sleep 2s + oc tag ${{ env.TOOLS_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PR_NUMBER }} ${{ env.DEV_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PR_NUMBER }} + + build-frontend: + if: > + (github.event.action == 'labeled' && github.event.label.name == 'build' && github.event.pull_request.base.ref == github.event.repository.default_branch) || + (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'build') && github.event.pull_request.base.ref == github.event.repository.default_branch) + name: Build ZEVA Frontend + runs-on: ubuntu-latest + needs: [get-version] + timeout-minutes: 60 + + env: + VERSION: ${{ needs.get-version.outputs.output1 }} + + steps: + - name: Check out repository + uses: actions/checkout@v4.1.1 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Log in to Openshift + uses: redhat-actions/oc-login@v1.3 + with: + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} + openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} + insecure_skip_tls_verify: true + namespace: ${{ env.TOOLS_NAMESPACE }} + + - name: Build ZEVA Frontend + run: | + cd openshift/templates/frontend + oc process -f ./frontend-bc-docker.yaml NAME=zeva SUFFIX=-${{ env.VERSION }}-${{ env.PR_NUMBER }} VERSION=${{ env.VERSION }}-${{ env.PR_NUMBER }} GIT_URL=${{ env.GIT_URL }} GIT_REF=${{ env.GIT_REF }} | oc apply --wait=true -f - -n ${{ env.TOOLS_NAMESPACE }} + sleep 2s + for build in $(oc -n ${{ env.TOOLS_NAMESPACE }} get builds -l buildconfig=zeva-frontend-${{ env.VERSION }}-${{ env.PR_NUMBER }} -o jsonpath='{.items[?(@.status.phase=="Running")].metadata.name}'); do + echo "canceling $build" + oc -n ${{ env.TOOLS_NAMESPACE }} cancel-build $build + done + sleep 2s + oc -n ${{ env.TOOLS_NAMESPACE }} start-build zeva-frontend-${{ env.VERSION }}-${{ env.PR_NUMBER }} --wait=true + sleep 2s + oc tag ${{ env.TOOLS_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PR_NUMBER }} ${{ env.DEV_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PR_NUMBER }} + + deploy: + if: > + (github.event.action == 'labeled' && github.event.label.name == 'build' && github.event.pull_request.base.ref == github.event.repository.default_branch) || + (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'build') && github.event.pull_request.base.ref == github.event.repository.default_branch) + name: Deploy ZEVA + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: [get-version, build-backend, build-frontend] + + env: + VERSION: ${{ needs.get-version.outputs.output1 }} + + steps: + - name: Checkout Manifest repository + uses: actions/checkout@v4.1.1 + with: + repository: bcgov-c/tenant-gitops-e52f12 + ref: main + ssh-key: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }} + + - name: Replace VERSION in values-dev-pr.yaml + uses: jacobtomlinson/gha-find-replace@v3 + with: + find: "VERSION" + replace: "${{ env.VERSION }}" + include: "zeva/values-dev-pr.yaml" + regex: false + + - name: Replace PRNUMBER in values-dev-pr.yaml + uses: jacobtomlinson/gha-find-replace@v3 + with: + find: "PRNUMBER" + replace: "${{ env.PR_NUMBER }}" + include: "zeva/values-dev-pr.yaml" + regex: false + + - name: Log in to Openshift + uses: redhat-actions/oc-login@v1.3 + with: + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} + openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} + insecure_skip_tls_verify: true + namespace: ${{ env.TOOLS_NAMESPACE }} + + - name: Helm Deployment + shell: bash {0} + run: | + pwd + ls -l + cat zeva/values-dev-pr.yaml + + - name: Helm Deployment + shell: bash {0} + run: | + cd postgres-pr + helm -n ${{ env.DEV_NAMESPACE }} -f ./values-dev-pr.yaml upgrade --install zeva-dev-${{ env.PR_NUMBER }}-postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --version 15.5.17 + sleep 60s + cd ../zeva + helm -n ${{ env.DEV_NAMESPACE }} -f ./values-dev-pr.yaml upgrade --install zeva-dev-${{ env.PR_NUMBER }} . diff --git a/.github/workflows/pr-label.yaml b/.github/workflows/pr-label.yaml deleted file mode 100644 index 1ba0d70d6..000000000 --- a/.github/workflows/pr-label.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Label PR - -on: - pull_request: - types: labeled - branches: - - 'release-*' - -jobs: - - automerge: - runs-on: ubuntu-latest - steps: - - id: automerge - name: automerge - uses: "pascalgn/automerge-action@v0.15.6" - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - MERGE_METHOD: squash - LOG: DEBUG - - diff --git a/.github/workflows/pr-teardown.yaml b/.github/workflows/pr-teardown.yaml index 3299b1d3e..2c0b82381 100644 --- a/.github/workflows/pr-teardown.yaml +++ b/.github/workflows/pr-teardown.yaml @@ -1,34 +1,37 @@ -name: Teardown PR on Dev +name: PR Teardown on Dev on: pull_request: - types: closed + types: [unlabeled, closed] env: - TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev + PR_NUMBER: ${{ github.event.pull_request.number }} -jobs: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true - teardown-on-dev: - if: endsWith( github.event.pull_request.title, 'build-on-dev' ) - name: Tear ZEVA down on Dev +jobs: + teardown: + if: > + (github.event.action == 'unlabeled' && github.event.label.name == 'build') || + (github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'build') ) + name: PR Teardown runs-on: ubuntu-latest - timeout-minutes: 20 - - steps: + timeout-minutes: 60 + steps: - name: Log in to Openshift uses: redhat-actions/oc-login@v1.3 with: openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} insecure_skip_tls_verify: true - namespace: ${{ env.TOOLS_NAMESPACE }} + namespace: ${{ env.DEV_NAMESPACE }} - - name: Undeploy on Dev - shell: bash {0} + - name: Teardown the pull request run: | - helm -n ${{ env.DEV_NAMESPACE }} uninstall zeva-backend-dev-${{ github.event.pull_request.number }} || true - helm -n ${{ env.DEV_NAMESPACE }} uninstall zeva-frontend-dev-${{ github.event.pull_request.number }} || true - helm -n ${{ env.DEV_NAMESPACE }} uninstall zeva-spilo-dev-${{ github.event.pull_request.number }} || true + helm -n ${{ env.DEV_NAMESPACE }} uninstall zeva-dev-${{ env.PR_NUMBER }} + helm -n ${{ env.DEV_NAMESPACE }} uninstall zeva-dev-${{ env.PR_NUMBER }}-postgresql + oc -n ${{ env.DEV_NAMESPACE }} delete pvc -l app.kubernetes.io/instance=zeva-dev-${{ env.PR_NUMBER }}-postgresql diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index 02c17aa7d..03c9125ca 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -1,7 +1,7 @@ ## For each release, please update the value of workflow name, branches and PR_NUMBER ## Also update frontend/package.json version -name: Release Build 1.61.0 +name: Release Build 1.62.0 on: workflow_dispatch: @@ -9,8 +9,8 @@ on: env: ## The pull request number of the Tracking pull request to merge the release branch to main - PR_NUMBER: 2270 - VERSION: 1.61.0 + PR_NUMBER: 2283 + VERSION: 1.62.0 GIT_URL: https://github.com/bcgov/zeva.git TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev @@ -25,7 +25,7 @@ jobs: call-unit-test: uses: ./.github/workflows/unit-test-template.yaml with: - pr-number: 2270 + pr-number: 2283 build: name: Build ZEVA on Openshift diff --git a/.github/workflows/test-ci.yaml b/.github/workflows/test-ci.yaml index c27ceaceb..e19b197fa 100644 --- a/.github/workflows/test-ci.yaml +++ b/.github/workflows/test-ci.yaml @@ -1,12 +1,12 @@ ## For each release, the value of workflow name, branches and VERSION need to be adjusted accordingly -name: ZEVA new-pipeline-1.61.0 Test CI +name: ZEVA new-pipeline-1.62.0 Test CI on: workflow_dispatch: env: - VERSION: 1.61.0 + VERSION: 1.62.0 GIT_URL: https://github.com/bcgov/zeva.git DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev TEST_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-test @@ -62,7 +62,7 @@ jobs: return 0 } - input_string=$(oc -n ${{ env.DEV_NAMESPACE }} describe deployment/zeva-frontend-dev | grep Image | awk -F '-' '{print $NF}') + input_string=$(oc -n ${{ env.DEV_NAMESPACE }} describe deployment/zeva-dev-frontend | grep Image | awk -F '-' '{print $NF}') echo "The retrieved pre-release number on Dev is $input_string " if check_string "$input_string"; then @@ -87,23 +87,10 @@ jobs: uses: trstringer/manual-approval@v1.6.0 with: secret: ${{ github.TOKEN }} - approvers: AlexZorkin,emi-hi,tim738745,kuanfandevops,prv-proton,JulianForeman + approvers: emi-hi,tim738745,kuanfandevops,JulianForeman,rogerlcleung minimum-approvals: 1 issue-title: "ZEVA ${{ env.VERSION }}-${{ env.PRE_RELEASE }} Test Deployment" - - name: Log in to Openshift - uses: redhat-actions/oc-login@v1.3 - with: - openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} - openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} - insecure_skip_tls_verify: true - namespace: ${{ env.DEV_NAMESPACE }} - - - name: Tag ZEVA images to Test - run: | - oc tag ${{ env.DEV_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-$PRE_RELEASE ${{ env.TEST_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-$PRE_RELEASE - oc tag ${{ env.DEV_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-$PRE_RELEASE ${{ env.TEST_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-$PRE_RELEASE - - name: Checkout Manifest repository uses: actions/checkout@v3 with: @@ -126,3 +113,19 @@ jobs: git add zeva/charts/zeva-backend/values-test.yaml git commit -m "Update the image tag to ${{ env.VERSION }}-${{ env.PRE_RELEASE }} on Zeva Test Environment" git push + + - name: Log in to Openshift + uses: redhat-actions/oc-login@v1.3 + with: + openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} + openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} + insecure_skip_tls_verify: true + namespace: ${{ env.DEV_NAMESPACE }} + + - name: Tag ZEVA images to Test + run: | + helm -n ${{ env.DEV_NAMESPACE }} list + oc tag ${{ env.DEV_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.TEST_NAMESPACE }}/zeva-backend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} + oc tag ${{ env.DEV_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} ${{ env.TEST_NAMESPACE }}/zeva-frontend:${{ env.VERSION }}-${{ env.PRE_RELEASE }} + cd zeva + helm -n ${{ env.DEV_NAMESPACE }} -f ./values-dev.yaml upgrade --install zeva-dev . diff --git a/README.md b/README.md index 2e84558ca..f52f949ea 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ Add this entry to your `/etc/hosts` file: to view the database use: docker-compose exec db psql -U postgres postgres - #### Django Django offers many helpful [mangement commands](https://docs.djangoproject.com/en/4.0/ref/django-admin/) out of the box. To be able to use these with docker you can access the python environment with bash: @@ -63,7 +62,6 @@ We take advantage that MinIO is S3 compatible and use [django-storages](https:// We are using a shared realm [Keycloak](https://www.keycloak.org/) client. Shared realm clients can be accessed and configured via [Common Hosted Single Sign-on (CSS)](https://bcgov.github.io/sso-requests) - ### Email We are using [CHES](https://digital.gov.bc.ca/common-components/common-hosted-email-service) to send email. Documentation is [available here](https://getok.nrs.gov.bc.ca/app/documentation) @@ -96,7 +94,7 @@ python manage.py test api.services.tests.test_credit_transfers.py ### Squashing migrations -To squash migrations: python manage.py squashmigrations {app_name} {#_of_migration_you_wish_to_squash_up_to_and_include} +To squash migrations: python manage.py squashmigrations {app_name} {#\_of_migration_you_wish_to_squash_up_to_and_include} For example: "python manage.py squashmigrations api 0100" will squash all migrations between the first migration and the 100th migration, inclusive. If, in the migrations you're squashing, there exists RunPython operations executing certain functions, those functions will have to be copied into the squashed migration file, and the RunPython operations in the squashed migration file will have to reference those copied over functions. @@ -134,23 +132,22 @@ Code released under the [Apache License, Version 2.0](./LICENSE). # List of Dev Work | What to do before bringing in a new ticket into a Sprint -This is a list that was created on 2023-02-01 with all Zelda Devs to provide alternative work instead of bringing in a new ticket. - -**Team Rule* Do not bring in ticket After Friday* +This is a list that was created on 2023-02-01 with all Zelda Devs to provide alternative work instead of bringing in a new ticket. -1. Help another Dev - see if other Devs need help to finish their ticket +\*_Team Rule_ Do not bring in ticket After Friday\* -2. PR Reviews – linked to the task above +1. Help another Dev - see if other Devs need help to finish their ticket -3. Writing additional tests – for both tront and back end +2. PR Reviews – linked to the task above -4. Take a look at Tech Debt tickets - If we bring in tickets let's bring in Tech Debt first +3. Writing additional tests – for both tront and back end -5. Learning time: +4. Take a look at Tech Debt tickets - If we bring in tickets let's bring in Tech Debt first -- Take the opportunity to familiarize yourself with business logic, tech (anything around work we do) +5. Learning time: -- New learning and applying it to our work +- Take the opportunity to familiarize yourself with business logic, tech (anything around work we do) -- Innovation work +- New learning and applying it to our work +- Innovation work diff --git a/backend/Dockerfile b/backend/Dockerfile index 1343bdc97..a9be671e6 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,8 +1,8 @@ -FROM python:3.9 +FROM --platform=linux/amd64 python:3.9 ENV PYTHONUNBUFFERED=1 WORKDIR /api COPY requirements.txt /api/ -RUN pip install --upgrade pip +RUN pip install --upgrade pip==24.0 RUN pip install -r requirements.txt diff --git a/backend/api/viewsets/organization.py b/backend/api/viewsets/organization.py index d720f1044..106963ddb 100644 --- a/backend/api/viewsets/organization.py +++ b/backend/api/viewsets/organization.py @@ -13,7 +13,7 @@ from api.serializers.sales_submission import SalesSubmissionListSerializer from api.serializers.organization import \ OrganizationSerializer, OrganizationWithMembersSerializer, \ - OrganizationSaveSerializer + OrganizationSaveSerializer, OrganizationNameSerializer from api.serializers.organization_ldv_sales import \ OrganizationLDVSalesSerializer from api.permissions.organization import OrganizationPermissions @@ -85,8 +85,11 @@ def list(self, request): is_government=False ).order_by('name') - serializer = self.get_serializer(organizations, many=True) - return Response(serializer.data) + serializer = OrganizationNameSerializer + if request.user.is_government: + serializer = OrganizationSerializer + + return Response(serializer(organizations, many=True).data) @action(detail=False) def mine(self, request): diff --git a/frontend/package.json b/frontend/package.json index 99d87844f..1b8557042 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "zeva-frontend", - "version": "1.61.0", + "version": "1.62.0", "private": true, "dependencies": { "@babel/eslint-parser": "^7.19.1", diff --git a/openshift/templates/backend/backend-bc-docker.yaml b/openshift/templates/backend/backend-bc-docker.yaml index 813515872..cb235cd66 100644 --- a/openshift/templates/backend/backend-bc-docker.yaml +++ b/openshift/templates/backend/backend-bc-docker.yaml @@ -14,7 +14,7 @@ parameters: required: true - name: VERSION displayName: - description: image tag name for output + description: image tag name for output required: true - name: GIT_URL displayName: @@ -47,7 +47,7 @@ objects: creationTimestamp: null name: ${NAME}-backend${SUFFIX} labels: - shared: "true" + shared: "true" spec: nodeSelector: null output: @@ -75,9 +75,9 @@ objects: pullSecret: name: artifacts-pull-default-erhptx type: Docker - triggers: - - imageChange: {} - type: ImageChange - - type: ConfigChange + # triggers: + # - imageChange: {} + # type: ImageChange + # - type: ConfigChange status: - lastVersion: 0 \ No newline at end of file + lastVersion: 0 diff --git a/openshift/templates/frontend/frontend-bc-docker.yaml b/openshift/templates/frontend/frontend-bc-docker.yaml index f7d80c2d1..dd3d30e14 100644 --- a/openshift/templates/frontend/frontend-bc-docker.yaml +++ b/openshift/templates/frontend/frontend-bc-docker.yaml @@ -14,7 +14,7 @@ parameters: required: true - name: VERSION displayName: - description: image tag name for output + description: image tag name for output required: true - name: GIT_URL displayName: @@ -25,51 +25,48 @@ parameters: description: itvr branch name of the pr required: true objects: -- apiVersion: image.openshift.io/v1 - kind: ImageStream - metadata: - annotations: - description: Keeps track of changes in the client / front end image - labels: - shared: "true" - creationTimestamp: null - name: ${NAME}-frontend - spec: - lookupPolicy: - local: false - status: - dockerImageRepository: "" -- apiVersion: build.openshift.io/v1 - kind: BuildConfig - metadata: - name: ${NAME}-frontend${SUFFIX} - creationTimestamp: - annotations: - description: Defines how to build the frontend image in docker - spec: - output: - to: - kind: ImageStreamTag - name: ${NAME}-frontend:${VERSION} - resources: + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + annotations: + description: Keeps track of changes in the client / front end image + labels: + shared: "true" + creationTimestamp: null + name: ${NAME}-frontend + spec: + lookupPolicy: + local: false + status: + dockerImageRepository: "" + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: ${NAME}-frontend${SUFFIX} + creationTimestamp: + annotations: + description: Defines how to build the frontend image in docker + spec: + output: + to: + kind: ImageStreamTag + name: ${NAME}-frontend:${VERSION} + resources: limits: - cpu: 1000m - memory: 2Gi + cpu: 1000m + memory: 2Gi requests: - cpu: 500m - memory: 1Gi - source: - contextDir: frontend - git: - uri: ${GIT_URL} - ref: ${GIT_REF} - type: Git - strategy: - type: Docker - dockerStrategy: - dockerfilePath: ./Dockerfile-Openshift - pullSecret: - name: artifacts-pull-default-erhptx - triggers: - - type: ConfigChange - - type: ImageChange \ No newline at end of file + cpu: 500m + memory: 1Gi + source: + contextDir: frontend + git: + uri: ${GIT_URL} + ref: ${GIT_REF} + type: Git + strategy: + type: Docker + dockerStrategy: + dockerfilePath: ./Dockerfile-Openshift + pullSecret: + name: artifacts-pull-default-erhptx