chore: fix flaky smoke tests on yarn#2764
Conversation
|
Coverage Report
File CoverageNo changed files found. |
|
| with: | ||
| node-version: 24 | ||
| - run: bash ./tests/smoke/basic/run-smoke.sh "npm i redoc redocly-cli.tgz" "npm run" | ||
| - run: bash ./tests/smoke/basic/run-smoke.sh "npm install && npm i redoc" "npm run" |
There was a problem hiding this comment.
This doesn't make any difference but the intention becomes less clear.
There was a problem hiding this comment.
I wanted to use yarn install instead of yarn add to fix the issue, so i added into package.json dependency, which points to the tgz cli file. I changed all tests to use just install and be consistent across the tests.
| - run: | | ||
| for i in {1..2}; do # workaround for yarn cache issue | ||
| sleep 5 && bash ./tests/smoke/basic/run-smoke.sh "yarn add ./redocly-cli.tgz" "yarn" && break | ||
| sleep 5 && bash ./tests/smoke/basic/run-smoke.sh "yarn install --no-lockfile" "yarn" && break |
There was a problem hiding this comment.
What does this change? There's no lockfile before the install, and we're installing the dependencies only once during this job, so having or not having the lockfile should change nothing.
There was a problem hiding this comment.
You are right. Let me drop this arg and re-ran tests, because my concern is that we are running yarn install and then yarn add redoc and the second command may overwrite the lock file and @redocly/config as a result.
| @@ -0,0 +1,16 @@ | |||
| #!/bin/bash | |||
|
|
|||
| REDOCLY_CONFIG_VERSION=$(node -e "const fs = require('fs'); const p = JSON.parse(fs.readFileSync('./packages/core/package.json', 'utf8')); console.log(p.dependencies['@redocly/config'].replace(/\^/, ''));") | |||
There was a problem hiding this comment.
We're emulating something that will not be the case in our users' setup, so the smokes become irrelevant. Let's try keeping them as much close to the reality as possible.
There was a problem hiding this comment.
This bash script read the version of @redocly/config from openapi-core and write this version to package.json of smoke tests to override this dep to be sure, that all tests will resolve proper version of @redocly/config. Users will resolve the same version of @redocly/config. My first try to fix this issue is manually adding this properties to the package.json, but we can forget to change it there, so i decided to create a script.
There was a problem hiding this comment.
Let's discuss this offine.
| # Executing the command provided as the first argument | ||
| $1 | ||
| # Executing the command provided as the first argument | ||
| eval "$1" |
There was a problem hiding this comment.
Before this change, smoke tests became unstable, because we are using && operator to install redoc dep: yarn install && yarn add redoc. Using eval i can support this operator
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9fa6b3c. Configure here.

What/Why/How?
I found the root cause of the failing tests. Old
redocdependency has av0.22.0version of@redocly/configand yarn tries to resolve this version instead of latest.The root cause: Yarn v1's flat-hoisting is non-deterministic when the install graph contains two incompatible versions of the same package.
Changes:
yarn installand useyarn addonly forredoc. Becauseyarnadd doesn't respectresolutionsproperty inpackage.json, which overrides deps.*.tgzfile inpackage.json.pin-config-version.shscript to read version of@redocly/configand@redocly/ajvfromopenapi-coreand write proper version topackage.jsonfor smoke tests.package.json.try catch, because bash exiting non-zero doesn't throw — it sets $LASTEXITCODE. The old catch block would never fire, so on the final attempt the step would exit 0 and the job would be reported.After changes we have only tiny warning, which means, that the version now resolves properly.
warning Resolution field "@redocly/config@0.48.1" is incompatible with requested version "@redocly/config@0.22.0"Reference
Resolves #2618
Testing
Ran 10 times smoke tests on this PR
Screenshots (optional)
When test failed:

When test passed:

Check yourself
Security
Note
Low Risk
Low risk: changes are limited to CI smoke-test setup and dependency installation behavior, with no production code impact. Main risk is unintended CI breakage due to new install/pinning steps across npm/yarn/pnpm and Windows runners.
Overview
Refactors the smoke-test GitHub Actions workflow to stop installing the CLI tarball via
addand instead runnpm/yarn/pnpm install, with a dedicated step to injectredoconly for the--redocmatrix jobs.Adds a smoke-test
package.jsondependency on@redocly/cliviafile:./redocly-cli.tgz, plus scripts (pin-intersecting-deps.sh,add-redoc.sh) to pin@redocly/config/@redocly/ajvvia Yarnresolutionsand to addredoc@latestto avoid non-deterministic Yarn v1 hoisting.Improves Windows smoke jobs by clearing npm cache and retrying installs correctly (removing ineffective
try/catchand exiting with the final failure code).Reviewed by Cursor Bugbot for commit 92985f2. Bugbot is set up for automated code reviews on this repo. Configure here.