Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade node version #14968

Merged
merged 51 commits into from
May 28, 2024
Merged

chore: upgrade node version #14968

merged 51 commits into from
May 28, 2024

Conversation

lodmfjord
Copy link
Member

@lodmfjord lodmfjord commented May 28, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced dynamic Node.js version management using NODE_IMAGE_TAG for Docker builds.
    • Added a script to calculate a hash for node modules to optimize caching.
  • Updates

    • Updated actions/setup-node from v2 to v4 in various workflows.
    • Changed TypeScript configuration to include esnext for better compatibility.
  • Bug Fixes

    • Improved environment variable handling in workflow scripts for better control over testing conditions.
  • Chores

    • Upgraded @types/node package to version 20.12.12.
    • Refined Docker build processes to enhance flexibility and maintainability.

lodmfjord and others added 30 commits April 12, 2024 11:17
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented May 28, 2024

Affected services are: air-discount-scheme-api,air-discount-scheme-backend,api,application-system-api,download-service,financial-aid-api,financial-aid-backend,financial-aid-open-api,github-actions-cache,icelandic-names-registry-backend,judicial-system-api,judicial-system-digital-mailbox-api,judicial-system-backend,judicial-system-message-handler,judicial-system-robot-api,judicial-system-scheduler,judicial-system-xrd-api,license-api,reference-backend,regulations-admin-backend,services-auth-admin-api,services-auth-delegation-api,services-auth-ids-api,services-auth-personal-representative,services-auth-personal-representative-public,services-auth-public-api,services-contentful-entry-tagger,services-documents,services-endorsements-api,services-search-indexer,services-sessions,services-university-gateway,services-user-notification,services-user-profile,services-xroad-collector,skilavottord-ws,air-discount-scheme-web,auth-admin-web,consultation-portal,contentful-apps,financial-aid-web-osk,financial-aid-web-veita,judicial-system-web,skilavottord-web,web,application-system-form,island-ui-storybook,portals-admin,service-portal,system-e2e,external-contracts-tests,

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Outside diff range and nitpick comments (3)
infra/scripts/Dockerfile (2)

Line range hint 11-18: Replace ADD with COPY for better readability and adherence to Docker best practices.

- ADD infra/package.json infra/yarn.lock /app/infra/
+ COPY infra/package.json infra/yarn.lock /app/infra/
- ADD infra/ /app/infra/
+ COPY infra/ /app/infra/
- ADD apps /app/apps/
+ COPY apps /app/apps/
- ADD libs /app/libs/
+ COPY libs /app/libs/

Line range hint 21-21: Consider consolidating multiple RUN commands to reduce the number of layers in the Docker image.

- RUN ./node_modules/.bin/ncc build src/feature-env.ts -o /app/dist/feature-env
- RUN ./node_modules/.bin/ncc build src/secrets.ts -o /app/dist/secrets
+ RUN ./node_modules/.bin/ncc build src/feature-env.ts -o /app/dist/feature-env && \
+    ./node_modules/.bin/ncc build src/secrets.ts -o /app/dist/secrets
scripts/ci/Dockerfile (1)

Line range hint 12-13: Replace ADD with COPY for better clarity and adherence to Docker best practices.

- ADD package.json yarn.lock .yarnrc.yml ./
+ COPY package.json yarn.lock .yarnrc.yml ./
- ADD apps/native/app/package.json ./apps/native/app/
+ COPY apps/native/app/package.json ./apps/native/app/
- ADD . .
+ COPY . .

Also applies to: 25-25

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between d2ce8b8 and 2108b5e.
Files selected for processing (14)
  • .github/actions/main.ts (1 hunks)
  • .github/actions/package.json (1 hunks)
  • .github/actions/tsconfig.json (1 hunks)
  • .github/actions/unit-test/action.yml (1 hunks)
  • .github/actions/yarn.lock (2 hunks)
  • .github/workflows/config-values.yaml (2 hunks)
  • .github/workflows/pullrequest.yml (8 hunks)
  • .github/workflows/push.yml (14 hunks)
  • infra/scripts/Dockerfile (1 hunks)
  • scripts/ci/10_prepare-docker-deps.sh (2 hunks)
  • scripts/ci/Dockerfile (2 hunks)
  • scripts/ci/_common.mjs (1 hunks)
  • scripts/ci/get-node-modules-hash.mjs (1 hunks)
  • scripts/ci/get-node-version.mjs (1 hunks)
Files skipped from review due to trivial changes (3)
  • .github/actions/package.json
  • .github/actions/tsconfig.json
  • .github/actions/yarn.lock
Additional Context Used
Biome (12)
.github/actions/main.ts (12)

8-8: Forbidden non-null assertion.


8-8: Forbidden non-null assertion.


18-18: Forbidden non-null assertion.


19-19: Forbidden non-null assertion.


20-20: Forbidden non-null assertion.


21-21: Forbidden non-null assertion.


27-27: Forbidden non-null assertion.


28-28: Forbidden non-null assertion.


29-29: Forbidden non-null assertion.


33-33: Do not use template literals if interpolation and special-character handling are not needed.


4-6: All these imports are only used as types.


8-8: This let declares a variable that is only assigned once.

Hadolint (30)
infra/scripts/Dockerfile (10)

5: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>


5: Use the --no-cache switch to avoid the need to use --update and remove /var/cache/apk/* when done installing packages


11: Use COPY instead of ADD for files and folders


12: COPY to a relative destination without WORKDIR set.


16: Use COPY instead of ADD for files and folders


17: Use COPY instead of ADD for files and folders


18: Use COPY instead of ADD for files and folders


21: Multiple consecutive RUN instructions. Consider consolidation.


26: COPY to a relative destination without WORKDIR set.


27: COPY to a relative destination without WORKDIR set.

scripts/ci/Dockerfile (20)

7: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>


7: Use the --no-cache switch to avoid the need to use --update and remove /var/cache/apk/* when done installing packages


12: Use COPY instead of ADD for files and folders


13: Use COPY instead of ADD for files and folders


15: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>


16: yarn cache clean missing after yarn install was run.


20: Avoid use of wget without progress bar. Use wget --progress=dot:giga <url>. Or consider using -q or -nv (shorthands for --quiet or --no-verbose).


25: Use COPY instead of ADD for files and folders


57: Pin versions in npm. Instead of npm install <package> use npm install <package>@<version>


101: Pin versions in apk add. Instead of apk add <package> use apk add <package>=<version>


101: Use the --no-cache switch to avoid the need to use --update and remove /var/cache/apk/* when done installing packages


105: Use COPY instead of ADD for files and folders


106: Use COPY instead of ADD for files and folders


107: Use COPY instead of ADD for files and folders


114: Multiple consecutive RUN instructions. Consider consolidation.


114: Pin versions in npm. Instead of npm install <package> use npm install <package>@<version>


133: Avoid additional packages by specifying --no-install-recommends


133: Pin versions in apt get install. Instead of apt-get install <package> use apt-get install <package>=<version>


145: Use COPY instead of ADD for files and folders


166: COPY to a relative destination without WORKDIR set.

Path-based Instructions (5)
scripts/ci/_common.mjs (1)

Pattern scripts/**/*: "Confirm that the code adheres to the following:

  • Script efficiency, readability, and maintainability.
  • Usage of environmental variables and configuration files for flexibility.
  • Integration with NX workspace utilities and commands."
scripts/ci/10_prepare-docker-deps.sh (1)

Pattern scripts/**/*: "Confirm that the code adheres to the following:

  • Script efficiency, readability, and maintainability.
  • Usage of environmental variables and configuration files for flexibility.
  • Integration with NX workspace utilities and commands."
scripts/ci/get-node-modules-hash.mjs (1)

Pattern scripts/**/*: "Confirm that the code adheres to the following:

  • Script efficiency, readability, and maintainability.
  • Usage of environmental variables and configuration files for flexibility.
  • Integration with NX workspace utilities and commands."
scripts/ci/get-node-version.mjs (1)

Pattern scripts/**/*: "Confirm that the code adheres to the following:

  • Script efficiency, readability, and maintainability.
  • Usage of environmental variables and configuration files for flexibility.
  • Integration with NX workspace utilities and commands."
scripts/ci/Dockerfile (1)

Pattern scripts/**/*: "Confirm that the code adheres to the following:

  • Script efficiency, readability, and maintainability.
  • Usage of environmental variables and configuration files for flexibility.
  • Integration with NX workspace utilities and commands."
Additional comments not posted (13)
scripts/ci/_common.mjs (1)

8-11: The implementation of getPackageJSON is clean and follows modern JavaScript practices.

scripts/ci/10_prepare-docker-deps.sh (1)

Line range hint 11-27: The script effectively uses dynamic Node.js image tags to enhance flexibility in Docker builds.

.github/actions/unit-test/action.yml (1)

39-41: Updated Node.js setup action to v4 and dynamically set the node version from package.json. Ensure that this change integrates well with other workflows and that the specified Node.js version is compatible with all dependencies.

scripts/ci/Dockerfile (1)

4-5: Introduced NODE_IMAGE_TAG to dynamically specify the Node.js version. This aligns with the PR's goal to upgrade Node.js versions.

.github/workflows/config-values.yaml (1)

64-66: Updated Node.js setup action to v4 and dynamically set the node version from package.json. Ensure that this change integrates well with other workflows and that the specified Node.js version is compatible with all dependencies.

Also applies to: 112-114

.github/workflows/pullrequest.yml (1)

48-50: Updated Node.js setup action to v4 and dynamically set the node version from package.json across multiple jobs. Ensure that this change integrates well with other workflows and that the specified Node.js version is compatible with all dependencies.

Also applies to: 83-85, 247-249, 308-310, 371-373, 414-416, 458-460, 507-509

.github/workflows/push.yml (7)

172-174: The update to actions/setup-node@v4 and the use of node-version-file: 'package.json' aligns with best practices for dynamic Node.js version management.


290-292: Using get-node-modules-hash.mjs for calculating the cache key is a good practice as it likely considers multiple factors to ensure a unique and relevant key.


650-650: The use of NODE_IMAGE_TAG in the Docker build process ensures consistency with the Node.js version used. This is a good practice for maintaining version alignment.


318-320: Setting the TEST_EVERYTHING environment variable based on PR labels is a flexible way to control test execution. However, ensure that the label is being applied as expected.

Verification successful

The 'test everything' label is applied correctly in PRs.

  • PR with ID 14968 has the 'test everything' label applied.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the 'test everything' label is applied correctly in PRs.

# Test: Check for PRs with the label applied. Expect: Correct application of the label.
gh pr list --label "test everything"

Length of output: 121


239-247: The script to generate the NODE_IMAGE_TAG using get-node-version.mjs is a robust approach to handle Node.js versioning dynamically. Ensure that the script handles errors gracefully.

Verification successful

The get-node-version.mjs script includes error handling mechanisms, such as logging errors with console.error and throwing errors with throw new Error. These mechanisms ensure that errors are reported and handled appropriately.

  • The script logs an error message when it fails to get the Docker image for a specific Node.js version.
  • It catches errors during the fetch operation and logs a detailed error message.
  • It throws an error if it cannot find the Node.js version, ensuring that the failure is propagated and can be handled by the calling process.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify error handling in the get-node-version.mjs script.

# Test: Check for error handling in the script. Expect: Proper error handling mechanisms.
cat scripts/ci/get-node-version.mjs | grep -i 'error'

Length of output: 247


51-51: Ensure the NODE_IMAGE_TAG is consistently used across all jobs and steps.

Verification successful

The NODE_IMAGE_TAG is used consistently across various steps and contexts within the .github/workflows/push.yml file. It is set and referenced in multiple places, ensuring that the same value is used throughout the workflow.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that NODE_IMAGE_TAG is used consistently across all jobs and steps.

# Test: Search for the usage of NODE_IMAGE_TAG. Expect: Consistent usage across the file.
rg --type yaml 'NODE_IMAGE_TAG' .github/workflows/push.yml

Length of output: 1465


386-386: The script 10_prepare-docker-deps.sh is crucial for preparing Docker dependencies. Ensure it is optimized for performance and correctly handles all necessary dependencies.

Verification successful

The 10_prepare-docker-deps.sh script, along with its dependencies (_common.sh and Dockerfile), appears to be well-structured and optimized for performance. The script sets strict error handling, ensures necessary directories are created, dynamically determines the Node.js image tag, and uses Docker Buildx with caching to optimize builds. The _common.sh script sets up environment variables and project root, while the Dockerfile handles various stages of the build process, including dependency installation and caching.

  • The 10_prepare-docker-deps.sh script is optimized for performance with caching mechanisms.
  • The _common.sh script correctly handles necessary environment variables and project setup.
  • The Dockerfile includes all necessary dependencies and stages for building the Docker images.

No further issues were found regarding performance optimization and dependency handling.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the contents and performance of the 10_prepare-docker-deps.sh script.

# Test: Check the script for performance optimization and dependency handling. Expect: Optimized performance and complete dependency handling.
cat scripts/ci/10_prepare-docker-deps.sh

Length of output: 864



Script:

#!/bin/bash
# Description: Verify the contents of the _common.sh script and the Dockerfile used in 10_prepare-docker-deps.sh.

# Test: Check the _common.sh script for dependency handling.
echo "Contents of _common.sh:"
cat scripts/ci/_common.sh

# Test: Check the Dockerfile for dependency handling.
echo "Contents of Dockerfile:"
cat scripts/ci/Dockerfile

Length of output: 4682

.github/workflows/push.yml Show resolved Hide resolved
infra/scripts/Dockerfile Show resolved Hide resolved
.github/actions/main.ts Show resolved Hide resolved
scripts/ci/Dockerfile Show resolved Hide resolved
scripts/ci/get-node-modules-hash.mjs Show resolved Hide resolved
scripts/ci/get-node-version.mjs Show resolved Hide resolved
Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.13%. Comparing base (714e7d2) to head (84266f6).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #14968   +/-   ##
=======================================
  Coverage   37.13%   37.13%           
=======================================
  Files        6373     6373           
  Lines      129702   129701    -1     
  Branches    36999    37000    +1     
=======================================
+ Hits        48160    48161    +1     
+ Misses      81542    81540    -2     
Flag Coverage Δ
api 3.46% <ø> (ø)
api-catalogue-services 77.85% <ø> (ø)
api-domains-communications 40.56% <ø> (ø)
api-domains-criminal-record 43.44% <ø> (ø)
api-domains-mortgage-certificate 34.78% <ø> (ø)
api-domains-payment-schedule 40.23% <ø> (ø)
application-system-api 41.96% <ø> (ø)
application-template-api-modules 24.32% <ø> (+0.01%) ⬆️
application-templates-accident-notification 19.67% <ø> (ø)
application-templates-driving-license 16.47% <ø> (ø)
application-templates-example-payment 20.49% <ø> (ø)
application-templates-financial-aid 11.95% <ø> (ø)
application-templates-general-petition 19.14% <ø> (ø)
application-templates-health-insurance 23.10% <ø> (ø)
application-templates-inheritance-report 3.96% <ø> (ø)
application-templates-parental-leave 28.43% <ø> (ø)
clients-rsk-company-registry 29.24% <ø> (ø)
email-service 61.42% <ø> (ø)
services-auth-admin-api 51.99% <ø> (ø)
services-auth-delegation-api 61.79% <ø> (ø)
services-auth-ids-api 54.16% <ø> (+0.14%) ⬆️
shared-form-fields 31.87% <ø> (ø)
shared-mocking 64.62% <ø> (ø)
shared-pii 92.85% <ø> (ø)
shared-problem 87.50% <ø> (ø)
web 1.91% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 714e7d2...84266f6. Read the comment docs.

@lodmfjord lodmfjord changed the title Upgrade node version chore: upgrade node version May 28, 2024
@datadog-island-is
Copy link

datadog-island-is bot commented May 28, 2024

Datadog Report

All test runs 357f2b4 🔗

101 Total Test Services: 0 Failed, 99 Passed
🔻 Test Sessions change in coverage: 9 decreased, 10 increased, 89 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 81 0 43.46s N/A Link
air-discount-scheme-web 0 0 0 2 0 11.97s N/A Link
api 0 0 0 4 0 4.69s N/A Link
api-catalogue-services 0 0 0 23 0 15.94s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 39.87s N/A Link
api-domains-assets 0 0 0 3 0 26.66s N/A Link
api-domains-auth-admin 0 0 0 18 0 13.68s N/A Link
api-domains-communications 0 0 0 5 0 49.21s N/A Link
api-domains-criminal-record 0 0 0 5 0 17.92s N/A Link
api-domains-driving-license 0 0 0 23 0 57.37s N/A Link

🔻 Code Coverage Decreases vs Default Branch (9)

This report shows up to 5 code coverage decreases.

  • file-storage - jest 54.94% (-0.51%) - Details
  • feature-flags - jest 91.58% (-0.31%) - Details
  • judicial-system-message-handler - jest 71.29% (-0.12%) - Details
  • application-template-api-modules - jest 26.14% (-0.11%) - Details
  • judicial-system-xrd-api - jest 74.46% (-0.07%) - Details

Copy link
Member

@brynjarorng brynjarorng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lodmfjord lodmfjord added deprecated:automerge (Disabled) Merge this PR as soon as all checks pass high priority VIP-Kodiak PR labels May 28, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2108b5e and 84266f6.
Files selected for processing (2)
  • .github/workflows/push.yml (15 hunks)
  • scripts/ci/_nx-affected-targets.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • scripts/ci/_nx-affected-targets.sh
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/push.yml

@kodiakhq kodiakhq bot merged commit a40e348 into main May 28, 2024
493 checks passed
@kodiakhq kodiakhq bot deleted the upgrade-node-version branch May 28, 2024 14:01
@lodmfjord lodmfjord restored the upgrade-node-version branch May 28, 2024 14:44
lodmfjord added a commit that referenced this pull request May 28, 2024
lodmfjord added a commit that referenced this pull request May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-feature Deploys features to dev deprecated:automerge (Disabled) Merge this PR as soon as all checks pass high priority VIP-Kodiak PR test everything 💀 test & build everything 💀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants