From 788e92d6374f6bd47c8f3ec1138c7fc8ed0cc85f Mon Sep 17 00:00:00 2001 From: Kial Date: Tue, 4 Jun 2024 15:15:19 -0700 Subject: [PATCH] CI/CD updates (#2) * removed base folder Signed-off-by: Kial Jinnah * ci updates Signed-off-by: Kial Jinnah * env.example updates Signed-off-by: Kial Jinnah * updated cloudbuild-pr yaml Signed-off-by: Kial Jinnah * updated cd stuff Signed-off-by: Kial Jinnah * updated firebase.json for PR build Signed-off-by: Kial Jinnah * fixed lint Signed-off-by: Kial Jinnah * updated middleware redirect Signed-off-by: Kial Jinnah --------- Signed-off-by: Kial Jinnah --- .env.example | 8 ++- .eslintrc | 18 +++++++ .github/workflows/cd.yml | 26 +++++----- .github/workflows/ci.yml | 10 ++-- .gitignore | 1 + .../e2e/error-flows/entry-auth-error.cy.ts | 14 ++--- devops/cloudbuild-pr.yaml | 51 ------------------- firebase.json | 2 +- src/app.vue | 4 +- .../{base => bcros}/dialog/Index.vue | 10 ++-- .../dialog/slot-templates/DialogButton.vue | 0 .../dialog/slot-templates/DialogContent.vue | 0 .../dialog/slot-templates/index.ts | 0 src/composables/useFetchBcros.ts | 4 +- src/middleware/01.redirect.global.ts | 6 ++- src/stores/business.ts | 5 +- tailwind.config.ts | 3 +- 17 files changed, 64 insertions(+), 98 deletions(-) create mode 100644 .eslintrc delete mode 100644 devops/cloudbuild-pr.yaml rename src/components/{base => bcros}/dialog/Index.vue (86%) rename src/components/{base => bcros}/dialog/slot-templates/DialogButton.vue (100%) rename src/components/{base => bcros}/dialog/slot-templates/DialogContent.vue (100%) rename src/components/{base => bcros}/dialog/slot-templates/index.ts (100%) diff --git a/.env.example b/.env.example index 28c49de..4e85674 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,7 @@ -# Base Path Openshift: bor Firebase: VUE_APP_PATH="/" -#vaults assets VUE_APP_POD_NAMESPACE="local" +VUE_APP_REQUIRE_LOGIN="true" #vaults web-url VUE_APP_REGISTRY_URL="https://dev.bcros.ca/dashboard" @@ -15,11 +14,10 @@ VUE_APP_AUTH_API_URL="https://auth-api-dev.apps.silver.devops.gov.bc.ca" VUE_APP_AUTH_API_VERSION="/api/v1" VUE_APP_PAY_API_URL="https://pay-api-dev.apps.silver.devops.gov.bc.ca" VUE_APP_PAY_API_VERSION="/api/v1" +VUE_APP_LEGAL_API_URL="https://legal-api-dev.apps.silver.devops.gov.bc.ca" +VUE_APP_LEGAL_API_VERSION_2="/api/v2" VUE_APP_STATUS_API_URL="https://status-api-dev.apps.silver.devops.gov.bc.ca" VUE_APP_STATUS_API_VERSION="/api/v1" -VUE_APP_BOR_API_URL="https://bcregistry-dev.apigee.net/director-search" -VUE_APP_BOR_API_VERSION="/api/v1" -VUE_APP_BOR_API_KEY= #vaults launchdarkly VUE_APP_BTR_LD_CLIENT_ID= diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..f865454 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,18 @@ +{ + "root": true, + "extends": [ + "@nuxtjs/eslint-config-typescript" + ], + "rules": { + "max-len": [ + "warn", + { "code": 120, "ignoreRegExpLiterals": true, "ignoreTrailingComments": true } + ], + "no-console": ["error", { "allow": ["warn", "error", "info"] }], + "space-before-function-paren": "off", + "vue/no-unused-vars": "warn", + "vue/multi-word-component-names": "off", + "vue/no-v-html": "off", + "@typescript-eslint/no-unused-vars": "warn" + } +} \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index af72f3b..2b6056e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -4,8 +4,6 @@ on: push: branches: - main - paths: - - "/**" workflow_dispatch: inputs: environment: @@ -13,10 +11,10 @@ on: required: true type: choice options: - - dev - - test - - sandbox - - prod + - dev + - test + - sandbox + - prod tagname: description: "Specify a previous version (git tag) to deploy" required: false @@ -25,13 +23,13 @@ on: jobs: bus-dash-ui-cd: permissions: - contents: 'write' - id-token: 'write' - uses: bcgov/bcregistry-sre/.github/workflows/ui-cd-pnpm.yaml@main + contents: "write" + id-token: "write" + uses: bcgov/bcregistry-sre/.github/workflows/frontend-cd.yaml@main with: - environment: ${{ inputs.environment }} - tagname: ${{ inputs.tagname }} + target: ${{ inputs.environment }} + node_version: 20 + app_name: "business-dashboard-ui" secrets: - APP_NAME: "business-dashboard-ui" - OP_CONNECT_URL: ${{ secrets.OP_CONNECT_URL }} - OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }} + WORKLOAD_IDENTIFY_POOLS_PROVIDER: ${{ secrets.WORKLOAD_IDENTIFY_POOLS_PROVIDER }} + GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af0cccf..07f5148 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,9 +3,6 @@ name: Business Dash CI on: pull_request: types: [assigned, synchronize] - paths: - - "/**" - defaults: run: @@ -72,11 +69,11 @@ jobs: cypress-test: needs: setup-job runs-on: ubuntu-20.04 - + strategy: matrix: node-version: [20] - + steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} @@ -108,7 +105,7 @@ jobs: strategy: matrix: node-version: [20] - + steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} @@ -124,4 +121,3 @@ jobs: - name: Build check run: pnpm build - diff --git a/.gitignore b/.gitignore index aa26665..51295dc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ logs .DS_Store .fleet .idea +.eslintcache # Local env files .env diff --git a/cypress/e2e/error-flows/entry-auth-error.cy.ts b/cypress/e2e/error-flows/entry-auth-error.cy.ts index 862b53b..7a1fcc7 100644 --- a/cypress/e2e/error-flows/entry-auth-error.cy.ts +++ b/cypress/e2e/error-flows/entry-auth-error.cy.ts @@ -4,13 +4,13 @@ context('Business Dash Auth Error Handling', () => { }) it('should display error modal', () => { - cy.get('[data-cy="base-dialog"]').should('exist') - cy.get('[data-cy="base-dialog"]').find('h1').should('have.text', 'Business Dashboard Unavailable') - cy.get('[data-cy="base-dialog"]').find('[data-cy="base-dialog-text"]').find('p') + cy.get('[data-cy="bcros-dialog"]').should('exist') + cy.get('[data-cy="bcros-dialog"]').find('h1').should('have.text', 'Business Dashboard Unavailable') + cy.get('[data-cy="bcros-dialog"]').find('[data-cy="bcros-dialog-text"]').find('p') .should('contain.text', 'application is currently unavailable') - cy.get('[data-cy="base-dialog"]').find('[data-cy="contact-icon"]').should('exist') - cy.get('[data-cy="base-dialog"]').find('[data-cy="contact-label"]').should('exist') - cy.get('[data-cy="base-dialog"]').find('[data-cy="contact-value"]').should('exist') - cy.get('[data-cy="base-dialog"]').find('[data-cy="base-dialog-btn"]').should('exist') + cy.get('[data-cy="bcros-dialog"]').find('[data-cy="contact-icon"]').should('exist') + cy.get('[data-cy="bcros-dialog"]').find('[data-cy="contact-label"]').should('exist') + cy.get('[data-cy="bcros-dialog"]').find('[data-cy="contact-value"]').should('exist') + cy.get('[data-cy="bcros-dialog"]').find('[data-cy="bcros-dialog-btn"]').should('exist') }) }) diff --git a/devops/cloudbuild-pr.yaml b/devops/cloudbuild-pr.yaml deleted file mode 100644 index 53ecd79..0000000 --- a/devops/cloudbuild-pr.yaml +++ /dev/null @@ -1,51 +0,0 @@ -steps: - # setup .env - - name: 'gcr.io/cloud-builders/gcloud' - entrypoint: bash - args: ['-c', 'cp .env.example .env'] - # install deps and build - - name: 'node:20.6.1' - env: - - 'VUE_APP_ADDRESS_COMPLETE_KEY=$_VUE_APP_ADDRESS_COMPLETE_KEY' - - 'VUE_APP_BTR_LD_CLIENT_ID=$_VUE_APP_LD_CLIENT_ID' - - 'VUE_APP_POD_NAMESPACE=$_VUE_APP_POD_NAMESPACE' - script: | - #!/usr/bin/env bash - npm install --global pnpm - pnpm install - pnpm build - # - # Deploy to firebase channel, using the PR # - # store log to /workspace to get the channel URL - # - - name: gcr.io/yfthig-dev/firebase - entrypoint: bash - dir: business-dashboard-ui - args: ['-c', 'firebase hosting:channel:deploy --project=yfthig-dev PR-$_PR_NUMBER > /workspace/firebase-deploy.txt'] - - # - # Update the PR with the temporary URL - # - - id: "Update the PR" - name: gcr.io/cloud-builders/curl - entrypoint: bash - dir: business-dashboard-ui - args: - - -c - - | - # Read from "/workspace" - url=`cat /workspace/firebase-deploy.txt| grep 'Channel URL' | grep -Eo "https://[a-zA-Z0-9./?=_%:-]*"` - echo "this is the body:" - echo '{"body": "Temporary Url for review:'"$url"'"}' - curl -X POST \ - https://api.github.com/repos/bcgov/business-dahsboard-ui/issues/$_PR_NUMBER/comments \ - --header "Authorization: Token $$TOKEN" \ - --header "Accept: application/vnd.github.v3+json" \ - --data-binary '{"body": "Temporary Url for review: '"$url"'"}' - secretEnv: ['TOKEN'] -availableSecrets: - secretManager: - - versionName: projects/$PROJECT_ID/secrets/token-pr-review/versions/latest - env: 'TOKEN' -options: - dynamic_substitutions: true \ No newline at end of file diff --git a/firebase.json b/firebase.json index 4ffbe3b..596679c 100644 --- a/firebase.json +++ b/firebase.json @@ -1,7 +1,7 @@ { "hosting": { - "site": "bcregistry-business-dashboard-dev", + "site": "business-dashboard-dev", "public": "dist", "ignore": ["**/devops/**", "**/.*", "**/node_modules/**"], "rewrites": [ diff --git a/src/app.vue b/src/app.vue index b5f8340..17b8fc1 100644 --- a/src/app.vue +++ b/src/app.vue @@ -1,7 +1,7 @@ - +
-

+

{{ options.title }}

@@ -16,11 +16,11 @@ color="primary" icon="i-heroicons-x-mark-20-solid" variant="ghost" - data-cy="base-dialog-close-btn" + data-cy="bcros-dialog-close-btn" @click="close()" />
-
+
- +
diff --git a/src/components/base/dialog/slot-templates/DialogButton.vue b/src/components/bcros/dialog/slot-templates/DialogButton.vue similarity index 100% rename from src/components/base/dialog/slot-templates/DialogButton.vue rename to src/components/bcros/dialog/slot-templates/DialogButton.vue diff --git a/src/components/base/dialog/slot-templates/DialogContent.vue b/src/components/bcros/dialog/slot-templates/DialogContent.vue similarity index 100% rename from src/components/base/dialog/slot-templates/DialogContent.vue rename to src/components/bcros/dialog/slot-templates/DialogContent.vue diff --git a/src/components/base/dialog/slot-templates/index.ts b/src/components/bcros/dialog/slot-templates/index.ts similarity index 100% rename from src/components/base/dialog/slot-templates/index.ts rename to src/components/bcros/dialog/slot-templates/index.ts diff --git a/src/composables/useFetchBcros.ts b/src/composables/useFetchBcros.ts index 91b6070..97a159e 100644 --- a/src/composables/useFetchBcros.ts +++ b/src/composables/useFetchBcros.ts @@ -8,8 +8,8 @@ export const useFetchBcros = (request, opts?) => { if (!opts.headers['Account-Id']) { opts.headers['Account-Id'] = (useBcrosAccount()).currentAccount?.id } - if (!opts.headers['Accept']) { - opts.headers['Accept'] = 'application/json' + if (!opts.headers.Accept) { + opts.headers.Accept = 'application/json' } return useFetch(request, opts) diff --git a/src/middleware/01.redirect.global.ts b/src/middleware/01.redirect.global.ts index 437b747..4d0118d 100644 --- a/src/middleware/01.redirect.global.ts +++ b/src/middleware/01.redirect.global.ts @@ -3,10 +3,14 @@ import { RouteNameE } from '@/enums/route-name-e' export default defineNuxtRouteMiddleware((to) => { const expectedRoutes = [RouteNameE.DASHBOARD] if (!expectedRoutes.includes(to.name as RouteNameE)) { + // TODO: remove dev/test redirects once other apps are redirecting to here properly // set specific identifier for development (allows going directly to localhost link) - if (['local'].includes(useRuntimeConfig().public.appEnv)) { + if (['local', 'pr', 'dev'].includes(useRuntimeConfig().public.appEnv)) { const identifier = 'BC0871427' return navigateTo({ name: RouteNameE.DASHBOARD, params: { identifier } }) + } else if (['test'].includes(useRuntimeConfig().public.appEnv)) { + const identifier = 'BC1052139' + return navigateTo({ name: RouteNameE.DASHBOARD, params: { identifier } }) } else { useBcrosNavigate().goToBcrosDashboard() } diff --git a/src/stores/business.ts b/src/stores/business.ts index 35675ab..b751bee 100644 --- a/src/stores/business.ts +++ b/src/stores/business.ts @@ -21,7 +21,10 @@ export const useBcrosBusiness = defineStore('bcros/business', () => { /** Return the business details for the given identifier */ async function getBusinessDetails (identifier: string, params?: object) { - return await useFetchBcros<{ business: BusinessI }>(`${apiURL}/businesses/${identifier}`, { params, dedupe: 'defer' }) + return await useFetchBcros<{ business: BusinessI }>( + `${apiURL}/businesses/${identifier}`, + { params, dedupe: 'defer' } + ) .then(({ data, error }) => { if (error.value || !data.value) { console.warn('Error fetching business details for', identifier) diff --git a/tailwind.config.ts b/tailwind.config.ts index 09ee397..42c5ff5 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -65,6 +65,5 @@ export default { } } }, - plugins: [], + plugins: [] } -