Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9463df7516 | |||
| 45fab3f079 | |||
| d597b772e2 | |||
| 7abc703dbb | |||
| f9f94ecffd | |||
| c5002c79a5 | |||
| 1c720bfd18 | |||
| e55790a197 | |||
| a46e606ed0 | |||
| b6f5d3ea9f | |||
| d909647537 | |||
| a13fa85dcd | |||
| 7fbd2d120a | |||
| 9ac8c2a48e | |||
| e0fc982ae5 | |||
| c3736a0955 | |||
| 05d621a883 | |||
| 7927a80e63 | |||
| 6d02be04f7 | |||
| e27eec824f | |||
| 01def5d074 |
@@ -10,7 +10,7 @@ jobs:
|
||||
pre-commit-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18.17.1'
|
||||
cache: 'yarn'
|
||||
|
||||
+3
-3
@@ -554,7 +554,7 @@ class OidcClient {
|
||||
.catch(error => {
|
||||
throw new Error(`Failed to get ID Token. \n
|
||||
Error Code : ${error.statusCode}\n
|
||||
Error Message: ${error.result.message}`);
|
||||
Error Message: ${error.message}`);
|
||||
});
|
||||
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||||
if (!id_token) {
|
||||
@@ -14133,8 +14133,8 @@ const parseInputs = () => {
|
||||
}),
|
||||
speckleFunctionRecommendedCPUm: parseInt(core.getInput('speckle_function_recommended_cpu_m', {
|
||||
required: false
|
||||
})),
|
||||
speckleFunctionRecommendedMemoryMi: parseInt(core.getInput('speckle_function_recommended_memory_mi', { required: false }))
|
||||
})) || undefined,
|
||||
speckleFunctionRecommendedMemoryMi: parseInt(core.getInput('speckle_function_recommended_memory_mi', { required: false })) || undefined
|
||||
};
|
||||
const inputParseResult = InputVariablesSchema.safeParse(rawInputs);
|
||||
if (inputParseResult.success)
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+16
-16
@@ -23,32 +23,32 @@
|
||||
"node": "^16.19.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/core": "^1.10.1",
|
||||
"@lifeomic/attempt": "^3.0.3",
|
||||
"node-fetch": "^3.3.2",
|
||||
"zod": "^3.22.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/node": "^18.17.4",
|
||||
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
||||
"@typescript-eslint/parser": "^6.3.0",
|
||||
"@types/node": "^18.18.8",
|
||||
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
||||
"@typescript-eslint/parser": "^6.10.0",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"@vitest/coverage-istanbul": "^0.34.1",
|
||||
"eslint": "^8.46.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.5",
|
||||
"@vitest/coverage-istanbul": "^0.34.6",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-filenames": "latest",
|
||||
"eslint-plugin-github": "^4.9.2",
|
||||
"eslint-plugin-github": "^4.10.1",
|
||||
"eslint-plugin-i18n-text": "^1.0.1",
|
||||
"eslint-plugin-import": "^2.28.0",
|
||||
"eslint-plugin-import": "^2.29.0",
|
||||
"eslint-plugin-no-only-tests": "^3.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"eslint-plugin-vitest": "^0.2.8",
|
||||
"msw": "^1.3.2",
|
||||
"prettier": "^3.0.1",
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "^4.4.9",
|
||||
"vitest": "^0.34.1"
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"eslint-plugin-vitest": "^0.3.9",
|
||||
"msw": "^2.0.5",
|
||||
"prettier": "^3.0.3",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^4.5.0",
|
||||
"vitest": "^0.34.6"
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -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
|
||||
|
||||
+71
-16
@@ -13,7 +13,7 @@ import { mkdtempSync, writeFileSync, rmdirSync, rmSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { setupServer } from 'msw/node'
|
||||
import { rest } from 'msw'
|
||||
import { http, HttpResponse } from 'msw'
|
||||
import { z } from 'zod'
|
||||
|
||||
describe('Register new version', () => {
|
||||
@@ -22,30 +22,37 @@ describe('Register new version', () => {
|
||||
let count500Errors = 0
|
||||
|
||||
const server = setupServer(
|
||||
rest.post(
|
||||
http.post(
|
||||
'http://myfakeautomate.speckle.internal/api/v1/functions/fake_function_id/versions',
|
||||
async (req, res, ctx) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await req.json())
|
||||
async ({ request }) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
|
||||
expect(parseResult.success).to.be.true
|
||||
countHappyPath++
|
||||
return res(ctx.status(201), ctx.json({ versionId: 'fake_version_id' }))
|
||||
return new HttpResponse(JSON.stringify({ versionId: 'fake_version_id' }), {
|
||||
status: 201,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
}
|
||||
),
|
||||
rest.post(
|
||||
http.post(
|
||||
'http://myfakeautomate.speckle.internal/api/v1/functions/network_error/versions',
|
||||
async (req, res, ctx) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await req.json())
|
||||
async ({ request }) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
|
||||
expect(parseResult.success).to.be.true
|
||||
return res.networkError('Failed to connect to server')
|
||||
return HttpResponse.error() // simulates a network error
|
||||
}
|
||||
),
|
||||
rest.post(
|
||||
http.post(
|
||||
'http://myfakeautomate.speckle.internal/api/v1/functions/500_response/versions',
|
||||
async (req, res, ctx) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await req.json())
|
||||
async ({ request }) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
|
||||
expect(parseResult.success).to.be.true
|
||||
count500Errors++
|
||||
return res(ctx.status(500))
|
||||
return new HttpResponse(null, {
|
||||
status: 500
|
||||
})
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -155,8 +162,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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user