Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project not working #1174

Closed
fhnaumann opened this issue Apr 27, 2024 · 5 comments
Closed

project not working #1174

fhnaumann opened this issue Apr 27, 2024 · 5 comments
Assignees

Comments

@fhnaumann
Copy link

fhnaumann commented Apr 27, 2024

I have a monorepo and in one folder of main repo I have my website with cypress tests. I want to use this action to run e2e tests in the folder.

name: Cypress E2E

on: [push]

jobs:
  cypress-run:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Cypress run
        uses: cypress-io/github-action@v6
        with:
          project: ./folder
          build: npm run build
          start: npm start

This workflow fails in the cypress run step with the following message:

Error: Action failed. Missing package manager lockfile. Expecting one of package-lock.json (npm), pnpm-lock.yaml (pnpm) or yarn.lock (yarn) in working-directory /home/runner/work/NewChallenges/NewChallenges

I suspect this is because the action tries to do stuff in the root folder and not the specified subfolder. How can I solve this?

@fhnaumann fhnaumann changed the title Using cypress-io/github-action in a monorepo project not working Apr 27, 2024
@MikeMcC399
Copy link
Collaborator

@fhnaumann

In which directory is your lockfile package-lock.json located?

@MikeMcC399 MikeMcC399 added the unexpected behavior User expected result, but got another label Apr 27, 2024
@fhnaumann
Copy link
Author

fhnaumann commented Apr 27, 2024

Its in a subfolder under the root.

root
| - app1
| - app2
     | - package-lock.json
     | - cypress (...)

I solved it by setting working-directory: app2/, though I don't really know why this works. As far as I know working-directory does nothing for actions that use uses:, only for run: commands. Somewhere deep in your example files I found this syntax. I don't use project: at all with this as it messes with the path.

@MikeMcC399
Copy link
Collaborator

@fhnaumann

For your repo structure, with the lockfile in a sub-directory, the Cypress GitHub Action option working-directory is the correct option to use. The README documentation section working-directory describes how this works.

The Cypress GitHub Action option project expects to find a lockfile in the root of the repository. This is the reason for your original error message. The Cypress CLI documenation provides an example structure under cypress-io/cypress-test-nested-projects to demonstrate this.

Please let us know if you think that there are any errors in the documentation, otherwise I suggest to close this issue since you say that you have solved your issue by changing the workflow parameters.

@MikeMcC399 MikeMcC399 removed the unexpected behavior User expected result, but got another label Apr 28, 2024
@MikeMcC399 MikeMcC399 self-assigned this Apr 28, 2024
@fhnaumann
Copy link
Author

Thanks for your clarification. I don't know how I missed the big working-directory section in the README...

@MikeMcC399
Copy link
Collaborator

@fhnaumann

Thanks for your clarification.

You're welcome! 🙂

I don't know how I missed the big working-directory section in the README...

The documentation for the project option could be improved to make it clearer. I will put that on my to-do list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants