Fix/yarn cache node16
GitLab CI lacks a definitive or clear method for deleting, invalidating, or refreshing a job cache beyond its baseline behavior. Leveraging the existing cache behavior, the cache is invalidated when the key changes – in our scenario, the files should undergo changes. However, as this doesn't naturally occur, I considered a workaround: deleting the cached files if the criteria for cache invalidation are met.
Deleting the cache files is inefficient because the job can prevent their download. Nevertheless, it is effective due to the absence of alternative approaches. In this way, the job can run successfully even if the cache has any issues with the new job version. Specifically, since Node.js 16 is a breaking change for the current yarn cached files, it would fail unless the cache is cleared.
Additionally, incorporating the Node.js version as a criterion ensures that in the future, this invalidation will occur automatically. Introducing an environment variable provides a mechanism to trigger cache invalidation for the job if the breaking change is within the Bash script itself.