Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff56aeb1c1 | |||
| c5d080d60d | |||
| d5c4844583 | |||
| 2a971c6f16 | |||
| 67d44ba23f | |||
| 7fdec8e7fc | |||
| 5493d6f271 | |||
| 775a02139f | |||
| e68d24406e | |||
| e87630d731 | |||
| 5c55ca7ea8 | |||
| 970e0f066b | |||
| df92d9c409 | |||
| f2adde5085 | |||
| 8ea1a1bc8e | |||
| a13b1e49e5 | |||
| 6b66e1479d | |||
| ade5dbf5cd | |||
| 0a39db82dc | |||
| be8fb87593 | |||
| e4a948b322 | |||
| 5eefa5a400 | |||
| 374d08671f | |||
| 45de2b5144 | |||
| 94cd180e64 |
@@ -37,9 +37,17 @@ Associates this new version with the given ID of a Speckle Function.
|
||||
|
||||
Your Speckle Token must have write permissions for the Speckle Function with this ID, otherwise the publish will fail.
|
||||
|
||||
#### `speckle_function_input_schema_file_path`
|
||||
|
||||
*Optional.* The path to the JSON Schema file that describes the input schema for this version of the Speckle Function. This file is used to define the input form that will be presented to users when they compose an Automation based on this Function. If not provided, no input form will be presented to users.
|
||||
|
||||
#### `speckle_function_command`
|
||||
|
||||
The command to run when this version of the Speckle Function is invoked. This command must be a valid command for the Docker image that contains the Speckle Function. This command must be a single string.
|
||||
|
||||
#### `speckle_function_release_tag`
|
||||
|
||||
The release tag for this version of the Speckle Function. This is intended to provide a more human understandable name for this version, and we recommend using the [Semver](https://semver.org) naming conventions. The name must conform to the following:
|
||||
The release tag for this version of the Speckle Function. This is intended to provide a more human understandable name for this version, and we recommend using the Git SHA of the commit used to generate this function version. The name must conform to the following:
|
||||
|
||||
- A minimum of 1 character is required.
|
||||
- A maximum of 128 characters are permitted.
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+24406
-235
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+13
-13
@@ -29,26 +29,26 @@
|
||||
"zod": "^3.22.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@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.6",
|
||||
"eslint": "^8.53.0",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^18.19.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
||||
"@typescript-eslint/parser": "^6.14.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"@vitest/coverage-istanbul": "^1.0.4",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-filenames": "latest",
|
||||
"eslint-plugin-github": "^4.10.1",
|
||||
"eslint-plugin-i18n-text": "^1.0.1",
|
||||
"eslint-plugin-import": "^2.29.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-no-only-tests": "^3.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"eslint-plugin-vitest": "^0.3.9",
|
||||
"msw": "^2.0.5",
|
||||
"prettier": "^3.0.3",
|
||||
"eslint-plugin-vitest": "^0.3.20",
|
||||
"msw": "^2.0.11",
|
||||
"prettier": "^3.1.1",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^4.5.0",
|
||||
"vitest": "^0.34.6"
|
||||
"vite": "^5.0.11",
|
||||
"vitest": "^1.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
+14
-3
@@ -173,9 +173,20 @@ const registerNewVersionForTheSpeckleAutomateFunction = async (
|
||||
if (parsedResult.success) return parsedResult.data
|
||||
throw parsedResult.error
|
||||
} catch (err) {
|
||||
throw Error('Failed to register new function version to the automate server', {
|
||||
cause: err
|
||||
})
|
||||
if (err instanceof Error) {
|
||||
throw Error(
|
||||
`Failed to register new function version to the automate server. ${err.message}`,
|
||||
{
|
||||
cause: err
|
||||
}
|
||||
)
|
||||
}
|
||||
throw Error(
|
||||
`Failed to register new function version to the automate server. ${err}`,
|
||||
{
|
||||
cause: err
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+78
-3
@@ -20,6 +20,49 @@ describe('Register new version', () => {
|
||||
let tmpDir: string
|
||||
let countHappyPath = 0
|
||||
let count500Errors = 0
|
||||
let count422Errors = 0
|
||||
|
||||
const error422 = {
|
||||
type: 'H3Error',
|
||||
message: 'Body parsing failed',
|
||||
stack: `Error: Body parsing failed
|
||||
at createError...`,
|
||||
statusCode: 422,
|
||||
fatal: false,
|
||||
unhandled: false,
|
||||
statusMessage: 'Body parsing failed',
|
||||
data: {
|
||||
type: 'ZodError',
|
||||
message:
|
||||
'[\n {\n "code": "custom",\n "message": "Invalid JSON schema: strict mode: unknown keyword: \\"IAmInvalid\\"",\n "path": [\n "inputSchema"\n ]\n }\n]',
|
||||
stack: {
|
||||
ZodError: [
|
||||
{
|
||||
code: 'custom',
|
||||
message: 'Invalid JSON schema: strict mode: unknown keyword: "IAmInvalid"',
|
||||
path: ['inputSchema']
|
||||
}
|
||||
]
|
||||
},
|
||||
aggregateErrors: [
|
||||
{
|
||||
type: 'Object',
|
||||
message: 'Invalid JSON schema: strict mode: unknown keyword: "IAmInvalid"',
|
||||
stack: {},
|
||||
code: 'custom',
|
||||
path: ['inputSchema']
|
||||
}
|
||||
],
|
||||
issues: [
|
||||
{
|
||||
code: 'custom',
|
||||
message: 'Invalid JSON schema: strict mode: unknown keyword: "IAmInvalid"',
|
||||
path: ['inputSchema']
|
||||
}
|
||||
],
|
||||
name: 'ZodError'
|
||||
}
|
||||
}
|
||||
|
||||
const server = setupServer(
|
||||
http.post(
|
||||
@@ -44,15 +87,29 @@ describe('Register new version', () => {
|
||||
return HttpResponse.error() // simulates a network error
|
||||
}
|
||||
),
|
||||
http.post(
|
||||
'http://myfakeautomate.speckle.internal/api/v1/functions/422_response/versions',
|
||||
async ({ request }) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
|
||||
expect(parseResult.success).to.be.true
|
||||
count422Errors++
|
||||
return HttpResponse.json(error422, {
|
||||
status: 422
|
||||
})
|
||||
}
|
||||
),
|
||||
http.post(
|
||||
'http://myfakeautomate.speckle.internal/api/v1/functions/500_response/versions',
|
||||
async ({ request }) => {
|
||||
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
|
||||
expect(parseResult.success).to.be.true
|
||||
count500Errors++
|
||||
return new HttpResponse(null, {
|
||||
status: 500
|
||||
})
|
||||
return HttpResponse.json(
|
||||
{},
|
||||
{
|
||||
status: 500
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -123,6 +180,24 @@ describe('Register new version', () => {
|
||||
expect(count500Errors).to.toBeGreaterThan(1) // we expect the action to retry the request
|
||||
count500Errors = 0
|
||||
})
|
||||
it('handles 422 responses', async () => {
|
||||
writeFileSync(join(tmpDir, 'schema.json'), '{}')
|
||||
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', '422_response')
|
||||
vi.stubEnv('INPUT_SPECKLE_TOKEN', '{token}')
|
||||
vi.stubEnv('INPUT_SPECKLE_FUNCTION_COMMAND', 'echo "hello automate"')
|
||||
vi.stubEnv('HOME', tmpDir) // the input schema file path is assumed to be relative to the home directory
|
||||
vi.stubEnv('INPUT_SPECKLE_FUNCTION_INPUT_SCHEMA_FILE_PATH', './schema.json')
|
||||
vi.stubEnv('INPUT_SPECKLE_FUNCTION_RELEASE_TAG', 'v1.0.0')
|
||||
vi.stubEnv('INPUT_SPECKLE_AUTOMATE_URL', 'http://myfakeautomate.speckle.internal')
|
||||
vi.stubEnv('GITHUB_SHA', 'commitSha')
|
||||
vi.stubEnv('GITHUB_REF_TYPE', 'commit')
|
||||
vi.stubEnv('GITHUB_REF_NAME', 'version')
|
||||
await expect(run()).rejects.toThrow(
|
||||
'Failed to register new function version to the automate server'
|
||||
)
|
||||
expect(count422Errors).to.eq(1) // we expect the action not to retry the request
|
||||
count422Errors = 0 // reset the count after the test
|
||||
})
|
||||
it('errors if the token is empty', async () => {
|
||||
writeFileSync(join(tmpDir, 'schema.json'), '{}')
|
||||
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', 'fake_function_id')
|
||||
|
||||
Reference in New Issue
Block a user