argos-ci / argos-javascript

Official Argos SDKs for JavaScript
https://docs.argos-ci.com
MIT License
8 stars 9 forks source link

Question: Is it possible to get the response after calling upload function locally #148

Closed kobenguyent closed 1 month ago

kobenguyent commented 2 months ago

Description

I'm totally new to this, so I'm just curios if we could get the response after calling upload function on local machine.

My function

  async uploadScreenshots(files: string[]): Promise<void> {
    console.log('Uploading screenshots to Argos-CI...');

    // @ts-ignore
    const result = await upload({
      branch: this.branch,
      buildName: this.buildId,
      token: this.argosToken,
      commit: process.env.GITHUB_SHA || 'local-commit',
      files: files,
    });

    console.log('Argos-CI upload result:', result);
  }

When running test locally, I just see this

Visual Regression Testing --
    [1]  Starting recording promises
    Timeouts: 
 › [Session] Starting singleton browser session
  Test home page visual appearance
    I am on page "https://www.google.com/"
    › [Browser:Info] Autofocus processing was blocked because a document already has a focused element.
    I take screenshot "home-page"
    › Screenshot is saving to /Users/t/Desktop/projects/codeceptjs-ArgosCIHelper/test/output/screenshots/home-page.png
Screenshot saved: ./output/screenshots/home-page.png
  ✔ OK in 2415ms

  OK  | 1 passed   // 4s
Uploading screenshots to Argos-CI...

When running on Github

> test@1.0.0 test
> codeceptjs run

CodeceptJS v3.6.5 #StandWithUkraine
Using test root "/home/runner/work/codeceptjs-ArgosCIHelper/codeceptjs-ArgosCIHelper/test"

Visual Regression Testing --
Screenshot saved: ./output/screenshots/home-page.png

  ✔ Test home page visual appearance in 916ms

  OK  | 1 passed   // 1s
Uploading screenshots to Argos-CI...
Argos-CI upload result: {
  build: {
    id: '562265',
    number: 8,
    status: 'pending',
    url: 'https://app.argos-ci.com/kobenguyent/codeceptjs-ArgosCIHelper/builds/8',
    notification: {
      description: 'Build is queued',
      context: 'argos/587ee126f8a494a6982f[74](https://github.com/kobenguyent/codeceptjs-ArgosCIHelper/actions/runs/10718133319/job/29719364367#step:5:75)3ad0029ec89b926edd',
      github: [Object],
      gitlab: [Object]
    }
  },
  screenshots: [
    {
      name: './output/screenshots/home-page.png',
      path: '/home/runner/work/codeceptjs-ArgosCIHelper/codeceptjs-ArgosCIHelper/test/output/screenshots/home-page.png',
      hash: '0536cbc74417d564c47b30f6debdd4e867ec695b9357d5a23da42529[76](https://github.com/kobenguyent/codeceptjs-ArgosCIHelper/actions/runs/10718133319/job/29719364367#step:5:77)b596e7',
      optimizedPath: '/tmp/tmp-2103-VB6SQTAxYniw',
      metadata: null,
      threshold: null,
      baseName: null,
      pwTrace: null
    }
  ]
}

Test repo: https://github.com/kobenguyent/codeceptjs-ArgosCIHelper

jsfez commented 2 months ago

Hi @kobenguyent, the upload() function in Argos isn’t meant to return the build’s status. It simply uploads your screenshot to the Argos app and provides a link to view the build on the app.

kobenguyent commented 2 months ago

@jsfez thanks for the reply! I'm coming from applitools world, so maybe argos works differently based on knowledge. With applitools, I could get the visual verification status, hence, I could mark the test either passed or failed. On the other hand, with Argos, I'm not sure how to achieve that. May you share if that's possible?

Here is my code that I implemented for Applitools. https://github.com/kobenguyent/codeceptjs-applitoolshelper/blob/master/src/index.ts

gregberge commented 2 months ago

@kobenguyent Argos processes the diff asynchronously, so you can't get the build result synchronously.

To achieve the same result, you have to pull Argos until the build is done. It's not documented but our API do have an endpoint to get the builds associated to a commit so it's definitely possible.

But it's not in the philosophy of Argos. Argos takes care of its own "commit status" or "check". So when you approve screenshots it's automatically updated.

I am curious of understanding your complete workflow in order to make it work for you! Could you book a call with me? https://cal.com/gregberge

kobenguyent commented 2 months ago

@gregberge thanks for the brief update! I managed to get the api collections, I'll try to play with it to learn more about it at first. Screenshot 2024-09-05 at 16 24 37