Repository navigation
Conversation
daee991 to
c782625
Compare
Adapt relevant functions by narrowing their types or skipping steps that would otherwise have been skipped as well
c782625 to
ac8654a
Compare
There was a problem hiding this comment.
Warning
- Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.
🟡 Changes recommended
The central aborted-configuration persistence and restoration path lacks direct unit coverage, with additional minor diagnostic and documentation issues.
4 open findings
Files excluded by content exclusion policy (1)
- lib/entry-points.js
🧠 Review effort: Balanced
| * The file will only contain parts of {@link config} that are relevant to | ||
| * the `init-post` step in the workflow. | ||
| */ | ||
| export function saveAbortedInitConfig( |
henrymercer
left a comment
There was a problem hiding this comment.
Some suggestions and comments, but this broadly looks good to me. I'm happy with testing the new functionality here using the PR check added by #4223.
| export function hasConfigKey<Key extends ActionConfigProperties>( | ||
| config: Partial<Config>, | ||
| key: Key, | ||
| ): config is ActionConfig<Key> { |
There was a problem hiding this comment.
OOI, does TypeScript not infer this itself?
There was a problem hiding this comment.
If we have e.g.
function bar(config: ActionConfig<"codeQLCmd">) {}
function foo(config: Partial<Config>) {
if (config.codeQLCmd === undefined) {
return;
}
bar(config); // Type error
}because TypeScript narrows the type of config.codeQLCmd not config.
| if (config === undefined) { | ||
| if (config?.codeQLCmd === undefined) { | ||
| logger.warning( | ||
| "Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.", |
There was a problem hiding this comment.
Should we narrow this log down to "before CodeQL could be set up", now that we have that more restrictive condition?
There was a problem hiding this comment.
Firstly, your comment made me realise that this change to the check is no longer needed. I initially allowed undefined for codeQLCmd in AbortedInitConfig, but then realised that this was feature creep for a potential future use where we might want to write the aborted configuration before the CLI is setup. However, since there's currently no need for this, I simplified it to require codeQLCmd to be set but then forgot to revert this check here. I'll do that now.
| * to requiring only those. For example, in `ActionConfig<"codeqlCmd">` | ||
| * all properties except `codeqlCmd` are optional. | ||
| */ | ||
| export type ActionConfig< |
There was a problem hiding this comment.
Bikeshed: ConfigWith?
Also, we should be careful with properties that might be optional, e.g. buildMode can be undefined in a successful configuration.
There was a problem hiding this comment.
Some time ago we talked about how Config is an awful name for the type and that it's really more representing the state of the Action that we persist across steps. It's also ambiguous as to whether it refers to the Action, CLI, or something else. I thought that I would use this opportunity to move away from that and introduce a better name.


This PR mainly contains cherry-picked changes from #4223 for easier review and since they are somewhat separate from the main goal there. In #4223, the goal is to persist and upload diagnostics that are created before the database is initialised. That is the case if, for example, we produce diagnostics and then realise that we should abort the analysis and shouldn't initialise a database.
One issue with making diagnostics from a failed
initrun available is that theinit-postaction does not produce or upload any debug artifacts (including the failed SARIF file that would contain the diagnostics) if noConfigwas written byinit. However,initonly writes theConfigthese days if it successfully runs to completion.This PR addresses this by making the following changes:
Configis written byinitif the step is aborted (i.e. an exception is thrown in the firsttry/catchblock). To avoid potentially breaking any code that treats the existence of the normal configuration file as a signal thatinitwas successful, we store the "failed" configuration with a different name.Configwhen a fullConfigis available, we write a minimal subset of properties that are needed byinit-postto try and produce the debug artifacts we are after. This is also intended to guard against the possibility that some functions interpret the presence of some properties as indication thatinitwas successful.init-postAction reads this "failed" config only if a normal config couldn't be found.ActionStatetype is added. This is equivalent toConfigby default and, besides having a name which more accurately reflects whatConfigis, has a type parameter that can be used to mark only some properties as required while unnamed ones are optional.Configconsumers so that they don't unnecessarily require a fullConfig.init-postto potentially call them with a "failed" config.Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist