Reputation: 27
Here I have a simple react app created with npx create-react-app.
The pipeline successfully extracts the cache but fails on yarn test --watchAll=false
with error "/bin/sh: 1: react-scripts: not found".
How do I fix this?.
The react app is located in a src/client directory hence the before_script to cd in the correct directory as seen in the yml file below.
.gitlab-ci.yml:
image: node:latest
default:
before_script:
- cd src/client
stages:
- build
- test
cache:
paths:
- node_modules/
build_react:
stage: build
script:
- yarn install
- yarn build
artifacts:
expire_in: 1 hour
paths:
- build
test_react:
stage: test
script:
- pwd
- yarn test --watchAll=false
Upvotes: 0
Views: 2223
Reputation: 7679
Artifacts are downloaded and extracted before any scripts are run, so it'll be extracted to{project_root}/
, then your default before_script will run. You should be able to reference the build directory by ../../build
, or move it to src/client
in your test_react
job.
Upvotes: 1