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

Fixture file not found when running on self-hosted runner #1094

Closed
far11ven opened this issue Dec 11, 2023 · 5 comments
Closed

Fixture file not found when running on self-hosted runner #1094

far11ven opened this issue Dec 11, 2023 · 5 comments
Labels
unexpected behavior User expected result, but got another

Comments

@far11ven
Copy link

far11ven commented Dec 11, 2023

I'm seeing the problem recenly where my tests running on selfhosted github-runner, fixture file is not found. Locally everything works fine. I'm not able to debug this as well.

I also ssh into the github runner to see if the file is physically present there (here you can see definitions.json is present:
image

but during running as part of an action I get following error:
Error snapshot:

image

I upgraded everything to latest and still this problem is there. are there any pointers to debug this?

Cypress - GitHubActions: v6.6.0
CypressVersion: v13.16.1

EDIT:

I added few cy.exec() before the actual line of code:

if (Cypress.platform === 'win32') {
        cy.exec('cd', {failOnNonZeroExit: false}).then((result) => {
            cy.log("CD: \n", JSON.stringify(result));
        })
      } else {
        cy.exec('cd', {failOnNonZeroExit: false} ).then((result) => {
            cy.log("CD: \n", JSON.stringify(result));
        })
    }

	if (Cypress.platform === 'win32') {
        cy.exec('cd cypress/fixtures/resources/AI-projects/DYNAMIC/requestPayloads/data-model-definition/ && type definitions.json', {failOnNonZeroExit: false}).then((result) => {
            cy.log(JSON.stringify(result));
        })
      } else {
        cy.exec('cd cypress/fixtures/resources/AI-projects/DYNAMIC/requestPayloads/data-model-definition/ && cat package.json', {failOnNonZeroExit: false} ).then((result) => {
            cy.log(JSON.stringify(result));
        })
      }

	if (Cypress.platform === 'win32') {
        cy.exec('cd && cd cypress/fixtures/resources/AI-projects/' + aiProjectType.toUpperCase() + '/requestPayloads/data-model-definition/ && type definitions.json', {failOnNonZeroExit: false}).then((result) => {
            cy.log("File-content: \n", JSON.stringify(result));
        })
      } else {
        cy.exec('cd cypress/fixtures/resources/AI-projects/' + aiProjectType.toUpperCase() + '/requestPayloads/data-model-definition/ && cat definitions.json', {failOnNonZeroExit: false} ).then((result) => {
            cy.log("File-content: \n", JSON.stringify(result));
        })
    }

	cy.fixture('/resources/AI-projects/' + aiProjectType.toUpperCase() + '/requestPayloads/data-model-definition/definitions.json', "binary")
		.then(data => {

...

and the result is below:
image

@MikeMcC399
Copy link
Collaborator

@far11ven

It's unlikely that your issue is caused by cypress-io/github-action however if you follow the steps in the README > Debugging section, you can set the DEBUG environment variable to get more debug information:

Debug action steps:

  env:
    DEBUG: '@cypress/github-action'

Debug Cypress:

  env:
    DEBUG: 'cypress:*'

Debug action steps and Cypress:

  env:
    DEBUG: '@cypress/github-action, cypress:*'

You are also welcome to post your GitHub Actions workflow here to see if there is anything unusual about it.

@far11ven
Copy link
Author

far11ven commented Dec 12, 2023

Hey @MikeMcC399 , thanks for your comment, following is the actions workflow:


name: Doc-AI Test Automation (Manual - with envFile)
on:
  workflow_dispatch:
    inputs:
      environment:
        type: choice
        description: 'The target environment-keyword relating to <env>.config.json, example: stg for (stg.config.json)'
        options: 
        - pr
        - qa
        - stg
        required: true
        default: "qa"
      tags:
        required: true
        default: "@all"
        type: string
        description: 'provide tags expression for running tests'
      record:
        type: boolean
        description: 'Record and publish to Cypress Dashboard'
jobs:
  manual_run:
    runs-on: cypress
    name: Manual Run
    steps:   
    # Checkout code in omnius-qa-doc-ai-automation repository
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ github.head.ref }}
          fetch-depth: '0'
    
    # Log Environment details
      - name: User Input Details
        run: |
          echo "running on environment ${{ github.event.inputs.environment }} from branch ${{ github.ref }}"
          echo "Tags provided: ${{ github.event.inputs.tags }}"
          echo "Cypress record: ${{ github.event.inputs.record }}"

    # Install dependencies by running npm install
      - name: Dependency Installation
        run: npm install
    
    # Execute automated tests and send execution summary to cypress cloud dashboard with Record flag true
      - name: Doc-AI Test Automation Manual Execution with Record
        id: run_step_with_record
        if: ${{ github.event.inputs.record == 'true' }}
        uses: cypress-io/github-action@v6.6.0
        with: 
          install: false
          command: node cy-runner.js cypress run --e2e --env envFile=${{ github.event.inputs.environment }},TAGS="${{ github.event.inputs.tags }}" --record --key ${{ secrets.DOC_AI_TESTING_CYPRESS_RECORD_KEY }}
    
    # Execute automated tests and send execution summary to cypress cloud dashboard
      - name: Doc-AI Test Automation Manual Execution
        id: run_step
        if: ${{ github.event.inputs.record != 'true' }}
        uses: cypress-io/github-action@v6.6.0
        with: 
          install: false
          command: node cy-runner.js cypress run --e2e --env envFile=${{ github.event.inputs.environment }},TAGS="${{ github.event.inputs.tags }}"
    
    # Cypress Test Result Details          
      - name: Print Cypress Cloud URL
        run: |
          echo Cypress finished with: ${{ steps.run_step.outcome }}
          echo Outputs: ${{ steps.run_step.outputs }}
          echo Outputs_JSON: ${{  toJSON(steps.run_step.outputs) }}
          echo See results at ${{ steps.run_step.outputs.dashboardUrl }}

    # Send Notification to Teams Channel QA Team > General
      - name: Send Notification to Teams Channel
        uses: Skitionek/notify-microsoft-teams@v1.0.8
        if: always()
        with:
          webhook_url: ${{ secrets.DOC_AI_TESTING_TEAMS_WEBHOOK }}
          overwrite: "{ title: `Manual Test Run Status`, sections: [{ activityTitle: `Run Info:`, activitySubtitle: `Started by ${{ github.actor }}`, facts: [{ name: `Run from branch`, value: `${{ github.ref }}` }, { name: `Environment`, value: `${{ github.event.inputs.environment }}` }, { name: `Tags`, value: `${{ github.event.inputs.tags }}` }, { name: `Recorded`, value: `${{ github.event.inputs.record }}` }], markdown: true }], potentialAction: [{ \"@type\": `OpenUri`, name: `Repository`, targets: [{ os: `default`, uri: `https://github.com/${{ github.repository }}` }] }, { \"@type\": `OpenUri`, name: `Workflow Run`, targets: [{ os: `default`, uri: `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}` }] }, { \"@type\": `OpenUri`, name: `Cypress Dashboard`, targets: [{ os: `default`, uri: `https://cloud.cypress.io/organizations/78668328-fe90-4847-a630-6b1ce6864929/projects` }] }] }"
          needs: ${{ toJSON(needs) }}
          steps: ${{ toJSON(steps) }}
          job: ${{ toJSON(job) }}
          
    # Upload test artifacts 
      - name: Upload Test Artifacts
        uses: actions/upload-artifact@v3.1.0
        if: success()
        with:
          name: reports
          path: |
            reports/
            cypress/fixtures/state/*
          retention-days: 30

@MikeMcC399
Copy link
Collaborator

@far11ven

Would you like to edit your posting to reformat your workflow so that it is more readable? Use triple backticks and yml to get markdown to format correctly:

```yml
workflow code
```

Your workflow shows an unconventional use of cypress-io/github-action using the command parameter which overrides most of the functions of the action. I suggest you refer to the README for examples of how the action is intended to be used.

@MikeMcC399 MikeMcC399 added the unexpected behavior User expected result, but got another label Dec 12, 2023
@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Dec 12, 2023

@far11ven

I'm going to close this issue. Your workflow specifies for instance:

uses: cypress-io/github-action@v6.6.0
    with: 
      install: false
      command: node cy-runner.js cypress run --e2e --env envFile=${{ github.event.inputs.environment }},TAGS="${{ github.event.inputs.tags }}"
  • specifying install: false means that you by-pass installation of dependencies using a lock file which the action would normally carry out
  • specifying command: node cy-runner.js cypress run etc means that the action is not running Cypress. Instead it just passes your command through to the runner which executes your command.

So, although you are calling cypress-io/github-action@v6.6.0, you are in fact not using any of its functionality in a meaningful way. Instead of calling the action, you could just use GitHub Actions run keyword. That also means that your problem with fixtures does not come from the action.

@MikeMcC399 MikeMcC399 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
@far11ven
Copy link
Author

Thanks @MikeMcC399 for your analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

2 participants