Skip to content

Commit

Permalink
Allow recommended CPU and memory to be NaN values and not error (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
iainsproat committed Nov 10, 2023
1 parent 1c720bf commit c5002c7
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 14 deletions.
4 changes: 2 additions & 2 deletions dist/action/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/action/index.js.map

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ const parseInputs = (): InputVariables => {
speckleFunctionReleaseTag: core.getInput('speckle_function_release_tag', {
required: true
}),
speckleFunctionRecommendedCPUm: parseInt(
core.getInput('speckle_function_recommended_cpu_m', {
required: false
})
),
speckleFunctionRecommendedMemoryMi: parseInt(
core.getInput('speckle_function_recommended_memory_mi', { required: false })
)
speckleFunctionRecommendedCPUm:
parseInt(
core.getInput('speckle_function_recommended_cpu_m', {
required: false
})
) || undefined,
speckleFunctionRecommendedMemoryMi:
parseInt(
core.getInput('speckle_function_recommended_memory_mi', { required: false })
) || undefined
}
const inputParseResult = InputVariablesSchema.safeParse(rawInputs)
if (inputParseResult.success) return inputParseResult.data
Expand Down
54 changes: 51 additions & 3 deletions tests/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,56 @@ const FunctionVersionRequestSchema = z.object({
.trim()
.min(6)
.transform((arg: string) => arg.substring(0, 10)),
versionTag: z.string(),
inputSchema: z.record(z.string(), z.unknown()).nullable(),
versionTag: z
.string()
.regex(
new RegExp('^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$'),
'A maximum of 128 characters are permitted. The first character must be alphanumeric (of lower or upper case) or an underscore, the subsequent characters may be alphanumeric (or lower or upper case), underscore, hyphen, or period.'
), // regex as per OCI distribution spec https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests
inputSchema: z.record(z.string(), z.unknown()).nullable(), // TODO: we need to validate the jsonschema somehow
command: z.array(z.string().nonempty()),
annotations: z.object({}).optional()
annotations: z
.object({
'speckle.systems/v1alpha1/publishing/status': z
.enum(['publish', 'draft', 'archive'], {
description:
'Whether this Function is published (and should appear in the library), a draft, or archived.'
})
.default('draft'),
'speckle.systems/v1alpha1/author': z
.string({
description:
'The name of the authoring organization or individual of this Function.'
})
.optional(),
'speckle.systems/v1alpha1/license': z
.enum(['MIT', 'BSD', 'Apache-2.0', 'MPL', 'CC0', 'Unlicense'], {
description:
'The license under under which this Function is made available. This must match the license in the source code repository.'
})
.optional(), //TODO match the specification for license names
'speckle.systems/v1alpha1/website': z
.string({
description: 'The marketing website for this Function or its authors.'
})
.url()
.optional(),
'speckle.systems/v1alpha1/documentation': z
.string({
description:
'The documentation website for this function. For example, this could be a url to the README in the source code repository.'
})
.url()
.optional(),
'speckle.systems/v1alpha1/keywords': z
.string({
description:
'Comma separated list of keywords used for categorizing this function.'
})
.optional(),
'speckle.systems/v1alpha1/description': z.string().optional()
})
.optional(),
recommendedCPUm: z.number().gte(100).lte(16000).finite().optional().default(1000),
recommendedMemoryMi: z.number().gte(1).lte(8000).finite().optional().default(100)
})

0 comments on commit c5002c7

Please sign in to comment.