Skip to content

Commit

Permalink
[CI] Improve yarn's performance in workflows by caching yarn's cache …
Browse files Browse the repository at this point in the history
…folder

Signed-off-by: Miki <[email protected]>
  • Loading branch information
AMoo-Miki committed Jan 6, 2023
1 parent 303e3bd commit 7f8cb42
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 12 deletions.
105 changes: 93 additions & 12 deletions .github/workflows/build_and_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ jobs:
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Run bootstrap
run: yarn osd bootstrap
Expand Down Expand Up @@ -103,14 +116,22 @@ jobs:
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
# 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: Run linter
id: linter
Expand Down Expand Up @@ -164,6 +185,19 @@ jobs:
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Setup chromedriver
run: node scripts/upgrade_chromedriver.js
Expand Down Expand Up @@ -223,17 +257,25 @@ jobs:
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
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
Expand Down Expand Up @@ -291,6 +333,19 @@ jobs:
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Get package version
run: |
Expand Down Expand Up @@ -347,6 +402,19 @@ jobs:
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Get package version
run: |
Expand Down Expand Up @@ -401,6 +469,19 @@ jobs:
run: |
npm uninstall -g yarn
npm i -g [email protected]
yarn config set network-timeout 1000000 -g
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Get package version
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,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

Expand Down

0 comments on commit 7f8cb42

Please sign in to comment.