Skip to content

Commit

Permalink
Remove home-rolled yarn caching (facebook#48237)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#48237

Noticed this when trying to diagnose what seemed like a stale caching issue. It effectively reverts D59917944.

D59917944 added logic to only do yarn caching on main, but it has some correctness issues:
1. We cache `node_modules` instead of the yarn cache, which may contain e.g. build artifacts, or other scratch/cache files written (such as anything that writes to `node_modules/.cache`). We really want to be caching the yarn cache, which has pristine packages before install, which I think it will also need to perform the real install anyways.
2. We key the cache on root `package.json`, which is missing a lot of information (both provided by the other `package.json` in the repo, but mostly, the lockfile resolution).

We only save cache when we're on `refs/heads/main` (so continuous builds against main), and supposedly, builds against base branch should be able to restore against those, but recent PR jobs I have seen, where `package.json` has not changed, all have `Cache not found for input keys: node-modules-068350889e87919c1c6c2c220c8d2d92db13f38820bf2efb315d1274b97bc367`

Because of the potential correctness issues, and that the strategy for limiting to main seemingly is not allowing cache to be used in PR, this diff goes back to previous solution, which may store more artifacts (but working cache should also reduce cost by making jobs run faster).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D67140004

fbshipit-source-id: f74074a498af56b1837fa23cf80795f76935b762
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Dec 12, 2024
1 parent 9f4b4ab commit a28867f
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Install node dependencies
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Set React Native Version
shell: bash
run: node ./scripts/releases/set-rn-artifacts-version.js --build-type ${{ inputs.release-type }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-hermes-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ runs:
fi
- name: Yarn- Install Dependencies
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Slice cache macosx
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/download-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-npm-package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ runs:
- name: Setup gradle
uses: ./.github/actions/setup-gradle
- name: Install dependencies
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Build packages
shell: bash
run: yarn build
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/create-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ runs:
using: composite
steps:
- name: Yarn install
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Configure Git
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/prepare-hermes-workspace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ runs:
- name: Yarn- Install Dependencies
if: ${{ steps.meaningful-cache.outputs.HERMES_CACHED != 'true' }}
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install

- name: Download Hermes tarball
if: ${{ steps.meaningful-cache.outputs.HERMES_CACHED != 'true' }}
Expand Down
1 change: 1 addition & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ runs:
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: yarn
2 changes: 1 addition & 1 deletion .github/actions/test-ios-helloworld/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ runs:
shell: bash
run: ls -lR "$HERMES_WS_DIR"
- name: Run yarn
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Setup ruby
uses: ruby/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/test-ios-rntester/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ runs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run yarn
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Download Hermes
uses: actions/download-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/test-js/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
with:
node-version: ${{ inputs.node-version }}
- name: Yarn install
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Run Tests - JavaScript Tests
shell: bash
run: node ./scripts/run-ci-javascript-tests.js --maxWorkers 2
Expand Down
28 changes: 0 additions & 28 deletions .github/actions/yarn-install-with-cache/action.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .github/actions/yarn-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: yarn-install
runs:
using: composite
steps:
- name: Install dependencies
shell: bash
run: yarn install --non-interactive --frozen-lockfile
2 changes: 1 addition & 1 deletion .github/workflows/publish-bumped-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run Yarn Install
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Build packages
run: yarn build
- name: Set NPM auth token
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ jobs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run yarn
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Setup ruby
uses: ruby/[email protected]
with:
Expand Down Expand Up @@ -320,7 +320,7 @@ jobs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run yarn
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
Expand Down Expand Up @@ -451,7 +451,7 @@ jobs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Install node dependencies
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Download APK
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -533,7 +533,7 @@ jobs:
- name: Setup gradle
uses: ./.github/actions/setup-gradle
- name: Run yarn install
uses: ./.github/actions/yarn-install-with-cache
uses: ./.github/actions/yarn-install
- name: Prepare the Helloworld application
shell: bash
run: node ./scripts/e2e/init-project-e2e.js --useHelloWorld --pathToLocalReactNative "$GITHUB_WORKSPACE/build/$(cat build/react-native-package-version)"
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/update-node-modules-cache.yml

This file was deleted.

0 comments on commit a28867f

Please sign in to comment.