fix (full-sync): Adding pino logger for probot update#961
Open
dolan-a wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
@decyjphr - can we get this considered for an upcoming release? |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the full-sync CLI entrypoint to restore logging compatibility after the Probot v14 upgrade by explicitly providing a logger to createProbot, and adds unit tests around performFullSync to prevent regressions.
Changes:
- Create a
pinologger and pass it tocreateProbotviaoverrides.logto avoidprobot.logbeingnull. - Add a null-guard around
settings.errorsto avoid crashing whensyncInstallation()returnsnull. - Export
performFullSyncand add unit tests for logger wiring and null-safety.
Show a summary per file
| File | Description |
|---|---|
| full-sync.js | Adds a pino logger override for Probot v14 and exports performFullSync for testing. |
| test/unit/full-sync.test.js | Introduces unit tests for performFullSync (logger override + null settings). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 3
Comment on lines
+4
to
+20
| const pino = require('pino') | ||
|
|
||
| async function performFullSync (appFn, nop) { | ||
| const probot = createProbot() | ||
| const logLevel = process.env.LOG_LEVEL || 'info' | ||
| const logger = pino({ | ||
| level: logLevel, | ||
| transport: { | ||
| target: 'pino-pretty', | ||
| options: { | ||
| colorize: true, | ||
| ignore: 'pid,hostname', | ||
| messageFormat: '{msg}', | ||
| customColors: 'info:blue,warn:yellow,error:red', | ||
| levelFirst: true | ||
| } | ||
| } | ||
| }) |
Comment on lines
+1
to
+25
| /* eslint-disable no-undef */ | ||
| const { performFullSync } = require("../../full-sync"); | ||
|
|
||
| jest.mock("probot", () => ({ createProbot: jest.fn() })); | ||
| jest.mock("pino", () => jest.fn(() => ({ info: jest.fn() }))); | ||
|
|
||
| describe("full-sync.js", () => { | ||
| let mockProbot, mockApp; | ||
|
|
||
| beforeEach(() => { | ||
| mockProbot = { log: { info: jest.fn() } }; | ||
| require("probot").createProbot.mockReturnValue(mockProbot); | ||
| mockApp = { syncInstallation: jest.fn() }; | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it("should pass logger to createProbot via overrides (v14 fix)", async () => { | ||
| mockApp.syncInstallation.mockResolvedValue({ errors: [] }); | ||
| await performFullSync(jest.fn().mockReturnValue(mockApp), true); | ||
|
|
||
| expect(require("probot").createProbot).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| overrides: expect.objectContaining({ log: expect.any(Object) }), | ||
| }), | ||
| ); |
Comment on lines
+26
to
+37
| }); | ||
|
|
||
| it("should handle null settings without crashing (null safety)", async () => { | ||
| mockApp.syncInstallation.mockResolvedValue(null); | ||
| await performFullSync(jest.fn().mockReturnValue(mockApp), true); | ||
|
|
||
| // Just verify it completes without throwing | ||
| expect(mockProbot.log.info).toHaveBeenCalledWith( | ||
| "Full sync completed successfully.", | ||
| ); | ||
| }); | ||
| }); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
With the Probot v14 update, it seems that logging in full-sync no longer works:
This PR has the following changes:
pino)performFullSyncin full-sync runs okay (test fails without the logger change; passes with it)