bahmutov / cypress-split

Split Cypress specs across parallel CI machines for speed
MIT License
201 stars 23 forks source link

timings.json file not found while using cypress github action #156

Closed pavelloz closed 8 months ago

pavelloz commented 8 months ago

Hello,

Im trying to use cypress-split with timings.json file.

I created timings.json in root directory, and tests are in cypress/ - just like in the official example repository. ( https://github.com/bahmutov/cypress-split-timings-example/blob/main/.github/workflows/ci.yml#L24 + https://github.com/bahmutov/cypress-split-timings-example/blob/main/timings.json )

cypress-split: Could not split specs by duration
cypress-split: there are 29 found specs
cypress-split: chunk 3 of 3
cypress-split: specs from the current directory /home/runner/work/frontend/frontend/cypress
ENOENT: no such file or directory, open 'timings.json'
cypress-split: splitting as is by name

In the github action config file this is how i point to a file:

      - name: Run Cypress Tests
        uses: cypress-io/github-action@v6
        env:
          SPLIT: ${{ strategy.job-total }}
          SPLIT_INDEX: ${{ strategy.job-index }}
          SPLIT_FILE: "timings.json" # split suite based on timings, not alphabetical

Additionally, inside the github action ive run ls -la *.json to make sure the file does exist and im not going crazy, and it looks like it is. Im kind of lost. I dont see any config option to change the root directory for cypress github action, so im not sure how it can miss the file.

image

For privacy reasons i cannot give URL to a repository, but if something comes to anyones mind i would be very grateful - maybe someone had similar issue, im out of ideas. :)

pavelloz commented 8 months ago

I managed to prepare repository with the bug present.

I cloned the example repository, added some of the settings we use in our private repo and there it is, file not found:

https://github.com/pavelloz/cypress-split-timings-example/actions/runs/6783957797/job/18439272097

I will try to narrow down the issue, but maybe the fact that config file is not in root directory, but in cypress/ is the problem.

pavelloz commented 8 months ago

Ah. It seems like it is the case.

I tried to point to timings by ../timings.json but it didnt help (which might be a bug)

Would it be possible to make SPLIT_FILE aware of the surroundings and look for the file relative to a root directory? My project has a different TS config for cypress/ and rest of the project, its much heavier lift than just moving a file like i did in my example repository.


Moving cypress config (and removing reference to it from with: block) is the correct answer.

Commit: https://github.com/pavelloz/cypress-split-timings-example/commit/3eb7726713ed5efb8b4f8a433cb4343e54d6c1c6 Build successful: https://github.com/pavelloz/cypress-split-timings-example/actions/runs/6784078487/job/18439647479

bahmutov commented 8 months ago

Right, by default it is looking at the split timings file in the current working directory, which is the one with the Cypress config file. Let me make it simpler by automatically searching folders up from the current directory.

pavelloz commented 8 months ago

I think current behavior is fine, as long as its possible to point to a file with a relative path, aka ../timings.json to go one (or more) level above.

Thank you very much for a quick response, cypress-split is a great piece of software :)

github-actions[bot] commented 8 months ago

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

The release is available on:

Your semantic-release bot :package::rocket: