Skip to content

Commit

Permalink
fix: copy the empty spec to temp folder before running (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jan 18, 2023
1 parent 3000173 commit 2c1f671
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,20 @@ jobs:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}

test-empty:
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎
uses: actions/checkout@v3
- name: Run an empty Cypress split 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v5
with:
command: npm run empty

release:
if: github.ref == 'refs/heads/main'
needs: [test-split, test-spec]
needs: [test-empty, test-split, test-spec]
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎
Expand Down
17 changes: 15 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const ghCore = require('@actions/core')
const cTable = require('console.table')
const { getChunk } = require('./chunk')
const path = require('path')
const os = require('os')
const fs = require('fs')

const label = 'cypress-split:'

Expand Down Expand Up @@ -125,8 +127,19 @@ function cypressSplit(on, config) {
debug(splitSpecs)
config.specPattern = splitSpecs
} else {
console.log('%s no specs to run, running an empty spec file', label)
config.specPattern = path.resolve(__dirname, './empty-spec.cy.js')
// copy the empty spec file from our source folder into temp folder
const tempFilename = path.join(
os.tmpdir(),
`empty-${splitIndex + 1}-of-${splitN}.cy.js`,
)
const emptyFilename = path.resolve(__dirname, 'empty-spec.cy.js')
fs.copyFileSync(emptyFilename, tempFilename)
console.log(
'%s no specs to run, running an empty spec file %s',
label,
tempFilename,
)
config.specPattern = tempFilename
}

return config
Expand Down

0 comments on commit 2c1f671

Please sign in to comment.