Skip to content

Commit

Permalink
Fix intermittent JSON schema building errors in CI (#687)
Browse files Browse the repository at this point in the history
This PR drops the usage of `as const` in `supported-php-extensions.ts`
since they don't seem to play well with the `ts-json-schema-generator`
package that generates Blueprint JSON schema from TypeScript types.

Specifically, it seems to be the root cause behind these intermittent
failures only happening in GitHub actions:

```
UnknownNodeError: Unknown node " supportedPHPExtensions" of kind "Identifier"
```

It's unclear to me why `as const` is fine in
`supported-php-versions.ts`. Perhaps it's because that file uses just
lists and not objects?

I also don't get why the failures are only intermittent. Let's further
investigate if and when these errors return.
  • Loading branch information
adamziel authored Oct 12, 2023
1 parent cdc468b commit 82bfcad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions packages/php-wasm/universal/src/lib/supported-php-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
export const supportedPHPExtensions = [
// The extensions list is repeated on purpose to avoid CI errors
// @see https://github.com/WordPress/wordpress-playground/pull/687
export type SupportedPHPExtension = 'iconv' | 'mbstring' | 'xml-bundle' | 'gd';
export const SupportedPHPExtensionsList = [
'iconv',
'mbstring',
'xml-bundle',
'gd',
] as const;
export type SupportedPHPExtension = (typeof supportedPHPExtensions)[number];
export const SupportedPHPExtensionsList =
supportedPHPExtensions as any as SupportedPHPExtension[];
];

export const SupportedPHPExtensionBundles = {
'kitchen-sink': supportedPHPExtensions,
} as const;
export type SupportedPHPExtensionBundle =
keyof typeof SupportedPHPExtensionBundles;
'kitchen-sink': SupportedPHPExtensionsList,
};
export type SupportedPHPExtensionBundle = 'kitchen-sink';
6 changes: 3 additions & 3 deletions packages/playground/blueprints/src/lib/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
LatestSupportedPHPVersion,
SupportedPHPExtension,
SupportedPHPExtensionsList,
SupportedPHPExtensionBundle,
SupportedPHPExtensionBundles,
SupportedPHPVersion,
SupportedPHPVersions,
UniversalPHP,
} from '@php-wasm/universal';
import type { SupportedPHPExtensionBundle } from '@php-wasm/universal';
import { isFileReference, Resource } from './resources';
import { Step, StepDefinition } from './steps';
import * as stepHandlers from './steps/handlers';
Expand Down Expand Up @@ -235,14 +235,14 @@ function compilePHPExtensions(
): SupportedPHPExtension[] {
const extensions = SupportedPHPExtensionsList.filter((extension) =>
requestedExtensions.includes(extension)
);
) as SupportedPHPExtension[];
const extensionsFromBundles = requestedBundles.flatMap((bundle) =>
bundle in SupportedPHPExtensionBundles
? SupportedPHPExtensionBundles[
bundle as SupportedPHPExtensionBundle
]
: []
);
) as SupportedPHPExtension[];
// Deduplicate
return Array.from(new Set([...extensions, ...extensionsFromBundles]));
}
Expand Down

0 comments on commit 82bfcad

Please sign in to comment.