sfpowerscripts icon indicating copy to clipboard operation
sfpowerscripts copied to clipboard

feat(events): new event stream for build command

Open Rocko1204 opened this issue 7 months ago • 2 comments

Summary generated by Reviewpad on 12 Dec 23 05:41 UTC

This pull request includes changes to multiple files. Here is a summary of the changes:

  1. build.ts in the orchestrator directory:

    • Added a new property jobId to the Build class.
    • Other existing properties remain unchanged.
  2. CreateDataPackageImpl.ts:

    • Added import statement for BuildStreamService from '../../eventStream/build'.
    • Added calls to BuildStreamService.sendPackageError() with error messages.
  3. build.json:

    • Added a new property jobIdFlagDescription.
  4. CreateDiffPackageImpl.ts:

    • Imported BuildStreamService from the build event stream.
    • Used BuildStreamService to send a package error message and throw an error.
  5. PackageDependencyDisplayer.ts:

    • Added an import statement for BuildStreamService.
    • Made changes to the printPackageDependencies method.
  6. CreatePackage.ts:

    • Added an import statement for BuildStreamService.
    • Added calls to BuildStreamService.buildPackageStatus() and BuildStreamService.sendPackageError().
  7. BuildImpl.ts:

    • Added import statement for BuildStreamService.
    • Made various changes to the BuildImpl class.
  8. hooks.ts:

    • Added a new file with code for logging events and sending webhooks.
  9. Other files:

    • Contains various changes related to types, interfaces, and imports.

Please review these changes and let me know if you have any questions.

Hi @azlam-abdulsalam

This is the pull request for the new event stream. (build and release command)

There are 2 options:

  1. Send the events to (a new object on) devhub

To activate this method you need to first install the package 04t2o000001B1kiAAC. This package contains a new object called SfPowerscriptsEvent__c and a permission set to access the new fields. And it has a scheduled apex class where you can delete old records from the event object. (default value older then 15 days)

Then you have to set the new (optional) flag --jobid (-j) to send the events to the devhub.

  1. Send the events as webhook

To activate this method you need to set the ENV variables

EVENT_STREAM_WEBHOOK_URL EVENT_STREAM_WEBHOOK_TOKEN

optional(NODE_TLS_REJECT_UNAUTHORIZED=0) (required when you have no ssl certificates for the hook)

At the end we create always a new json in the .sfpowerscripts folder with the name ,,eventStreamBuild.json'' OR ,,eventStreamRelease.json''. This file has all infos from part1/2 as well.

Checklist

All items have to be completed before a PR is merged

  • [x] Adhere to Contribution Guidelines
  • [ ] Updates to Decision Records considered?
  • [ ] Updates to documentation at DX@Scale Guide considered?
  • [ ] Tested changes?
  • [ ] Unit Tests new and existing passing locally?

Rocko1204 avatar Dec 12 '23 05:12 Rocko1204

Reviewpad Report

:warning: Warnings

  • Please link an issue to the pull request

reviewpad[bot] avatar Dec 12 '23 05:12 reviewpad[bot]

Codecov Report

Attention: 158 lines in your changes are missing coverage. Please review.

Comparison is base (94042a5) 46.83% compared to head (6b1dd48) 45.04%.

Files Patch % Lines
packages/core/src/eventStream/build.ts 3.36% 114 Missing and 1 partial :warning:
packages/core/src/eventStream/hooks.ts 14.28% 30 Missing :warning:
.../core/src/package/packageCreators/CreatePackage.ts 11.11% 8 Missing :warning:
...c/package/packageCreators/CreateDiffPackageImpl.ts 25.00% 3 Missing :warning:
...c/package/packageCreators/CreateDataPackageImpl.ts 33.33% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1446      +/-   ##
==========================================
- Coverage   46.83%   45.04%   -1.79%     
==========================================
  Files          70       73       +3     
  Lines        2667     2855     +188     
  Branches      300      315      +15     
==========================================
+ Hits         1249     1286      +37     
- Misses       1416     1539     +123     
- Partials        2       30      +28     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 12 '23 05:12 codecov[bot]