The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Do not include already patched libraries in node_modules cache (#65052)
Nemanja Glumacfcd7a987459f
diff --git a/.github/actions/prepare-frontend/action.yml b/.github/actions/prepare-frontend/action.ymlindex 789acde9d0c..ad655d6a1eb 100644--- a/.github/actions/prepare-frontend/action.yml+++ b/.github/actions/prepare-frontend/action.yml@@ -3,6 +3,10 @@ inputs:node-version:description: "The version of Node.js to use, overriding .nvmrc"required: false+ apply-patches:+ description: "Whether to patch frontend dependencies with patch-package."+ required: true+ default: 'true'runs:using: "composite"steps:@@ -31,5 +35,13 @@ runs:path: node_moduleskey: ${{ steps.get-cache-keys.outputs.node-cache-key }}- - run: yarn install --frozen-lockfile --prefer-offline+ # postinstall lifecycle hook can be dangerous in CI so we only run it locally (see package.json)+ # If a job wants to patch packages, it does so explicitly in the CI. This setting is opt-out.+ # For example, we never want to cache node_modules with patches already applied so cache-generator.yml skips that step.+ - name: Clean install+ run: yarn install --frozen-lockfile --prefer-offline+ shell: bash+ - name: Patch frontend dependencies+ if: inputs.apply-patches == 'true'+ run: yarn patch-packageshell: bashdiff --git a/.github/workflows/cache-generator.yml b/.github/workflows/cache-generator.ymlindex 2f09e7aa0b9..3c321d80c1d 100644--- a/.github/workflows/cache-generator.yml+++ b/.github/workflows/cache-generator.yml@@ -83,8 +83,14 @@ jobs:- uses: actions/checkout@v4# `prepare-frontend` action (1) prepares Node.js and (2) fetches the node_modules cache if it exists.# It then (3) runs `yarn install --frozen-lockfile --prefer-offline` which ensures the local cache is fully populated.+ # IMPORTANT: Caching node_modules after patches are already applied will break any PR that attempts to either:+ # - upgrade a patched library+ # - change a patch+ # Hence why we explicitly exclude patches from the cache (controlled by the `apply-patches` action input).- name: Install front-end dependenciesuses: ./.github/actions/prepare-frontend+ with:+ apply-patches: 'false'- name: Update node_modules cacheuses: ./.github/actions/update-cachediff --git a/package.json b/package.jsonindex ee2d1913e5b..ef45ef7b3e2 100644--- a/package.json+++ b/package.json@@ -467,7 +467,7 @@"lint-prettier": "yarn && yarn lint-prettier-pure","lint-prettier-pure": "prettier --check '{frontend,enterprise/frontend,e2e}/**/*.{js,jsx,ts,tsx,css}'","lint-yaml": "yamllint **/*.{yaml,yml} --ignore=node_modules/**/*.{yaml,yml}",- "postinstall": "yarn patch-package",+ "postinstall": "if [ -z \"$CI\" ]; then yarn dedupe && yarn patch-package; fi","precommit": "lint-staged --shell","preinstall": "echo $npm_execpath | grep -q yarn || echo '\\033[0;33mSorry, npm is not supported. Please use Yarn (https://yarnpkg.com/).\\033[0m'","prepare": "husky install",