Skip to content

Commit 95bf9c5

Browse files
committed
Add more logging to all procedures
1 parent f9beeaf commit 95bf9c5

5 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/api/conditionalRequests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function returnIfChanged<TResponse, TParams>(
4141
: TParams & {headers: Record<string, string>};
4242

4343
const cacheKey = cacheId ?? JSON.stringify(options);
44-
logDebug("Performing conditional request for cache key:", cacheKey);
44+
logTrace("Performing conditional request for cache key:", cacheKey);
4545

4646
// Add If-None-Match header if we have an ETag for this key
4747
const cacheMatch = timestamp ? timestampMap.get(cacheKey) : etagMap.get(cacheKey);

src/pinnedWorkflows/pinnedWorkflows.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ export async function initPinnedWorkflows(store: RunStore) {
5656
}
5757

5858
async function _init(): Promise<void> {
59+
logDebug("Initializing pinned workflows watcher");
5960
await updatePinnedWorkflows();
6061

6162
if (refreshTimer) {
63+
logDebug("Existing pinned workflows refresh timer found, clearing it");
6264
clearInterval(refreshTimer);
6365
refreshTimer = undefined;
6466
}
6567

6668
if (isPinnedWorkflowsRefreshEnabled()) {
69+
logDebug("Pinned workflows refresh enabled, checking every", pinnedWorkflowsRefreshInterval(), "seconds");
6770
refreshTimer = setInterval(() => void refreshPinnedWorkflows(), pinnedWorkflowsRefreshInterval() * 1000);
6871
}
6972
}
@@ -116,15 +119,17 @@ async function updatePinnedWorkflows() {
116119
const workflowByPath: {[id: string]: Workflow} = {};
117120
workflows.forEach(w => (workflowByPath[w.path] = w));
118121

119-
for (const pinnedWorkflow of workflowsByWorkspace.get(workspaceName) || []) {
120-
if (!workflowByPath[pinnedWorkflow]) {
121-
log(`Unable to find pinned workflow ${pinnedWorkflow} in ${workspaceName}, ignoring`);
122-
continue;
123-
}
122+
await Promise.all(
123+
(workflowsByWorkspace.get(workspaceName) || []).map(async pinnedWorkflow => {
124+
if (!workflowByPath[pinnedWorkflow]) {
125+
log(`Unable to find pinned workflow ${pinnedWorkflow} in ${workspaceName}, ignoring`);
126+
return;
127+
}
124128

125-
const pW = createPinnedWorkflow(gitHubRepoContext, workflowByPath[pinnedWorkflow]);
126-
await refreshPinnedWorkflow(pW);
127-
}
129+
const pW = createPinnedWorkflow(gitHubRepoContext, workflowByPath[pinnedWorkflow]);
130+
return refreshPinnedWorkflow(pW);
131+
})
132+
);
128133
}
129134
}
130135

src/store/store.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ type Updater = {
1616
handle: NodeJS.Timeout | undefined;
1717
};
1818

19+
/**
20+
* Serves as the central cache store for Workflow run status in Github Actions.
21+
*
22+
* This is basically a local mirror of what is fetched from the GitHub API.
23+
*
24+
* Views should subscribe to this store's event to get updates
25+
*/
1926
export class RunStore extends EventEmitter<RunStoreEvent> {
2027
private runs = new Map<number, WorkflowRun>();
2128
private updaters = new Map<number, Updater>();

src/treeViews/currentBranch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {getCurrentBranch, getGitHubContext, GitHubRepoContext} from "../git/repo
55
import {CurrentBranchRepoNode} from "./current-branch/currentBranchRepoNode";
66

77
import {NoRunForBranchNode} from "./current-branch/noRunForBranchNode";
8-
import {log, logDebug} from "../log";
8+
import {log, logDebug, logTrace} from "../log";
99
import {RunStore} from "../store/store";
1010
import {AttemptNode} from "./shared/attemptNode";
1111
import {GitHubAPIUnreachableNode} from "./shared/gitHubApiUnreachableNode";
@@ -39,6 +39,7 @@ export class CurrentBranchTreeProvider
3939
}
4040

4141
protected _updateNode(node: WorkflowRunNode): void {
42+
logTrace(`Node updated: ${node.id} ${node.label}`);
4243
this._onDidChangeTreeData.fire(node);
4344
}
4445

src/treeViews/workflows.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22

33
import {canReachGitHubAPI} from "../api/canReachGitHubAPI";
44
import {getGitHubContext} from "../git/repository";
5-
import {log, logDebug, logError} from "../log";
5+
import {log, logDebug, logError, logTrace} from "../log";
66
import {RunStore} from "../store/store";
77
import {AttemptNode} from "./shared/attemptNode";
88
import {AuthenticationNode} from "./shared/authenticationNode";
@@ -42,6 +42,7 @@ export class WorkflowsTreeProvider
4242
}
4343

4444
protected _updateNode(node: WorkflowRunNode): void {
45+
logTrace(`Workflow Tree Node updated: ${node.description} ${node.label}`);
4546
this._onDidChangeTreeData.fire(node);
4647
}
4748

0 commit comments

Comments
 (0)