Skip to content

Conversation

@sayali10
Copy link
Contributor

@sayali10 sayali10 commented Nov 20, 2024

📝 Description

We want to trigger comparadise based on the event trigger in our application instead of git PR.
For that we will be using unique id from app instead of commit hash to store new images.

While trying to run comparadise using unique id instead of commit hash, I am getting this error because the commit hash is invalid:

/home/runners/actions-runner/_work/_actions/ExpediaGroup/comparadise/v1/action/dist/main.js:26313
      const error = new RequestError(toErrorMessage(data), status, {
                    ^
RequestError [HttpError]: Not Found - https://docs.github.com/rest/commits/statuses#list-commit-statuses-for-a-reference
    at /home/runners/actions-runner/_work/_actions/ExpediaGroup/comparadise/v1/action/dist/main.js:26313:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getLatestVisualRegressionStatus (/home/runners/actions-runner/_work/_actions/ExpediaGroup/comparadise/v1/action/dist/main.js:36109:20)
    at async run (/home/runners/actions-runner/_work/_actions/ExpediaGroup/comparadise/v1/action/dist/main.js:36163:40) {
  status: 404,

This PR wraps that call in try catch and returns null on error.
This way we would be able to save the new/diff images using unique id from app instead of commit hash.

).length;

const latestVisualRegressionStatus =
await getLatestVisualRegressionStatus(commitHash);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it down just before the usage.

commitHash,
'failure',
VISUAL_TESTS_FAILED_TO_EXECUTE
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrapped it in common method so that we can print the error message => Failed to update commit status.
This would give little more clarity on reason why job failed.

'Failed to get latest visual regression status.'
);
warning(error as Error);
return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using optional chaining operator wherever we are using latestVisualRegressionStatus value so returning null shouldn't break anything.

@danadajian
Copy link
Contributor

As discussed, we are going to add a new "diff id" param that can be used in place of commit hash

@danadajian danadajian closed this Nov 21, 2024
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

Successfully merging this pull request may close these issues.

2 participants