From 95a7b4497ea400fc280840b0a671dc185c268f1d Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 5 Sep 2023 10:27:27 -0700 Subject: [PATCH] Enable GitHub Actions Yarn Caching (#1332) Summary: We sometimes see workflows fail due to network flakiness, almost always being Windows agents doing a `yarn install`. This change enables storing and reusing Yarn's package cache, and makes `yarn install` more permissive when it does hit the network. https://stackoverflow.com/questions/51508364/yarn-there-appears-to-be-trouble-with-your-network-connection-retrying Pull Request resolved: https://github.com/facebook/yoga/pull/1332 Test Plan: Workflows succeed, and we see cache being restored before yarn install step. Reviewed By: lunaleaps Differential Revision: D48967590 Pulled By: NickGerleman fbshipit-source-id: 55ce6f05496f014512e0153b6646a7ca0ab964d9 --- .github/actions/setup-js/action.yml | 15 ++++++++++----- .github/actions/setup-website/action.yml | 11 ++++++++--- .github/workflows/validate-js.yml | 9 ++++----- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/actions/setup-js/action.yml b/.github/actions/setup-js/action.yml index 31159165..c3140d72 100644 --- a/.github/actions/setup-js/action.yml +++ b/.github/actions/setup-js/action.yml @@ -3,17 +3,22 @@ name: Setup JavaScript envirionment runs: using: "composite" steps: - - name: Install Node - uses: actions/setup-node@v1 - with: - node-version: 18.x - - name: Install emsdk uses: ./.github/actions/install-emsdk - name: Install Ninja uses: ./.github/actions/install-ninja + - name: Setup Node environment + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: yarn + cache-dependency-path: yarn.lock + env: + # https://github.com/actions/setup-node/issues/317 + FORCE_COLOR: 0 + - name: yarn install shell: bash run: yarn install --frozen-lockfile diff --git a/.github/actions/setup-website/action.yml b/.github/actions/setup-website/action.yml index 0473cee3..b255d06b 100644 --- a/.github/actions/setup-website/action.yml +++ b/.github/actions/setup-website/action.yml @@ -5,14 +5,19 @@ runs: steps: # TODO: Update to latest when website is moved to the workspace version of # yoga-layout - - name: Install Node - uses: actions/setup-node@v1 + - name: Setup Node environment + uses: actions/setup-node@v3 with: node-version: 12.x + cache: yarn + cache-dependency-path: website/yarn.lock + env: + # https://github.com/actions/setup-node/issues/317 + FORCE_COLOR: 0 # TODO: the website should be in a yarn workspace with the library, but the # current version of gatsby is incompatible with hoisting. - name: yarn install shell: bash - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile --network-timeout 1000000 working-directory: website diff --git a/.github/workflows/validate-js.yml b/.github/workflows/validate-js.yml index d3ee8392..fa26dbca 100644 --- a/.github/workflows/validate-js.yml +++ b/.github/workflows/validate-js.yml @@ -65,8 +65,8 @@ jobs: steps: - uses: actions/checkout@v3 - - name: yarn install - run: yarn install --frozen-lockfile + - name: Setup + uses: ./.github/actions/setup-js - name: yarn lint run: yarn lint @@ -77,9 +77,8 @@ jobs: steps: - uses: actions/checkout@v3 - - name: yarn install - run: yarn install --frozen-lockfile - working-directory: javascript + - name: Setup + uses: ./.github/actions/setup-js - name: yarn tsc run: yarn tsc