percy / exec-action

A (deprecated) GitHub action to run Percy Agent `percy exec` commands
https://docs.percy.io/docs/github-actions#section-exec-action
MIT License
8 stars 5 forks source link

exec-action creating 2 builds and giving errors Error: listen EADDRINUSE: address already in use :::5338 #15

Closed juhi123 closed 4 years ago

juhi123 commented 4 years ago

Hey

I have been trying to integrate percyScript tests with Github Actions, here is the output of exec-action

  with:
    command: percy exec -- node homepage-snapshot.js
    working-directory: ./tests/percy/tests
    verbose: true
    passthrough: false
    silence: false
  env:
    PERCY_TOKEN: ***
/usr/local/bin/npx percy exec -- percy exec -- node homepage-snapshot.js
[percy] Current config file path: /home/runner/work/dir/tests/percy/.percy.yml
[percy] Using config: { version: 1, snapshot: { widths: [ 375, 1280, 1920 ] } }
[percy] created build #47: https://percy.io/example/builds/4964845
[percy] -> assetDiscoveryService.puppeteer.launch
[percy] -> assetDiscoveryService.createPagePool
[percy] -> assetDiscoveryService.setup
[percy] percy has started.
[percy] -> assetDiscoveryService.browser.newPage
[percy] Current config file path: /home/runner/work/dir/tests/percy/.percy.yml
[percy] Using config: { version: 1, snapshot: { widths: [ 375, 1280, 1920 ] } }
[percy] created build #48: https://percy.io/example/builds/4964846
events.js:288
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::5338
    at Server.setupListenHandle [as _listen2] (net.js:1309:16)
    at listenInCluster (net.js:1357:12)
  C

My workflow file looks like this:

name: Percy Workflow
on: 
  pull_request:
    branches:
      - develop
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1.0.0
      - name: Install dependencies 
        working-directory: ./tests/percy
        run: npm install
      - name: Percy Test
        uses: percy/exec-action@v0.3.0
        with:
          command: percy exec -- node homepage-snapshot.js
          working-directory: ./tests/percy/tests
          verbose: true
        env:
          PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}

My homepage-snapshot.js looks like this

const PercyScript = require('@percy/script');

PercyScript.run(async (page, percySnapshot) => {
  await page.goto('URL');
  // ensure the page has loaded before capturing a snapshot
  await page.waitFor('body');
  await percySnapshot('homepage');
});

Why this is initiating 2 builds, because of 2 build I think getting this issues of "Address is already in use"

Looking forward. Thanks!

Robdel12 commented 4 years ago

Hey @juhi123! The exec action already runs percy exec: https://github.com/percy/exec-action/blob/master/src/index.js#L62 so this is creating two builds because percy exec is being called twice: /usr/local/bin/npx percy exec -- percy exec -- node homepage-snapshot.js

name: Percy Workflow
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1.0.0
      - name: Install dependencies 
        working-directory: ./tests/percy
        run: npm install
      - name: Percy Test
        uses: percy/exec-action@v0.3.0
        with:
          command: "node homepage-snapshot.js"
          working-directory: ./tests/percy/tests
          verbose: true
        env:
          PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
juhi123 commented 4 years ago

@Robdel12 Thank you so much :)