-
Notifications
You must be signed in to change notification settings - Fork 61
✨ Supporting Build Review Actions #1942
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f29b341
adding build:approve command
bhokaremoin fad34eb
adding unapprove and reject
bhokaremoin e7edbb1
adding command in build
bhokaremoin c19def5
fixing lint and updating readme
bhokaremoin f953fda
lint fix
bhokaremoin 66443d9
logging error message received from api
bhokaremoin fd0898e
adding tests for approve
bhokaremoin a428a13
adding test for unapprove and reject
bhokaremoin 073c32f
updating the env values
bhokaremoin c5370d3
refactoring logging for review command
bhokaremoin e71ff9a
adding temp test for code coverage
bhokaremoin c2d1e50
fixing test for code coverage
bhokaremoin 7577d05
updating sending on creds
bhokaremoin 3d79068
refactoring
bhokaremoin f76a6db
updating readme
bhokaremoin 163b747
fixing test
bhokaremoin 75e9bf0
adding delete command
bhokaremoin 6f6cdb7
adding deleted by user details
bhokaremoin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import command from '@percy/cli-command'; | ||
| import { fetchCredentials, reviewCommandConfig } from './utils.js'; | ||
|
|
||
| /** | ||
| * Approve command definition for Percy builds | ||
| * Allows users to approve builds using build ID and authentication credentials | ||
| */ | ||
| export const approve = command('approve', { | ||
| description: 'Approve Percy builds', | ||
| ...reviewCommandConfig | ||
| }, async ({ flags, args, percy, log, exit }) => { | ||
| // Early return if Percy is disabled | ||
| if (!percy) { | ||
| exit(0, 'Percy is disabled'); | ||
| } | ||
|
|
||
| // Validate and get authentication credentials | ||
| const { username, accessKey } = fetchCredentials(flags); | ||
|
|
||
| if (!username || !accessKey) { | ||
| exit(1, 'Username and access key are required to approve builds.'); | ||
| } | ||
|
|
||
| log.info(`Approving build ${args.buildId}...`); | ||
|
|
||
| try { | ||
| // Call the Percy API to approve the build | ||
| const buildApprovalResponse = await percy.client.approveBuild( | ||
| args.buildId, | ||
| username, | ||
| accessKey | ||
| ); | ||
|
|
||
| const approvedBy = buildApprovalResponse.data.attributes['action-performed-by'] || { | ||
| user_email: 'unknown@example.com', | ||
| user_name: username | ||
| }; | ||
| log.info(`Build ${args.buildId} approved successfully!`); | ||
| log.info(`Approved by: ${approvedBy.user_name} (${approvedBy.user_email})`); | ||
| } catch (error) { | ||
| log.error(`Failed to approve build ${args.buildId}`); | ||
| log.error(error); | ||
|
|
||
| // Provide user-friendly error message | ||
| exit(1, 'Failed to approve the build'); | ||
| } | ||
| }); | ||
|
|
||
| export default approve; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import command from '@percy/cli-command'; | ||
| import { fetchCredentials, reviewCommandConfig } from './utils.js'; | ||
|
|
||
| /** | ||
| * Delete command definition for Percy builds | ||
| * Allows users to delete builds using build ID and authentication credentials | ||
| */ | ||
| export const deleteBuild = command('delete', { | ||
| description: 'Delete Percy builds', | ||
| ...reviewCommandConfig | ||
| }, async ({ flags, args, percy, log, exit }) => { | ||
| // Early return if Percy is disabled | ||
| if (!percy) { | ||
| exit(0, 'Percy is disabled'); | ||
| } | ||
|
|
||
| // Validate and get authentication credentials | ||
| const { username, accessKey } = fetchCredentials(flags); | ||
|
|
||
| if (!username || !accessKey) { | ||
| exit(1, 'Username and access key are required to delete builds.'); | ||
| } | ||
|
|
||
| log.info(`Deleting build ${args.buildId}...`); | ||
|
|
||
| try { | ||
| // Call the Percy API to delete the build | ||
| const buildDeletionResponse = await percy.client.deleteBuild( | ||
| args.buildId, | ||
| username, | ||
| accessKey | ||
| ); | ||
| const deletedBy = buildDeletionResponse['action-performed-by'] || { | ||
| user_email: 'unknown@example.com', | ||
| user_name: username | ||
| }; | ||
|
|
||
| log.info(`Build ${args.buildId} deleted successfully!`); | ||
| log.info(`Deleted by: ${deletedBy.user_name} (${deletedBy.user_email})`); | ||
| } catch (error) { | ||
| log.error(`Failed to delete build ${args.buildId}`); | ||
| log.error(error); | ||
|
|
||
| // Provide user-friendly error message | ||
| exit(1, 'Failed to delete the build'); | ||
| } | ||
| }); | ||
|
|
||
| export default deleteBuild; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import command from '@percy/cli-command'; | ||
| import { fetchCredentials, reviewCommandConfig } from './utils.js'; | ||
|
|
||
| /** | ||
| * Reject command definition for Percy builds | ||
| * Allows users to reject builds using build ID and authentication credentials | ||
| */ | ||
| export const reject = command('reject', { | ||
| description: 'Reject Percy builds', | ||
| ...reviewCommandConfig | ||
| }, async ({ flags, args, percy, log, exit }) => { | ||
| // Early return if Percy is disabled | ||
| if (!percy) { | ||
| exit(0, 'Percy is disabled'); | ||
| } | ||
|
|
||
| // Validate and get authentication credentials | ||
| const { username, accessKey } = fetchCredentials(flags); | ||
|
|
||
| if (!username || !accessKey) { | ||
| exit(1, 'Username and access key are required to reject builds.'); | ||
| } | ||
|
|
||
| log.info(`Rejecting build ${args.buildId}...`); | ||
|
|
||
| try { | ||
| // Call the Percy API to reject the build | ||
| const buildRejectionResponse = await percy.client.rejectBuild( | ||
| args.buildId, | ||
| username, | ||
| accessKey | ||
| ); | ||
|
|
||
| const rejectedBy = buildRejectionResponse.data.attributes['action-performed-by'] || { | ||
| user_email: 'unknown@example.com', | ||
| user_name: username | ||
| }; | ||
| log.info(`Build ${args.buildId} rejected successfully!`); | ||
| log.info(`Rejected by: ${rejectedBy.user_name} (${rejectedBy.user_email})`); | ||
| } catch (error) { | ||
| log.error(`Failed to reject build ${args.buildId}`); | ||
| log.error(error); | ||
|
|
||
| // Provide user-friendly error message | ||
| exit(1, 'Failed to reject the build'); | ||
| } | ||
| }); | ||
|
|
||
| export default reject; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.