cypress-io / netlify-plugin-cypress

Runs Cypress end-to-end tests after Netlify builds the site but before it is deployed
https://www.cypress.io/blog/2020/03/30/run-cypress-tests-on-netlify-using-a-single-line/
MIT License
89 stars 39 forks source link

Tests never start to run in prebuild (Gatsby dev server) #76

Closed philschonholzer closed 3 years ago

philschonholzer commented 4 years ago

Versions

{
    "@testing-library/cypress": "^6.0.0",
    "cypress": "^4.11.0",
    "cypress-axe": "^0.8.1",
    "eslint-plugin-cypress": "^2.11.1",
    "netlify-plugin-cypress": "^1.4.1",
}

Build image: Ubuntu Xenial 16.04 (default) Now using node v14.7.0 (npm v6.14.7)

Describe the bug

I'm deploying a gatsby page and trying to have the prebuild tests running. After the local server is running the test never start until netlify cancels the build: Build exceeded maximum allowed runtime As you can see in the log the local server is started on 11:54:48 AM and finishes on 11:55:23 AM sot the 45 seconds timeout should be enough time.

# netlify.toml
[build]
command = "npm run build"
publish = "public"

[build.environment]
# cache Cypress binary in local "node_modules" folder
# so Netlify caches it
CYPRESS_CACHE_FOLDER = "./node_modules/CypressBinary"
# set TERM variable for terminal output
TERM = "xterm"

[[plugins]]
# local Cypress plugin will test our site after it is built
  package = "netlify-plugin-cypress"
  [plugins.inputs.preBuild]
    start = 'npm run start:mock'
    wait-on = 'http://localhost:8000/'
    wait-on-timeout = '45' # seconds
    record = true

Logs and screenshots

