From 234e9e40dd165f4ecfed369f4afb5c63620b03e6 Mon Sep 17 00:00:00 2001 From: JatinderSingh Date: Thu, 4 Apr 2024 15:46:58 -0700 Subject: [PATCH] update github actions and workflow --- .../actions/build-push-container/action.yaml | 10 +-- .../actions/deploy-to-environment/action.yaml | 2 +- .github/workflows/charts-release.yaml | 2 +- .github/workflows/codeql-analysis.yaml | 8 +- .github/workflows/on-pr-closed.yaml | 6 +- .github/workflows/on-pr-opened.yaml | 6 +- .github/workflows/on-push.yaml | 8 +- .github/workflows/unit-tests.yaml | 85 ++++++++++++------- app/frontend/package.json | 70 ++++++++++++++- app/frontend/src/App.vue | 6 ++ app/lcov-fix.js | 2 +- 11 files changed, 150 insertions(+), 55 deletions(-) diff --git a/.github/actions/build-push-container/action.yaml b/.github/actions/build-push-container/action.yaml index f87609a..a753a21 100644 --- a/.github/actions/build-push-container/action.yaml +++ b/.github/actions/build-push-container/action.yaml @@ -30,7 +30,7 @@ runs: using: composite steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Parse Input Values shell: bash @@ -39,7 +39,7 @@ runs: echo "HAS_DOCKERHUB=${{ fromJson(inputs.dockerhub_username != '' && inputs.dockerhub_token != '') }}" >> $GITHUB_ENV - name: Login to Github Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ env.GH_USERNAME }} @@ -47,7 +47,7 @@ runs: - name: Login to Dockerhub Container Registry if: env.HAS_DOCKERHUB == 'true' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: docker.io username: ${{ inputs.dockerhub_username }} @@ -55,7 +55,7 @@ runs: - name: Prepare Container Metadata tags id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: | ghcr.io/${{ env.GH_USERNAME }}/${{ inputs.image_name }} @@ -74,7 +74,7 @@ runs: - name: Build and Push to Container Registry id: builder - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: ${{ inputs.context }} push: true diff --git a/.github/actions/deploy-to-environment/action.yaml b/.github/actions/deploy-to-environment/action.yaml index 58422d4..19c2751 100644 --- a/.github/actions/deploy-to-environment/action.yaml +++ b/.github/actions/deploy-to-environment/action.yaml @@ -30,7 +30,7 @@ runs: using: composite steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to OpenShift Cluster uses: redhat-actions/oc-login@v1 diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 62919f9..16063db 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index 1ea8655..25226f5 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -42,11 +42,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -57,7 +57,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -71,4 +71,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/on-pr-closed.yaml b/.github/workflows/on-pr-closed.yaml index 8af073c..31dc732 100644 --- a/.github/workflows/on-pr-closed.yaml +++ b/.github/workflows/on-pr-closed.yaml @@ -27,7 +27,7 @@ jobs: timeout-minutes: 12 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to OpenShift Cluster uses: redhat-actions/oc-login@v1 with: @@ -41,12 +41,12 @@ jobs: helm uninstall --namespace ${{ env.NAMESPACE_PREFIX }}-dev pr-${{ github.event.number }} --timeout 10m --wait oc delete --namespace ${{ env.NAMESPACE_PREFIX }}-dev cm,secret --selector app.kubernetes.io/instance=pr-${{ github.event.number }} - name: Remove Release Comment on PR - uses: marocchino/sticky-pull-request-comment@v2 + uses: marocchino/sticky-pull-request-comment@v2.9.0 with: header: release delete: true - name: Remove Github Deployment Environment - uses: strumwolf/delete-deployment-environment@v2 + uses: strumwolf/delete-deployment-environment@v3 with: environment: pr onlyRemoveDeployments: true diff --git a/.github/workflows/on-pr-opened.yaml b/.github/workflows/on-pr-opened.yaml index c79745e..1b6facd 100644 --- a/.github/workflows/on-pr-opened.yaml +++ b/.github/workflows/on-pr-opened.yaml @@ -26,7 +26,7 @@ jobs: timeout-minutes: 10 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build & Push uses: ./.github/actions/build-push-container with: @@ -45,7 +45,7 @@ jobs: timeout-minutes: 12 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy to Dev uses: ./.github/actions/deploy-to-environment with: @@ -58,7 +58,7 @@ jobs: openshift_server: ${{ secrets.OPENSHIFT_SERVER }} openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} - name: Release Comment on PR - uses: marocchino/sticky-pull-request-comment@v2 + uses: marocchino/sticky-pull-request-comment@v2.9.0 if: success() with: header: release diff --git a/.github/workflows/on-push.yaml b/.github/workflows/on-push.yaml index a72fe80..99f96e9 100644 --- a/.github/workflows/on-push.yaml +++ b/.github/workflows/on-push.yaml @@ -23,7 +23,7 @@ jobs: timeout-minutes: 10 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build & Push uses: ./.github/actions/build-push-container with: @@ -44,7 +44,7 @@ jobs: timeout-minutes: 12 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy to Dev uses: ./.github/actions/deploy-to-environment with: @@ -69,7 +69,7 @@ jobs: timeout-minutes: 12 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy to Test uses: ./.github/actions/deploy-to-environment with: @@ -95,7 +95,7 @@ jobs: timeout-minutes: 12 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Deploy to Prod uses: ./.github/actions/deploy-to-environment with: diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 95d798f..179a273 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -5,29 +5,34 @@ on: - pull_request jobs: test-app: + name: Unit Tests (App) runs-on: ubuntu-latest defaults: run: working-directory: app + outputs: + HAS_CC_SECRETS: ${{ steps.check-secrets.outputs.HAS_CC_SECRETS }} timeout-minutes: 10 strategy: fail-fast: true matrix: node-version: - - 14.x - 16.x - 18.x + - 20.x steps: - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 + uses: actions/checkout@v4 + - name: Check CodeClimate Secrets + id: check-secrets + run: | + echo "HAS_CC_SECRETS=${{ secrets.CC_TEST_REPORTER_ID != '' }}" >> $GITHUB_OUTPUT - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 id: cache-app env: cache-name: cache-node-modules @@ -46,36 +51,52 @@ jobs: env: CI: true - name: Save Coverage Results - if: matrix.node-version == '18.x' - uses: actions/upload-artifact@v2 + if: matrix.node-version == '20.x' + uses: actions/upload-artifact@v4 with: name: coverage-app path: ${{ github.workspace }}/app/coverage retention-days: 1 + - name: Monitor Coverage + if: "matrix.node-version == '20.x' && ! github.event.pull_request.head.repo.fork" + uses: slavcodev/coverage-monitor-action@v1 + with: + comment_mode: update + comment_footer: false + comment_context: Coverage Report (Application) + coverage_path: app/coverage/clover.xml + github_token: ${{ secrets.GITHUB_TOKEN }} + threshold_alert: 50 + threshold_warning: 80 test-frontend: + name: Unit Tests (Frontend) runs-on: ubuntu-latest defaults: run: working-directory: app/frontend + outputs: + HAS_CC_SECRETS: ${{ steps.check-secrets.outputs.HAS_CC_SECRETS }} timeout-minutes: 10 strategy: fail-fast: true matrix: node-version: - - 14.x - 16.x - 18.x + - 20.x steps: - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 + uses: actions/checkout@v4 + - name: Check CodeClimate Secrets + id: check-secrets + run: | + echo "HAS_CC_SECRETS=${{ secrets.CC_TEST_REPORTER_ID != '' }}" >> $GITHUB_OUTPUT - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v4 id: cache-frontend env: cache-name: cache-node-modules @@ -94,38 +115,38 @@ jobs: env: CI: true - name: Save Coverage Results - if: matrix.node-version == '18.x' - uses: actions/upload-artifact@v2 + if: matrix.node-version == '20.x' + uses: actions/upload-artifact@v4 with: name: coverage-frontend path: ${{ github.workspace }}/app/frontend/coverage retention-days: 1 + - name: Monitor Coverage + if: "matrix.node-version == '20.x' && ! github.event.pull_request.head.repo.fork" + uses: slavcodev/coverage-monitor-action@v1 + with: + comment_mode: update + comment_footer: false + comment_context: Coverage Report (Frontend) + coverage_path: app/frontend/coverage/clover.xml + github_token: ${{ secrets.GITHUB_TOKEN }} + threshold_alert: 50 + threshold_warning: 80 test-coverage: + name: Publish to Code Climate needs: - test-app - test-frontend + if: needs.test-app.outputs.HAS_CC_SECRETS == 'true' runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Check Workflow Secrets - id: check-secrets - run: | - unset HAS_SECRETS - if [ -n "$CC_TEST_REPORTER_ID" ]; then HAS_SECRETS='true'; fi - echo ::set-output name=HAS_SECRETS::${HAS_SECRETS} - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - name: Checkout Repository - if: steps.check-secrets.outputs.HAS_SECRETS - uses: actions/checkout@v2 - with: - fetch-depth: 0 + uses: actions/checkout@v4 - name: Restore Coverage Results - if: steps.check-secrets.outputs.HAS_SECRETS - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 - name: Publish code coverage - if: steps.check-secrets.outputs.HAS_SECRETS - uses: paambaati/codeclimate-action@v2.7.5 + uses: paambaati/codeclimate-action@v5 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: diff --git a/app/frontend/package.json b/app/frontend/package.json index eb4ccd8..8a4a2a3 100644 --- a/app/frontend/package.json +++ b/app/frontend/package.json @@ -1 +1,69 @@ -{"name":"ches-showcase-frontend","version":"1.0.0","private":true,"license":"Apache-2.0","scripts":{"serve":"vue-cli-service serve","build":"vue-cli-service build","test":"npm run test:unit","test:unit":"vue-cli-service test:unit --verbose --verbose --forceExit --detectOpenHandles --maxWorkers=10","lint":"vue-cli-service lint","lint:fix":"vue-cli-service lint --fix","pretest":"npm run lint","clean":"rm -rf coverage dist **/e2e/videos","purge":"rm -rf node_modules","rebuild":"npm run clean && npm run build","reinstall":"npm run purge && npm install"},"dependencies":{"@bcgov/bc-sans":"^2.1.0","@ckeditor/ckeditor5-basic-styles":"^41.2.1","@ckeditor/ckeditor5-dev-utils":"^27.1.1","@ckeditor/ckeditor5-dev-webpack-plugin":"^31.1.13","@ckeditor/ckeditor5-editor-classic":"^41.2.1","@ckeditor/ckeditor5-essentials":"^41.2.1","@ckeditor/ckeditor5-link":"^41.2.1","@ckeditor/ckeditor5-paragraph":"^41.2.1","@ckeditor/ckeditor5-source-editing":"^41.2.1","@ckeditor/ckeditor5-table":"^41.2.1","@ckeditor/ckeditor5-theme-lark":"^41.2.1","@ckeditor/ckeditor5-vue2":"^3.0.1","@vue/cli-plugin-vuex":"^4.5.19","axios":"^1.6.7","core-js":"^3.36.0","date-fns":"^3.6.0","keycloak-js":"^24.0.2","lodash":"^4.17.21","nprogress":"^0.2.0","vue":"2.7.16","vue-router":"^3.6.5","vuetify":"^2.6.12","vuex":"^3.6.2","vuex-map-fields":"^1.4.1","vuex-persistedstate":"^4.1.0","xlsx":"^0.18.5"},"devDependencies":{"@babel/eslint-parser":"^7.5.4","@vue/cli-plugin-babel":"^5.0.8","@vue/cli-plugin-eslint":"^5.0.8","@vue/cli-plugin-router":"^5.0.8","@vue/cli-plugin-unit-jest":"^5.0.8","@vue/cli-plugin-vuex":"^5.0.8","@vue/cli-service":"^5.0.8","@vue/test-utils":"^1.3.6","@vue/vue2-jest":"^27.0.0","babel-eslint":"^10.1.0","eslint":"^8.57.0","eslint-plugin-prettier":"^5.1.3","eslint-plugin-vue":"^9.23.0","eslint-plugin-vuetify":"^1.0.1","prettier":"^3.2.5","sass":"< 1.33.0","sass-loader":"^14.1.1","vue-cli-plugin-vuetify":"^2.5.8","vue-template-compiler":"^2.7.16","vuetify-loader":"^1.9.2"}} +{ + "name": "ches-showcase-frontend", + "version": "1.0.0", + "private": true, + "license": "Apache-2.0", + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "test": "npm run test:unit", + "test:unit": "vue-cli-service test:unit --verbose --verbose --forceExit --detectOpenHandles --maxWorkers=10", + "lint": "vue-cli-service lint", + "lint:fix": "vue-cli-service lint --fix", + "pretest": "npm run lint", + "clean": "rm -rf coverage dist **/e2e/videos", + "purge": "rm -rf node_modules", + "rebuild": "npm run clean && npm run build", + "reinstall": "npm run purge && npm install" + }, + "dependencies": { + "@bcgov/bc-sans": "^2.1.0", + "@ckeditor/ckeditor5-basic-styles": "^41.2.1", + "@ckeditor/ckeditor5-dev-utils": "^27.1.1", + "@ckeditor/ckeditor5-dev-webpack-plugin": "^31.1.13", + "@ckeditor/ckeditor5-editor-classic": "^41.2.1", + "@ckeditor/ckeditor5-essentials": "^41.2.1", + "@ckeditor/ckeditor5-link": "^41.2.1", + "@ckeditor/ckeditor5-paragraph": "^41.2.1", + "@ckeditor/ckeditor5-source-editing": "^41.2.1", + "@ckeditor/ckeditor5-table": "^41.2.1", + "@ckeditor/ckeditor5-theme-lark": "^41.2.1", + "@ckeditor/ckeditor5-vue2": "^3.0.1", + "@vue/cli-plugin-vuex": "^4.5.19", + "axios": "^1.6.7", + "core-js": "^3.36.0", + "date-fns": "^3.6.0", + "keycloak-js": "^24.0.2", + "lodash": "^4.17.21", + "nprogress": "^0.2.0", + "vue": "2.7.16", + "vue-router": "^3.6.5", + "vuetify": "^2.6.12", + "vuex": "^3.6.2", + "vuex-map-fields": "^1.4.1", + "vuex-persistedstate": "^4.1.0", + "xlsx": "^0.18.5" + }, + "devDependencies": { + "@babel/eslint-parser": "^7.5.4", + "@vue/cli-plugin-babel": "^5.0.8", + "@vue/cli-plugin-eslint": "^5.0.8", + "@vue/cli-plugin-router": "^5.0.8", + "@vue/cli-plugin-unit-jest": "^5.0.8", + "@vue/cli-plugin-vuex": "^5.0.8", + "@vue/cli-service": "^5.0.8", + "@vue/test-utils": "^1.3.6", + "@vue/vue2-jest": "^27.0.0", + "babel-eslint": "^10.1.0", + "eslint": "^8.57.0", + "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-vue": "^9.23.0", + "eslint-plugin-vuetify": "^1.0.1", + "prettier": "^3.2.5", + "sass": "< 1.33.0", + "sass-loader": "^14.1.1", + "vue-cli-plugin-vuetify": "^2.5.8", + "vue-template-compiler": "^2.7.16", + "vuetify-loader": "^1.9.2" + } +} diff --git a/app/frontend/src/App.vue b/app/frontend/src/App.vue index 55c1fb5..b20b871 100644 --- a/app/frontend/src/App.vue +++ b/app/frontend/src/App.vue @@ -14,15 +14,21 @@