Skip to content

Commit

Permalink
feat: add debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jan 16, 2023
1 parent 6016db4 commit 352c208
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@

> Split Cypress specs across parallel CI machines for speed
> without using any external services
## Debugging

To see diagnostic log messages from this plugin, set the environment variable `DEBUG=cypress-split`
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"dependencies": {
"@actions/core": "^1.10.0",
"console.table": "^0.10.0",
"debug": "^4.3.4",
"find-cypress-specs": "^1.24.0"
},
"devDependencies": {
Expand Down
13 changes: 10 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const debug = require('debug')('cypress-split')
const { getSpecs } = require('find-cypress-specs')
const ghCore = require('@actions/core')
const cTable = require('console.table')

function getChunk(values, totalChunks, chunkIndex) {
debug('get chunk %o', { values, totalChunks, chunkIndex })

// split all items into N chunks and take just a single chunk
if (totalChunks < 0) {
throw new Error('totalChunks must be >= 0')
Expand All @@ -29,18 +32,20 @@ function cypressSplit(on, config) {
// maybe the user called this function with a single argument
// then we assume it is the config object
if (arguments.length === 1) {
debug('single argument, assuming it is the config object')
config = on
}

if (config.specs) {
console.log(config.specs)
debug('config has specs set')
debug(config.specs)
}

// the user can specify the split flag / numbers
// using either OS process environment variables
// or Cypress env variables
console.log('Cypress config env')
console.log(config.env)
debug('Cypress config env')
debug(config.env)

let SPLIT = process.env.SPLIT || config.env.split || config.env.SPLIT
let SPLIT_INDEX = process.env.SPLIT_INDEX || config.env.splitIndex
Expand Down Expand Up @@ -111,6 +116,8 @@ function cypressSplit(on, config) {
.write()
}

debug('setting the spec pattern to')
debug(splitSpecs)
config.specPattern = splitSpecs
return config
}
Expand Down

0 comments on commit 352c208

Please sign in to comment.