11:52:58 AM: Waiting for other deploys from your team to complete
11:53:13 AM: Build ready to start
11:53:19 AM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
11:53:19 AM: build-image tag: v3.3.20
11:53:19 AM: buildbot version: 0ee111aa6b75403f01f5d27b0a6736d30a2da28c
11:53:19 AM: Fetching cached dependencies
11:53:19 AM: Starting to download cache of 457.0MB
11:53:21 AM: Finished downloading cache in 2.029026656s
11:53:21 AM: Starting to extract cache
11:53:47 AM: Finished extracting cache in 25.805533849s
11:53:47 AM: Finished fetching cache in 27.983111763s
11:53:47 AM: Starting to prepare the repo for build
11:53:48 AM: Preparing Git Reference refs/heads/develop
11:53:53 AM: Starting build script
11:53:53 AM: Installing dependencies
11:53:53 AM: Python version set to 2.7
11:53:54 AM: Started restoring cached node version
11:53:59 AM: Finished restoring cached node version
11:53:59 AM: Attempting node version 'v14' from .nvmrc
11:53:59 AM: v14.7.0 is already installed.
11:54:00 AM: Now using node v14.7.0 (npm v6.14.7)
11:54:00 AM: Started restoring cached build plugins
11:54:00 AM: Finished restoring cached build plugins
11:54:00 AM: Attempting ruby version 2.6.2, read from environment
11:54:02 AM: Using ruby version 2.6.2
11:54:02 AM: Using PHP version 5.6
11:54:03 AM: 5.2 is already installed.
11:54:03 AM: Using Swift version 5.2
11:54:03 AM: Started restoring cached node modules
11:54:03 AM: Finished restoring cached node modules
11:54:03 AM: Installing NPM modules using NPM version 6.14.7
11:54:28 AM: npm WARN @pmmmwh/react-refresh-webpack-plugin@0.3.3 requires a peer of react-refresh@^0.8.2 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN @testing-library/react-hooks@1.0.4 requires a peer of react-test-renderer@>=16.8.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN babel-preset-gatsby@0.5.4 requires a peer of core-js@^3.0.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-config-airbnb-base@14.1.0 requires a peer of eslint@^5.16.0 || ^6.8.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-config-blvd@1.0.2 requires a peer of eslint@^6.1.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN @typescript-eslint/eslint-plugin@2.14.0 requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN @typescript-eslint/parser@2.14.0 requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-config-airbnb@18.0.1 requires a peer of eslint@^5.16.0 || ^6.1.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-plugin-react-hooks@1.7.0 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-config-react-app@5.2.1 requires a peer of @typescript-eslint/eslint-plugin@2.x but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-config-react-app@5.2.1 requires a peer of @typescript-eslint/parser@2.x but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-config-react-app@5.2.1 requires a peer of eslint@6.x but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-config-react-app@5.2.1 requires a peer of eslint-plugin-react-hooks@1.x || 2.x but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN eslint-loader@2.2.1 requires a peer of eslint@>=1.6.0 <7.0.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN react-hooks-testing-library@0.6.0 requires a peer of react-test-renderer@^16.8.0 but none is installed. You must install peer dependencies yourself.
11:54:28 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/chokidar/node_modules/fsevents):
11:54:28 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
11:54:28 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/jest-haste-map/node_modules/fsevents):
11:54:28 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
11:54:28 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/watchpack/node_modules/fsevents):
11:54:28 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
11:54:28 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
11:54:28 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
11:54:28 AM: added 139 packages from 38 contributors and audited 3801 packages in 24.56s
11:54:31 AM: 181 packages are looking for funding
11:54:31 AM:   run `npm fund` for details
11:54:31 AM: found 364 vulnerabilities (362 low, 2 high)
11:54:31 AM:   run `npm audit fix` to fix them, or `npm audit` for details
11:54:31 AM: NPM modules installed
11:54:31 AM: Started restoring cached go cache
11:54:33 AM: Finished restoring cached go cache
11:54:33 AM: Installing Go version 1.12
11:54:33 AM: unset GOOS;
11:54:33 AM: unset GOARCH;
11:54:33 AM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64';
11:54:33 AM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64/bin:${PATH}";
11:54:33 AM: go version >&2;
11:54:33 AM: export GIMME_ENV='/opt/buildhome/.gimme_cache/env/go1.12.linux.amd64.env';
11:54:33 AM: go version go1.12 linux/amd64
11:54:33 AM: Installing missing commands
11:54:33 AM: Verify run directory
11:54:34 AM: ​
11:54:34 AM: ┌─────────────────────────────┐
11:54:34 AM: │        Netlify Build        │
11:54:34 AM: └─────────────────────────────┘
11:54:34 AM: ​
11:54:34 AM: ❯ Version
11:54:34 AM:   @netlify/build 3.1.5
11:54:34 AM: ​
11:54:34 AM: ❯ Flags
11:54:34 AM:   deployId: 5f292ffa0b443100082a6378
11:54:34 AM:   mode: buildbot
11:54:34 AM:   timersFile: /tmp/substage_times.txt
11:54:34 AM: ​
11:54:34 AM: ❯ Current directory
11:54:34 AM:   /opt/build/repo
11:54:34 AM: ​
11:54:34 AM: ❯ Config file
11:54:34 AM:   /opt/build/repo/netlify.toml
11:54:34 AM: ​
11:54:34 AM: ❯ Context
11:54:34 AM:   production
11:54:34 AM: ​
11:54:34 AM: ❯ Loading plugins
11:54:34 AM:    - netlify-plugin-cypress@1.4.1 from netlify.toml and package.json
11:54:34 AM: ​
11:54:34 AM: ┌───────────────────────────────────────────────────┐
11:54:34 AM: │ 1. onPreBuild command from netlify-plugin-cypress │
11:54:34 AM: └───────────────────────────────────────────────────┘
11:54:34 AM: ​
11:54:48 AM: waiting on "http://localhost:8000/" with timeout of 45 seconds
11:54:48 AM: > gcb-shop@1.0.0 start:mock /opt/build/repo
11:54:48 AM: > npm run fetchAssets && GATSBY_MOCK_ACCOUNTING=true npm run dev
11:54:48 AM: > gcb-shop@1.0.0 fetchAssets /opt/build/repo
11:54:48 AM: > node scripts/fetch-drupal-assets.mjs
11:54:50 AM: stored ./drupal/de/header.html
11:54:50 AM: stored ./drupal/de/footer.html
11:54:50 AM: stored ./drupal/de/style.html
11:54:50 AM: > gcb-shop@1.0.0 dev /opt/build/repo
11:54:50 AM: > gatsby develop
11:54:55 AM: Debugger listening on ws://127.0.0.1:9229/b48b6c47-a602-4e73-bec6-e5c5d25cb57a
11:54:55 AM: For help, see: https://nodejs.org/en/docs/inspector
11:54:55 AM: success open and validate gatsby-configs - 0.094s
11:54:56 AM: success load plugins - 1.217s
11:54:56 AM: success onPreInit - 0.003s
11:54:56 AM: success initialize cache - 0.009s
11:54:56 AM: success copy gatsby files - 0.035s
11:54:57 AM: info [sanity] Fetching remote GraphQL schema
11:54:57 AM: info [sanity] Transforming to Gatsby-compatible GraphQL SDL
11:54:57 AM: info [sanity] Stitching GraphQL schemas from SDL
11:54:57 AM: success @wapps: copy redirect component - 0.001s
11:54:57 AM: success onPreBootstrap - 0.373s
11:54:57 AM: success createSchemaCustomization - 0.015s
11:54:57 AM: info [sanity] Fetching export stream for dataset
11:54:58 AM: warning [sanity] Document "0cf5429e-510b-42b0-ae88-487c8a0e22aa" has type mwst (SanityMwst), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
11:54:58 AM: warning [sanity] Document "bbe86f1b-cd76-4b22-950c-d5b53cd9a03b" has type mwst (SanityMwst), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
11:54:58 AM: warning [sanity] Document "bc96ebdb-66d8-42e5-989e-33cb4481063b" has type mwst (SanityMwst), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
11:54:58 AM: info [sanity] Done exporting!
11:54:58 AM: success @wapps: create node: de_messages - 0.032s
11:54:58 AM: success @wapps: create node: en_messages - 0.006s
11:54:58 AM: success @wapps: create node: fr_messages - 0.008s
11:54:58 AM: success Checking for changed pages - 0.001s
11:54:58 AM: success source and transform nodes - 1.184s
11:54:58 AM: warning The type `SanityImageAsset` does not explicitly define the field `childImageSharp`.
11:54:58 AM: On types with the `@dontInfer` directive, or with the `infer` extension set to `false`, automatically adding fields for children types is deprecated.
11:54:58 AM: In Gatsby v3, only children fields explicitly set with the `childOf` extension will be added.
11:54:59 AM: success building schema - 0.563s
11:54:59 AM: success createPages - 0.208s
11:54:59 AM: success Checking for changed pages - 0.000s
11:54:59 AM: success createPagesStatefully - 0.354s
11:54:59 AM: success updating schema - 0.043s
11:54:59 AM: success write out redirect data - 0.006s
11:54:59 AM: success onPreExtractQueries - 0.024s
11:55:01 AM: success extract queries from components - 1.233s
11:55:01 AM: success write out requires - 0.050s
11:55:01 AM: success run static queries - 0.085s - 6/6 70.87/s
11:55:01 AM: success run page queries - 0.254s - 133/133 523.76/s
11:55:10 AM: Using browser-only version of superagent in non-browser environment
11:55:23 AM: ⠀
11:55:23 AM: You can now view gcb-shop in the browser.
11:55:23 AM: ⠀
11:55:23 AM:   http://localhost:8000/
11:55:23 AM: ⠀
11:55:23 AM: View GraphiQL, an in-browser IDE, to explore your site's data and schema⠀
11:55:23 AM:   http://localhost:8000/___graphql
11:55:23 AM: ⠀
11:55:23 AM: Note that the development build is not optimized.
11:55:23 AM: To create a production build, use gatsby build
11:55:23 AM: ⠀
11:55:23 AM: success Building development bundle - 12.882s
12:23:13 PM: Build exceeded maximum allowed runtime
12:23:15 PM: success onPreExtractQueries - 0.170s
12:23:19 PM: error There was a problem reading the file: /opt/build/repo/src/templates/package.tsx
12:23:19 PM: 
12:23:19 PM: 
12:23:19 PM:   Error: ENOENT: no such file or directory, open '/opt/build/repo/src/templates/  package.tsx'
12:23:19 PM: 
12:23:19 PM: error There was a problem reading the file: /opt/build/repo/src/templates/category.tsx
...
Pieparker commented 4 years ago

Hey there! Stumbled upon this topic and just wanted to let you know that Build exceeded maximum allowed runtime is associated with a Netlify build timeout.

By default, builds will only run for 15 minutes. This limit can be increased, provided you have billing info on file, else you should check out the nifty build optimisation guide.

philschonholzer commented 4 years ago

@Pieparker thanks for replying.

I know about the max build time on netlify. The problem here is the test could start at 11:55:23 (server running) but does not for almost 8min (12:23:19) until the max build time stops the build.

bahmutov commented 3 years ago

@philschonholzer can you create tiny reproducible example, please? I want to make sure I fix the right thing here

bahmutov commented 3 years ago

:tada: This issue has been resolved in version 1.9.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: