From 20faf897c9152db76e0bb37ac74be6a5f47f6a2f Mon Sep 17 00:00:00 2001 From: Bryan Date: Mon, 14 Mar 2022 11:49:49 -0700 Subject: [PATCH] fix: Test flake when installing yarn dependencies on MacOS (#436) This fixes #433 - a test flake in E2E (intermittent `ESOCKETTIMEDOUT` errors on MacOS). The main issue is that, occasionally, for very large dependencies (like `@material-ui/icons`) - yarn can actually time out! We researched this in-depth in v1: https://github.com/coder/m/pull/10040 and fixed it successfully there, by increasing the timeout for yarn. However, this also highlighted the fact that our `node_modules` caching behavior wasn't correct - we should very rarely see a timeout issue like this, because `@material-ui/icons` should be cached. It turns out that we weren't falling back to the latest cached `node_modules` if there was a miss - so anytime the lock file changed, we'd invalidate the cache, and not restore the previous one. This can be improved by using the [`restore-keys`](https://github.com/coder/m/pull/10040) parameter of the [`@actions/cache`](https://github.com/actions/cache)... and in fact we already do this for the `go` dependencies. So this fix does two things: - Improve the caching behavior, such that we should rarely have to install `@material-ui/icons` (and other large dependencies) - When we do have to install, update the timeout so that we can avoid random `ESOCKETTIMEDOUT` errors --- .github/workflows/coder.yaml | 8 ++++++++ site/.yarnrc | 1 + 2 files changed, 9 insertions(+) create mode 100644 site/.yarnrc diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index d0afed5280..de216cbae2 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -61,6 +61,8 @@ jobs: **/node_modules .eslintcache key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + js-${{ runner.os }}- - name: Install node_modules run: ./scripts/yarn_install.sh @@ -108,6 +110,8 @@ jobs: **/node_modules .eslintcache key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + js-${{ runner.os }}- - name: Install node_modules run: ./scripts/yarn_install.sh @@ -250,6 +254,8 @@ jobs: **/node_modules .eslintcache key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + js-${{ runner.os }}- # Go is required for uploading the test results to datadog - uses: actions/setup-go@v2 @@ -312,6 +318,8 @@ jobs: **/node_modules .eslintcache key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + js-${{ runner.os }}- # Go is required for uploading the test results to datadog - uses: actions/setup-go@v2 diff --git a/site/.yarnrc b/site/.yarnrc new file mode 100644 index 0000000000..d7d9c737a6 --- /dev/null +++ b/site/.yarnrc @@ -0,0 +1 @@ +network-timeout 300000