From 5e559764cb3d95de5edab9d5c895d7498f35811d Mon Sep 17 00:00:00 2001 From: Jeremy Ho Date: Fri, 20 Oct 2023 12:38:14 -0700 Subject: [PATCH 1/3] Add bcgov pubcode manifest Signed-off-by: Jeremy Ho --- bcgovpubcode.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 bcgovpubcode.yml diff --git a/bcgovpubcode.yml b/bcgovpubcode.yml new file mode 100644 index 0000000..375c7b2 --- /dev/null +++ b/bcgovpubcode.yml @@ -0,0 +1,44 @@ +--- +data_management_roles: + data_custodian: Fraser Marshall + product_owner: Sharolyn Hurley +product_external_dependencies: + identity_authorization: + - Custom-Keycloak + notification_standard: [] +product_information: + api_specifications: + - https://cdogs.api.gov.bc.ca/api/v2/docs + business_capabilities_custom: Rich document templating support,Merge complex datasets + business_capabilities_standard: + - Other + ministry: + - Water, Land and Resource Stewardship + product_acronym: CDOGS + product_description: >- + Hosted API service to Leverage your structured datasets and your business + templates to automatically populate printable documents, spreadsheets, + presentations, or PDFs + product_name: Common Document Generation Service + product_status: stable + product_urls: + - https://api.gov.bc.ca/devportal/api-directory/3181?preview=false + program_area: NRIDS +product_technology_information: + backend_frameworks: + - name: Express + version: 4.18.2 + - name: Other + version: Carbone + backend_languages_version: + - name: JavaScript + version: ecmaVersion 9 / es2018 + ci_cd_tools: + - Jenkins + data_storage_platforms: + - Other + data_storage_platforms_custom: PVC Cache + frontend_languages: [] + hosting_platforms: + - Private-Cloud-Openshift +version: 1 From 4f698bda5d0242737188b5b6ecea39b2071e738f Mon Sep 17 00:00:00 2001 From: Jeremy Ho Date: Fri, 20 Oct 2023 12:49:13 -0700 Subject: [PATCH 2/3] Update tests and coverage pipeline Signed-off-by: Jeremy Ho --- .github/workflows/unit-tests.yaml | 58 +++++++++++++++++-------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 5a9197e..3e9da6b 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -1,33 +1,40 @@ --- name: Tests + on: - push - pull_request + jobs: test-app: + name: Unit Tests 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: - - 12.x - 14.x - 16.x + - 18.x steps: - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 + uses: actions/checkout@v3 + - 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@v3 with: node-version: ${{ matrix.node-version }} - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v3 id: cache-app env: cache-name: cache-node-modules @@ -46,37 +53,36 @@ jobs: env: CI: true - name: Save Coverage Results - if: matrix.node-version == '16.x' - uses: actions/upload-artifact@v2 + if: matrix.node-version == '18.x' + uses: actions/upload-artifact@v3 with: name: coverage-app path: ${{ github.workspace }}/app/coverage retention-days: 1 + - name: Monitor Coverage + if: "matrix.node-version == '18.x' && ! github.event.pull_request.head.repo.fork" + uses: slavcodev/coverage-monitor-action@v1 + with: + comment_mode: update + comment_footer: false + coverage_path: app/coverage/clover.xml + github_token: ${{ secrets.GITHUB_TOKEN }} + threshold_alert: 50 + threshold_warning: 80 + test-coverage: - needs: - - test-app + name: Publish to Code Climate + needs: test-app + 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@v3 - name: Restore Coverage Results - if: steps.check-secrets.outputs.HAS_SECRETS - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 - name: Publish code coverage - if: steps.check-secrets.outputs.HAS_SECRETS - uses: paambaati/codeclimate-action@v2.7.5 + uses: paambaati/codeclimate-action@v3.2.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: From 92a1095a84e565d2e94fe7f85bcf708230d2851f Mon Sep 17 00:00:00 2001 From: Jeremy Ho Date: Fri, 20 Oct 2023 11:35:04 -0700 Subject: [PATCH 3/3] Update base image to use node 18.18.2 Signed-off-by: Jeremy Ho --- app/Dockerfile | 13 +++++++++---- openshift/app.bc.yaml | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index 421097b..bd87d61 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,12 +1,17 @@ -FROM docker.io/bcgovimages/alpine-node-libreoffice:1.0.7 +FROM docker.io/bcgovimages/alpine-node-libreoffice:18.18.2 ARG APP_ROOT=/opt/app-root/src -ENV NO_UPDATE_NOTIFIER=true \ - APP_PORT=3000 +ENV APP_PORT=8080 \ + NO_UPDATE_NOTIFIER=true WORKDIR ${APP_ROOT} +# NPM Permission Fix (already present in base image) + +# Install Application COPY . . -RUN npm ci +RUN chown -R 1001:0 ${APP_ROOT} +USER 1001 +RUN npm ci --omit=dev EXPOSE ${APP_PORT} CMD ["npm", "run", "start"] diff --git a/openshift/app.bc.yaml b/openshift/app.bc.yaml index 94d286b..5c1e714 100644 --- a/openshift/app.bc.yaml +++ b/openshift/app.bc.yaml @@ -51,7 +51,7 @@ objects: value: notice from: kind: DockerImage - name: docker.io/bcgovimages/alpine-node-libreoffice:1.0.7 + name: docker.io/bcgovimages/alpine-node-libreoffice:18.18.2 type: Docker successfulBuildsHistoryLimit: 3 parameters: