From b57f3cc83bdd58588bf956a781e7ad45645fd8f5 Mon Sep 17 00:00:00 2001 From: Miki Date: Fri, 6 Jan 2023 11:07:17 -0800 Subject: [PATCH] [CI] Improve yarn's performance in workflows by caching yarn's cache folder (#3194) Signed-off-by: Miki Signed-off-by: Miki Co-authored-by: Qingyang(Abby) Hu --- .github/workflows/build_and_test_workflow.yml | 104 ++++++++++++++++-- CHANGELOG.md | 1 + 2 files changed, 93 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_and_test_workflow.yml b/.github/workflows/build_and_test_workflow.yml index f9e54b445373..3a3399a66a8a 100644 --- a/.github/workflows/build_and_test_workflow.yml +++ b/.github/workflows/build_and_test_workflow.yml @@ -45,6 +45,18 @@ jobs: run: | npm uninstall -g yarn npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- - name: Run bootstrap run: yarn osd bootstrap @@ -103,14 +115,23 @@ jobs: run: | npm uninstall -g yarn npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g - # https://github.com/yarnpkg/yarn/issues/8242#issuecomment-776561223 - # Increase network timeout for Windows, retry once if bootstrap fails - - name: Run bootstrap + - name: Configure Yarn Cache run: | - yarn cache clean - yarn config set network-timeout 1000000 -g - yarn osd bootstrap || yarn osd bootstrap + echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- + + - name: Run bootstrap + run: yarn osd bootstrap || yarn osd bootstrap - name: Run linter id: linter @@ -164,6 +185,18 @@ jobs: run: | npm uninstall -g yarn npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- - name: Setup chromedriver run: node scripts/upgrade_chromedriver.js @@ -223,17 +256,26 @@ jobs: run: | npm uninstall -g yarn npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: | + echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- - name: Setup chromedriver run: node scripts/upgrade_chromedriver.js - # https://github.com/yarnpkg/yarn/issues/8242#issuecomment-776561223 - # Increase network timeout for Windows, retry once if bootstrap fails - name: Run bootstrap - run: | - yarn cache clean - yarn config set network-timeout 1000000 -g - yarn osd bootstrap || yarn osd bootstrap + run: yarn osd bootstrap || yarn osd bootstrap - name: Build plugins run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10 @@ -291,6 +333,18 @@ jobs: run: | npm uninstall -g yarn npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- - name: Get package version run: | @@ -347,6 +401,20 @@ jobs: run: | npm uninstall -g yarn npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: | + echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- - name: Get package version run: | @@ -401,6 +469,18 @@ jobs: run: | npm uninstall -g yarn npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- - name: Get package version run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 1270569d2a45..e4e94748ce6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,6 +94,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Add Windows CI workflows ([#2966](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2966)) - Add automatic selection of the appropriate version of chrome driver to run functional tests ([#2990](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2990)) - Add recording of functional test artifacts if they fail ([#3190](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3190)) +- Improve yarn's performance in workflows by caching yarn's cache folder ([#3194](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3194)) ### 📝 Documentation