35 Commits

Author SHA1 Message Date
Iain Sproat 0e00242543 Align with API and update documentation (#261) 2023-11-12 17:17:56 +00:00
dependabot[bot] 9463df7516 build(deps-dev): bump typescript from 5.1.6 to 5.2.2 (#253)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.1.6 to 5.2.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.1.6...v5.2.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-10 23:00:15 +00:00
dependabot[bot] 45fab3f079 build(deps): bump @actions/core from 1.10.0 to 1.10.1 (#256)
* build(deps): bump @actions/core from 1.10.0 to 1.10.1

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.10.0 to 1.10.1.
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Build dist package

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
2023-11-10 22:58:34 +00:00
dependabot[bot] d597b772e2 build(deps-dev): bump eslint-plugin-github from 4.9.2 to 4.10.1 (#254)
Bumps [eslint-plugin-github](https://github.com/github/eslint-plugin-github) from 4.9.2 to 4.10.1.
- [Release notes](https://github.com/github/eslint-plugin-github/releases)
- [Commits](https://github.com/github/eslint-plugin-github/compare/v4.9.2...v4.10.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-github
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-10 22:55:35 +00:00
dependabot[bot] 7abc703dbb build(deps-dev): bump @typescript-eslint/parser from 6.9.1 to 6.10.0 (#257)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.9.1 to 6.10.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.10.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-10 22:52:01 +00:00
dependabot[bot] f9f94ecffd build(deps-dev): bump msw from 1.3.2 to 2.0.5 (#259)
* build(deps-dev): bump msw from 1.3.2 to 2.0.5

Bumps [msw](https://github.com/mswjs/msw) from 1.3.2 to 2.0.5.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mswjs/msw/compare/v1.3.2...v2.0.5)

---
updated-dependencies:
- dependency-name: msw
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Migrate to msw 2.x

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
2023-11-10 22:51:49 +00:00
Iain Sproat c5002c79a5 Allow recommended CPU and memory to be NaN values and not error (#260) 2023-11-10 22:35:56 +00:00
dependabot[bot] 1c720bfd18 build(deps-dev): bump eslint-plugin-prettier from 5.0.0 to 5.0.1 (#251)
Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-plugin-prettier/compare/v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 17:34:06 +00:00
dependabot[bot] e55790a197 build(deps-dev): bump eslint-plugin-import from 2.28.0 to 2.29.0 (#245)
Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.28.0 to 2.29.0.
- [Release notes](https://github.com/import-js/eslint-plugin-import/releases)
- [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-plugin-import/compare/v2.28.0...v2.29.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-import
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 17:33:47 +00:00
dependabot[bot] a46e606ed0 build(deps-dev): bump vitest from 0.34.1 to 0.34.6 (#246)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 0.34.1 to 0.34.6.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.34.6/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 17:33:27 +00:00
dependabot[bot] b6f5d3ea9f build(deps-dev): bump @typescript-eslint/eslint-plugin (#252)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 6.3.0 to 6.10.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.10.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 17:33:00 +00:00
dependabot[bot] d909647537 build(deps-dev): bump vite from 4.4.9 to 4.5.0 (#247)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.4.9 to 4.5.0.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.5.0/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 17:18:35 +00:00
dependabot[bot] a13fa85dcd build(deps-dev): bump @vitest/coverage-istanbul from 0.34.1 to 0.34.6 (#248)
Bumps [@vitest/coverage-istanbul](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-istanbul) from 0.34.1 to 0.34.6.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v0.34.6/packages/coverage-istanbul)

---
updated-dependencies:
- dependency-name: "@vitest/coverage-istanbul"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 17:08:37 +00:00
dependabot[bot] 7fbd2d120a build(deps-dev): bump eslint-plugin-vitest from 0.2.8 to 0.3.9 (#249)
Bumps [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) from 0.2.8 to 0.3.9.
- [Release notes](https://github.com/veritem/eslint-plugin-vitest/releases)
- [Commits](https://github.com/veritem/eslint-plugin-vitest/compare/v0.2.8...v0.3.9)

---
updated-dependencies:
- dependency-name: eslint-plugin-vitest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 17:08:09 +00:00
dependabot[bot] 9ac8c2a48e build(deps-dev): bump eslint-import-resolver-typescript (#218)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 3.5.5 to 3.6.1.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v3.5.5...v3.6.1)

---
updated-dependencies:
- dependency-name: eslint-import-resolver-typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 14:02:13 +00:00
dependabot[bot] e0fc982ae5 build(deps-dev): bump @typescript-eslint/parser from 6.3.0 to 6.9.1 (#241)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.3.0 to 6.9.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.9.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 14:00:15 +00:00
dependabot[bot] c3736a0955 build(deps): bump actions/setup-node from 3 to 4 (#237)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 13:57:14 +00:00
dependabot[bot] 05d621a883 build(deps): bump actions/checkout from 3 to 4 (#209)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 13:56:58 +00:00
dependabot[bot] 7927a80e63 build(deps-dev): bump prettier from 3.0.1 to 3.0.3 (#206)
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.1 to 3.0.3.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.1...3.0.3)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 13:56:32 +00:00
dependabot[bot] 6d02be04f7 build(deps-dev): bump eslint from 8.46.0 to 8.53.0 (#244)
Bumps [eslint](https://github.com/eslint/eslint) from 8.46.0 to 8.53.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.46.0...v8.53.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 13:55:21 +00:00
dependabot[bot] e27eec824f build(deps): bump @babel/traverse from 7.22.8 to 7.23.2 (#235)
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.8 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 13:52:59 +00:00
dependabot[bot] 01def5d074 build(deps-dev): bump @types/node from 18.17.4 to 18.18.8 (#242)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.17.4 to 18.18.8.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 13:52:33 +00:00
Iain Sproat 2f4e3cf8e3 feat(compute resources): suggest recommended limits to CPU and Memory for a Function (#243)
* feat(compute resources): suggest recommended limits to CPU and Memory for a Function

* Adds documentation
2023-11-06 14:48:11 +01:00
Iain Sproat 2cf7d93b74 Add tests and refactor (#231)
- generally improves tests which were not working, and adds them to CI pipeline
- refactors to catch errors
- Rename github action to match current usage
- Informing GitHub of failure is done at the top-level method
- Add tests for network and http errors
- reduce coverage thresholds
2023-10-19 15:45:58 +01:00
dependabot[bot] bcc6ed5ca1 build(deps): bump zod from 3.21.4 to 3.22.3 (#233)
* build(deps): bump zod from 3.21.4 to 3.22.3

Bumps [zod](https://github.com/colinhacks/zod) from 3.21.4 to 3.22.3.
- [Release notes](https://github.com/colinhacks/zod/releases)
- [Changelog](https://github.com/colinhacks/zod/blob/master/CHANGELOG.md)
- [Commits](https://github.com/colinhacks/zod/compare/v3.21.4...v3.22.3)

---
updated-dependencies:
- dependency-name: zod
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update dist

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
2023-10-16 11:31:13 +01:00
dependabot[bot] 0c51cac769 build(deps): bump postcss from 8.4.25 to 8.4.31 (#227)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.25 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.25...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 11:11:19 +01:00
dependabot[bot] 47b660068e build(deps): bump get-func-name from 2.0.0 to 2.0.2 (#223)
Bumps [get-func-name](https://github.com/chaijs/get-func-name) from 2.0.0 to 2.0.2.
- [Release notes](https://github.com/chaijs/get-func-name/releases)
- [Commits](https://github.com/chaijs/get-func-name/commits/v2.0.2)

---
updated-dependencies:
- dependency-name: get-func-name
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 11:10:38 +01:00
Gergő Jedlicska 342c0fb72d update action variables 2023-09-22 12:17:32 +02:00
Gergő Jedlicska 5462de9d2d functionReleaseTag as an input 2023-09-22 11:35:15 +02:00
Gergő Jedlicska ea219ded92 feat: use shorthened git commit id, change output variable to version tag 2023-09-18 17:26:12 +02:00
Gergő Jedlicska 4599eff830 explicitly read from the home directory 2023-08-11 16:04:42 +02:00
Gergő Jedlicska 352365220a move to a file based function input 2023-08-10 17:03:40 +02:00
Gergő Jedlicska c3d711f76d update dist 2023-08-10 16:26:47 +02:00
Gergő Jedlicska ae84132685 Merge branch 'main' of github.com:specklesystems/speckle-automate-github-action 2023-08-10 16:06:40 +02:00
Gergő Jedlicska 937dd88b55 merge error raising 2023-08-10 16:06:11 +02:00
11 changed files with 2386 additions and 588 deletions
+9 -2
View File
@@ -7,10 +7,10 @@ on: # rebuild any PRs and main branch changes
- 'releases/*'
jobs:
pre-commit:
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,6 +19,10 @@ jobs:
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- uses: actions/setup-node@v4
with:
node-version: '18.17.1'
cache: 'yarn'
- name: Yarn Install
run: yarn install
- uses: actions/cache/save@v3
@@ -27,3 +31,6 @@ jobs:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- uses: pre-commit/action@v3.0.0
- name: Tests
run: yarn test
continue-on-error: true # ignore test failures for now
+38 -21
View File
@@ -13,7 +13,6 @@ It is a GitHub Action that publishes a Speckle Automate Function definition to S
> This is a low level building block action.
> As a Speckle Automate Function developer you probably want to use our [composite action](https://github.com/specklesystems/speckle-automate-github-composite-action)
### Inputs
#### `speckle_automate_url`
@@ -32,19 +31,33 @@ If you believe your token has been compromised, please revoke it immediately on
Please note that this is not a Speckle Account token, but a **Speckle Automate API** token. You can create one by logging into the [Speckle Automate Server](https://automate.speckle.dev) and going to the [API Tokens](https://automate.speckle.dev/tokens) page.
#### `speckle_function_path`
The path to the Speckle Automate Function to publish. This path is relative to the root of the repository. If you provide a path to a directory, your Speckle Automate Function must be in a file named `specklefunction.yaml` within that directory.
#### `speckle_function_id`
*Optional.* If you have already registered a Speckle Function, you can use the ID of that Speckle Function to ensure that any changes are associated with it.
If you do not provide a Function Id, we will attempt to determine the Function ID based on the GitHub server, GitHub repository, Reference (branch), and the Speckle Function Path.
Providing a Speckle Function ID allows you to change one of those values, and update the original Function instead of creating a new one.
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_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:
- A minimum of 1 character is required.
- A maximum of 128 characters are permitted.
- The first character must be alphanumeric (of lower or upper case) or an underscor.
- Subsequent characters, if any, must be either alphanumeric (lower or upper case), underscore, hyphen, or a period.
#### `speckle_function_recommended_cpu_m`
*Optional.* The recommended maximum CPU in millicores for the function. If the Function exceeds this limit, it will be throttled to run within the limit.
1000 millicores = 1 CPU core. Defaults to 1000 millicores (1 CPU core).
#### `speckle_function_recommended_memory_mi`
*Optional.* The recommended maximum memory in mebibytes for the function. If the Function exceeds this limit, it will be **terminated**.
1024 mebibytes = 1 gibibyte. Defaults to 100 mebibytes.
### Outputs
#### `version_id`
@@ -67,9 +80,9 @@ with:
# speckle_automate_url is optional and defaults to https://automate.speckle.dev
# The speckle_token is a secret and must be stored in GitHub as an encrypted secret
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
speckle_token: ${{ secrets.SPECKLE_TOKEN }}
# speckle_function_path is optional and defaults to ./specklefunction.yaml
# speckle_function_id is optional and will be auto-generated if not provided
speckle_token: "${{ secrets.SPECKLE_TOKEN }}"
speckle_function_id: "abcdefghij"
speckle_function_release_tag: "1.0.0"
```
#### Publish a function to a self-hosted server
@@ -81,8 +94,8 @@ with:
speckle_automate_url: https://example.org
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
speckle_token: ${{ secrets.SPECKLE_TOKEN }}
# speckle_function_path is optional and defaults to ./specklefunction.yaml
# speckle_function_id is optional and will be auto-generated if not provided
speckle_function_id: "abcdefghij"
speckle_function_release_tag: "1.0.0"
```
### Example usage within an entire GitHub Actions Workflow
@@ -113,12 +126,6 @@ jobs:
# but Speckle Automate does
name: Checkout
uses: actions/checkout@v3
-
id: speckle
name: Register Speckle Function
uses: actions/speckle-automate-github-action@0.1.0
with:
speckle_token: ${{ secrets.SPECKLE_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
@@ -143,7 +150,17 @@ jobs:
# ## platforms must match the platforms that you have registered with Speckle Automate, which also defaults to linux/amd64.
# platforms: linux/amd64
push: true
tags: ${{ steps.speckle.outputs.image_name }}
# The name of the image to build and push.
# This must be the automate url host, followed by the function id, followed by the release tag.
tags: automate.speckle.dev/abcdefghij:1.0.0
-
id: speckle
name: Register Speckle Function
uses: actions/speckle-automate-github-action@0.1.0
with:
speckle_token: ${{ secrets.SPECKLE_TOKEN }}
speckle_function_id: "abcdefghij"
speckle_function_release_tag: "1.0.0"
```
## Developing & Debugging
+13 -6
View File
@@ -15,17 +15,24 @@ inputs:
speckle_function_id:
description: 'The unique identifier of the function. Go to automate to generate one.'
required: true
speckle_function_input_schema:
description: 'JSON Schema of the parameters object required by the function.'
speckle_function_input_schema_file_path:
description: 'File path containing JSON Schema of the parameters object required by the function.'
required: false
speckle_function_command:
description: 'The command to run to execute the function in a runtime environment.'
required: true
speckle_function_release_tag:
description: 'User defined tag for the function release'
required: true
speckle_function_recommended_cpu_m:
description: 'The recommended maximum CPU in millicores for the function. 1000 millicores = 1 CPU core. Defaults to 1000 millicores (1 CPU core). If the Function exceeds this limit, it will be throttled to run within the limit.'
required: false
speckle_function_recommended_memory_mi:
description: 'The recommended maximum memory in mebibytes for the function. 1024 mebibytes = 1 gibibyte. Defaults to 100 mebibytes. If the Function exceeds this limit, it will be terminated.'
required: false
outputs:
version_id:
description: 'The unique identifier of the function version.'
speckle_automate_host:
description: 'The host component of the Speckle Automate Server URL.'
speckle_automate_function_release_id:
description: 'The unique identifier of the function release.'
runs:
using: 'node16' #FIXME bump to node18 when available
main: 'dist/action/index.js'
Generated Vendored
+1 -1
View File
@@ -9,7 +9,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "toFormData": () => (/* binding */ toFormData)
/* harmony export */ });
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2777);
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2185);
/* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8010);
Generated Vendored
+240 -113
View File
@@ -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) {
@@ -7137,6 +7137,20 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net");
/***/ }),
/***/ 7561:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
/***/ }),
/***/ 9411:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
/***/ }),
/***/ 7742:
/***/ ((module) => {
@@ -7305,28 +7319,18 @@ const File = _File
/***/ }),
/***/ 2777:
/***/ 2185:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
// EXPORTS
__nccwpck_require__.d(__webpack_exports__, {
"$B": () => (/* reexport */ file/* default */.Z)
});
// UNUSED EXPORTS: Blob, blobFrom, blobFromSync, default, fileFrom, fileFromSync
;// CONCATENATED MODULE: external "node:fs"
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
;// CONCATENATED MODULE: external "node:path"
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
// EXTERNAL MODULE: ./node_modules/node-domexception/index.js
var node_domexception = __nccwpck_require__(7760);
// EXTERNAL MODULE: ./node_modules/fetch-blob/file.js
var file = __nccwpck_require__(3213);
// EXTERNAL MODULE: ./node_modules/fetch-blob/index.js
var fetch_blob = __nccwpck_require__(1410);
;// CONCATENATED MODULE: ./node_modules/fetch-blob/from.js
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "$B": () => (/* reexport safe */ _file_js__WEBPACK_IMPORTED_MODULE_3__.Z)
/* harmony export */ });
/* unused harmony exports blobFrom, blobFromSync, fileFrom, fileFromSync */
/* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(7561);
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(9411);
/* harmony import */ var node_domexception__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(7760);
/* harmony import */ var _file_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(3213);
/* harmony import */ var _index_js__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(1410);
@@ -7334,7 +7338,7 @@ var fetch_blob = __nccwpck_require__(1410);
const { stat } = external_node_fs_namespaceObject.promises
const { stat } = node_fs__WEBPACK_IMPORTED_MODULE_0__.promises
/**
* @param {string} path filepath on the disk
@@ -7425,7 +7429,7 @@ class BlobDataItem {
}
}
/* harmony default export */ const from = ((/* unused pure expression or super */ null && (blobFromSync)));
/* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ((/* unused pure expression or super */ null && (blobFromSync)));
@@ -8389,7 +8393,8 @@ class ParseStatus {
status.dirty();
if (value.status === "dirty")
status.dirty();
if (typeof value.value !== "undefined" || pair.alwaysSet) {
if (key.value !== "__proto__" &&
(typeof value.value !== "undefined" || pair.alwaysSet)) {
finalObject[key.value] = value.value;
}
}
@@ -8497,6 +8502,7 @@ class ZodType {
this.catch = this.catch.bind(this);
this.describe = this.describe.bind(this);
this.pipe = this.pipe.bind(this);
this.readonly = this.readonly.bind(this);
this.isNullable = this.isNullable.bind(this);
this.isOptional = this.isOptional.bind(this);
}
@@ -8713,6 +8719,9 @@ class ZodType {
pipe(target) {
return ZodPipeline.create(this, target);
}
readonly() {
return ZodReadonly.create(this);
}
isOptional() {
return this.safeParse(undefined).success;
}
@@ -8722,17 +8731,28 @@ class ZodType {
}
const cuidRegex = /^c[^\s-]{8,}$/i;
const cuid2Regex = /^[a-z][a-z0-9]*$/;
const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
// const uuidRegex =
// /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
// from https://stackoverflow.com/a/46181/1550155
// old version: too slow, didn't support unicode
// const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
//old email regex
// const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
// eslint-disable-next-line
const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
// const emailRegex =
// /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
// const emailRegex =
// /^[a-zA-Z0-9\.\!\#\$\%\&\'\*\+\/\=\?\^\_\`\{\|\}\~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
// const emailRegex =
// /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
// const emailRegex =
// /^[a-z0-9.!#$%&*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
const emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
let emojiRegex;
const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
// Adapted from https://stackoverflow.com/a/3143231
@@ -8772,31 +8792,6 @@ function isValidIP(ip, version) {
return false;
}
class ZodString extends ZodType {
constructor() {
super(...arguments);
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
validation,
code: ZodIssueCode.invalid_string,
...errorUtil.errToObj(message),
});
/**
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
*/
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
this.trim = () => new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "trim" }],
});
this.toLowerCase = () => new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toLowerCase" }],
});
this.toUpperCase = () => new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toUpperCase" }],
});
}
_parse(input) {
if (this._def.coerce) {
input.data = String(input.data);
@@ -8884,6 +8879,9 @@ class ZodString extends ZodType {
}
}
else if (check.kind === "emoji") {
if (!emojiRegex) {
emojiRegex = new RegExp(_emojiRegex, "u");
}
if (!emojiRegex.test(input.data)) {
ctx = this._getOrReturnCtx(input, ctx);
addIssueToContext(ctx, {
@@ -9036,6 +9034,13 @@ class ZodString extends ZodType {
}
return { status: status.value, value: input.data };
}
_regex(regex, validation, message) {
return this.refinement((data) => regex.test(data), {
validation,
code: ZodIssueCode.invalid_string,
...errorUtil.errToObj(message),
});
}
_addCheck(check) {
return new ZodString({
...this._def,
@@ -9133,6 +9138,31 @@ class ZodString extends ZodType {
...errorUtil.errToObj(message),
});
}
/**
* @deprecated Use z.string().min(1) instead.
* @see {@link ZodString.min}
*/
nonempty(message) {
return this.min(1, errorUtil.errToObj(message));
}
trim() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "trim" }],
});
}
toLowerCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toLowerCase" }],
});
}
toUpperCase() {
return new ZodString({
...this._def,
checks: [...this._def.checks, { kind: "toUpperCase" }],
});
}
get isDatetime() {
return !!this._def.checks.find((ch) => ch.kind === "datetime");
}
@@ -10841,6 +10871,12 @@ class ZodRecord extends ZodType {
}
}
class ZodMap extends ZodType {
get keySchema() {
return this._def.keyType;
}
get valueSchema() {
return this._def.valueType;
}
_parse(input) {
const { status, ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.map) {
@@ -11037,16 +11073,20 @@ class ZodFunction extends ZodType {
const params = { errorMap: ctx.common.contextualErrorMap };
const fn = ctx.data;
if (this._def.returns instanceof ZodPromise) {
return OK(async (...args) => {
// Would love a way to avoid disabling this rule, but we need
// an alias (using an arrow function was what caused 2651).
// eslint-disable-next-line @typescript-eslint/no-this-alias
const me = this;
return OK(async function (...args) {
const error = new ZodError([]);
const parsedArgs = await this._def.args
const parsedArgs = await me._def.args
.parseAsync(args, params)
.catch((e) => {
error.addIssue(makeArgsIssue(args, e));
throw error;
});
const result = await fn(...parsedArgs);
const parsedReturns = await this._def.returns._def.type
const result = await Reflect.apply(fn, this, parsedArgs);
const parsedReturns = await me._def.returns._def.type
.parseAsync(result, params)
.catch((e) => {
error.addIssue(makeReturnsIssue(result, e));
@@ -11056,13 +11096,17 @@ class ZodFunction extends ZodType {
});
}
else {
return OK((...args) => {
const parsedArgs = this._def.args.safeParse(args, params);
// Would love a way to avoid disabling this rule, but we need
// an alias (using an arrow function was what caused 2651).
// eslint-disable-next-line @typescript-eslint/no-this-alias
const me = this;
return OK(function (...args) {
const parsedArgs = me._def.args.safeParse(args, params);
if (!parsedArgs.success) {
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
}
const result = fn(...parsedArgs.data);
const parsedReturns = this._def.returns.safeParse(result, params);
const result = Reflect.apply(fn, this, parsedArgs.data);
const parsedReturns = me._def.returns.safeParse(result, params);
if (!parsedReturns.success) {
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
}
@@ -11150,7 +11194,7 @@ ZodLiteral.create = (value, params) => {
};
function createZodEnum(values, params) {
return new ZodEnum({
values: values,
values,
typeName: ZodFirstPartyTypeKind.ZodEnum,
...processCreateParams(params),
});
@@ -11292,8 +11336,29 @@ class ZodEffects extends ZodType {
_parse(input) {
const { status, ctx } = this._processInputParams(input);
const effect = this._def.effect || null;
const checkCtx = {
addIssue: (arg) => {
addIssueToContext(ctx, arg);
if (arg.fatal) {
status.abort();
}
else {
status.dirty();
}
},
get path() {
return ctx.path;
},
};
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
if (effect.type === "preprocess") {
const processed = effect.transform(ctx.data);
const processed = effect.transform(ctx.data, checkCtx);
if (ctx.common.issues.length) {
return {
status: "dirty",
value: ctx.data,
};
}
if (ctx.common.async) {
return Promise.resolve(processed).then((processed) => {
return this._def.schema._parseAsync({
@@ -11311,21 +11376,6 @@ class ZodEffects extends ZodType {
});
}
}
const checkCtx = {
addIssue: (arg) => {
addIssueToContext(ctx, arg);
if (arg.fatal) {
status.abort();
}
else {
status.dirty();
}
},
get path() {
return ctx.path;
},
};
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
if (effect.type === "refinement") {
const executeRefinement = (acc
// effect: RefinementEffect<any>
@@ -11629,8 +11679,24 @@ class ZodPipeline extends ZodType {
});
}
}
class ZodReadonly extends ZodType {
_parse(input) {
const result = this._def.innerType._parse(input);
if (isValid(result)) {
result.value = Object.freeze(result.value);
}
return result;
}
}
ZodReadonly.create = (type, params) => {
return new ZodReadonly({
innerType: type,
typeName: ZodFirstPartyTypeKind.ZodReadonly,
...processCreateParams(params),
});
};
const custom = (check, params = {},
/*
/**
* @deprecated
*
* Pass `fatal` into the params object instead:
@@ -11697,6 +11763,7 @@ var ZodFirstPartyTypeKind;
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
const instanceOfType = (
// const instanceOfType = <T extends new (...args: any[]) => any>(
@@ -11810,6 +11877,7 @@ var z = /*#__PURE__*/Object.freeze({
BRAND: BRAND,
ZodBranded: ZodBranded,
ZodPipeline: ZodPipeline,
ZodReadonly: ZodReadonly,
custom: custom,
Schema: ZodType,
ZodSchema: ZodType,
@@ -13594,8 +13662,8 @@ class AbortError extends FetchBaseError {
}
}
// EXTERNAL MODULE: ./node_modules/fetch-blob/from.js + 2 modules
var from = __nccwpck_require__(2777);
// EXTERNAL MODULE: ./node_modules/fetch-blob/from.js
var from = __nccwpck_require__(2185);
;// CONCATENATED MODULE: ./node_modules/node-fetch/src/index.js
/**
* Index.js
@@ -14010,29 +14078,49 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
// EXTERNAL MODULE: ./node_modules/@lifeomic/attempt/dist/src/index.js
var src = __nccwpck_require__(6494);
// EXTERNAL MODULE: external "node:fs"
var external_node_fs_ = __nccwpck_require__(7561);
// EXTERNAL MODULE: external "node:path"
var external_node_path_ = __nccwpck_require__(9411);
;// CONCATENATED MODULE: ./src/main.ts
const InputVariablesSchema = z.object({
speckleAutomateUrl: z.string().url().nonempty(),
speckleToken: z.string().nonempty(),
speckleFunctionId: z.string().nonempty(),
speckleFunctionInputSchema: z.record(z.string().nonempty(), z.unknown()).nullable(),
speckleFunctionCommand: z.string().nonempty().array()
speckleAutomateUrl: z.string().url().min(1),
speckleToken: z.string().min(1),
speckleFunctionId: z.string().min(1),
speckleFunctionInputSchema: z.record(z.string().min(1), z.unknown()).nullable(),
speckleFunctionCommand: z.array(z.string().min(1)),
speckleFunctionReleaseTag: 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.'),
speckleFunctionRecommendedCPUm: z.number()
.int()
.finite()
.gte(100)
.lte(16000)
.optional(),
speckleFunctionRecommendedMemoryMi: z.number()
.int()
.finite()
.gte(1)
.lte(8000)
.optional()
});
const parseInputs = () => {
const speckleTokenRaw = core.getInput('speckle_token', { required: true });
core.setSecret(speckleTokenRaw);
const rawInputSchemaPath = core.getInput('speckle_function_input_schema_file_path');
const homeDir = process.env['HOME'];
if (!homeDir)
throw new Error('The home directory is not defined, cannot load inputSchema');
let speckleFunctionInputSchema = null;
try {
const rawInputSchema = core.getInput('speckle_function_input_schema');
if (rawInputSchema)
speckleFunctionInputSchema = JSON.parse(rawInputSchema);
}
catch (err) {
core.setFailed(`Parsing the function input schema failed with: ${err}`);
if (rawInputSchemaPath) {
const rawInputSchema = (0,external_node_fs_.readFileSync)((0,external_node_path_.join)(homeDir, rawInputSchemaPath), 'utf-8');
speckleFunctionInputSchema = JSON.parse(rawInputSchema);
}
const rawInputs = {
speckleAutomateUrl: core.getInput('speckle_automate_url', { required: true }),
@@ -14040,40 +14128,45 @@ const parseInputs = () => {
speckleFunctionId: core.getInput('speckle_function_id', { required: true }),
speckleFunctionInputSchema,
speckleFunctionCommand: core.getInput('speckle_function_command', { required: true })
.split(' ')
.split(' '),
speckleFunctionReleaseTag: core.getInput('speckle_function_release_tag', {
required: true
}),
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;
core.setFailed(`The provided inputs do not match the required schema, ${inputParseResult.error.message}`);
throw inputParseResult.error;
};
const RequiredEnvVarsSchema = z.object({
gitRefName: z.string().nonempty(),
gitRefType: z.string().nonempty(),
gitCommitSha: z.string().nonempty()
});
const parseEnvVars = () => {
const parseResult = RequiredEnvVarsSchema.safeParse({
gitCommitSha: process.env.GITHUB_SHA,
gitRefType: process.env.GITHUB_REF_TYPE,
gitRefName: process.env.GITHUB_REF_NAME
gitCommitSha: process.env.GITHUB_SHA
});
if (parseResult.success)
return parseResult.data;
core.setFailed(`The current execution environment does not have the required variables: ${parseResult.error.message}`);
throw parseResult.error;
};
const FunctionVersionResponseBodySchema = z.object({
versionId: z.string().nonempty()
});
const registerNewVersionForTheSpeckleAutomateFunction = async ({ speckleAutomateUrl, speckleFunctionCommand, speckleFunctionId, speckleFunctionInputSchema, speckleToken }, { gitCommitSha, gitRefName, gitRefType }) => {
const registerNewVersionForTheSpeckleAutomateFunction = async ({ speckleAutomateUrl, speckleFunctionCommand, speckleFunctionId, speckleFunctionInputSchema, speckleToken, speckleFunctionReleaseTag, speckleFunctionRecommendedCPUm, speckleFunctionRecommendedMemoryMi }, commitId
// { gitCommitSha, gitRefName, gitRefType }: RequiredEnvVars
) => {
try {
const requestBody = {
commitId: gitCommitSha,
versionTag: gitRefType === 'tag' ? gitRefName : gitCommitSha,
commitId,
versionTag: speckleFunctionReleaseTag,
command: speckleFunctionCommand,
inputSchema: speckleFunctionInputSchema
inputSchema: speckleFunctionInputSchema,
recommendedCPUm: speckleFunctionRecommendedCPUm,
recommendedMemoryMi: speckleFunctionRecommendedMemoryMi
};
const versionRegisterUrl = new URL(`/api/v1/functions/${speckleFunctionId}/versions`, speckleAutomateUrl);
const retryFlag = 'RETRY THIS';
@@ -14107,25 +14200,59 @@ const registerNewVersionForTheSpeckleAutomateFunction = async ({ speckleAutomate
}
}
});
return FunctionVersionResponseBodySchema.parse(response);
const parsedResult = FunctionVersionResponseBodySchema.safeParse(response);
if (parsedResult.success)
return parsedResult.data;
throw parsedResult.error;
}
catch (err) {
core.setFailed(`Failed to register new function version to the automate server: ${err}`);
throw err;
throw Error('Failed to register new function version to the automate server', {
cause: err
});
}
};
const failAndReject = async (e, errorMessageForUnknownObjectType) => {
if (e instanceof ZodError || e instanceof Error) {
core.setFailed(e.message);
return Promise.reject(e.message);
}
core.setFailed(errorMessageForUnknownObjectType);
return Promise.reject(e);
};
async function run() {
core.info('Start registering a new version on the automate instance');
const inputVariables = parseInputs();
let inputVariables = {};
try {
inputVariables = parseInputs();
}
catch (e) {
return failAndReject(e, 'Failed to parse the input variables');
}
core.info(`Parsed input variables to: ${JSON.stringify(inputVariables)}`);
const requiredEnvVars = parseEnvVars();
let requiredEnvVars = {};
try {
requiredEnvVars = parseEnvVars();
}
catch (e) {
return failAndReject(e, 'Failed to parse the required environment variables');
}
const { gitCommitSha } = requiredEnvVars;
core.info(`Parsed required environment variables to: ${JSON.stringify(requiredEnvVars)}`);
const { speckleAutomateUrl, speckleFunctionId } = inputVariables;
core.setOutput('speckle_automate_host', new URL(speckleAutomateUrl).host);
core.info(`Sending a new function version definition for function ${speckleFunctionId} to the automate server: ${speckleAutomateUrl}`);
const { versionId } = await registerNewVersionForTheSpeckleAutomateFunction(inputVariables, requiredEnvVars);
core.setOutput('version_id', versionId);
core.info(`Registered function version with new id: ${versionId}`);
// github uses 7 chars to identify commits
const commitId = gitCommitSha.substring(0, 7);
let versionId = '';
try {
const registrationResponse = await registerNewVersionForTheSpeckleAutomateFunction(inputVariables, commitId);
versionId = registrationResponse.versionId;
}
catch (e) {
return failAndReject(e, 'Failed to register the new function version');
}
core.info(`Registered function version tagged as ${inputVariables.speckleFunctionReleaseTag} with new id: ${versionId}. Recommended CPU: ${inputVariables.speckleFunctionRecommendedCPUm}m, recommended memory: ${inputVariables.speckleFunctionRecommendedMemoryMi}Mi.`);
core.setOutput('speckle_automate_function_release_id', versionId);
}
run();
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+18 -17
View File
@@ -16,38 +16,39 @@
"precommit": "pre-commit run --all-files",
"prettier:check": "prettier --check '**/*.ts'",
"prettier:fix": "prettier --write '**/*.ts'",
"test": "vitest --run --coverage",
"test": "vitest --run --coverage",
"test:watch": "vitest"
},
"engines": {
"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.21.4"
"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",
"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"
}
}
+112 -40
View File
@@ -1,14 +1,36 @@
import * as core from '@actions/core'
import { z } from 'zod'
import { ZodError, z } from 'zod'
import fetch from 'node-fetch'
import { retry } from '@lifeomic/attempt'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
const InputVariablesSchema = z.object({
speckleAutomateUrl: z.string().url().nonempty(),
speckleToken: z.string().nonempty(),
speckleFunctionId: z.string().nonempty(),
speckleFunctionInputSchema: z.record(z.string().nonempty(), z.unknown()).nullable(),
speckleFunctionCommand: z.string().nonempty().array()
speckleAutomateUrl: z.string().url().min(1),
speckleToken: z.string().min(1),
speckleFunctionId: z.string().min(1),
speckleFunctionInputSchema: z.record(z.string().min(1), z.unknown()).nullable(),
speckleFunctionCommand: z.array(z.string().min(1)),
speckleFunctionReleaseTag: 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.'
),
speckleFunctionRecommendedCPUm: z
.number()
.int()
.finite()
.gte(100)
.lte(16000)
.optional(),
speckleFunctionRecommendedMemoryMi: z
.number()
.int()
.finite()
.gte(1)
.lte(8000)
.optional()
})
type InputVariables = z.infer<typeof InputVariablesSchema>
@@ -17,13 +39,16 @@ const parseInputs = (): InputVariables => {
const speckleTokenRaw = core.getInput('speckle_token', { required: true })
core.setSecret(speckleTokenRaw)
const rawInputSchemaPath = core.getInput('speckle_function_input_schema_file_path')
const homeDir = process.env['HOME']
if (!homeDir)
throw new Error('The home directory is not defined, cannot load inputSchema')
let speckleFunctionInputSchema: Record<string, unknown> | null = null
try {
const rawInputSchema = core.getInput('speckle_function_input_schema')
if (rawInputSchema) speckleFunctionInputSchema = JSON.parse(rawInputSchema)
} catch (err) {
core.setFailed(`Parsing the function input schema failed with: ${err}`)
if (rawInputSchemaPath) {
const rawInputSchema = readFileSync(join(homeDir, rawInputSchemaPath), 'utf-8')
speckleFunctionInputSchema = JSON.parse(rawInputSchema)
}
const rawInputs: InputVariables = {
speckleAutomateUrl: core.getInput('speckle_automate_url', { required: true }),
speckleToken: speckleTokenRaw,
@@ -31,19 +56,27 @@ const parseInputs = (): InputVariables => {
speckleFunctionInputSchema,
speckleFunctionCommand: core
.getInput('speckle_function_command', { required: true })
.split(' ')
.split(' '),
speckleFunctionReleaseTag: core.getInput('speckle_function_release_tag', {
required: true
}),
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
core.setFailed(
`The provided inputs do not match the required schema, ${inputParseResult.error.message}`
)
throw inputParseResult.error
}
const RequiredEnvVarsSchema = z.object({
gitRefName: z.string().nonempty(),
gitRefType: z.string().nonempty(),
gitCommitSha: z.string().nonempty()
})
@@ -51,14 +84,9 @@ type RequiredEnvVars = z.infer<typeof RequiredEnvVarsSchema>
const parseEnvVars = (): RequiredEnvVars => {
const parseResult = RequiredEnvVarsSchema.safeParse({
gitCommitSha: process.env.GITHUB_SHA,
gitRefType: process.env.GITHUB_REF_TYPE,
gitRefName: process.env.GITHUB_REF_NAME
gitCommitSha: process.env.GITHUB_SHA
} as RequiredEnvVars)
if (parseResult.success) return parseResult.data
core.setFailed(
`The current execution environment does not have the required variables: ${parseResult.error.message}`
)
throw parseResult.error
}
@@ -67,6 +95,8 @@ type FunctionVersionRequestBody = {
versionTag: string
command: string[]
inputSchema: Record<string, unknown> | null
recommendedCPUm?: number
recommendedMemoryMi?: number
}
const FunctionVersionResponseBodySchema = z.object({
@@ -81,16 +111,22 @@ const registerNewVersionForTheSpeckleAutomateFunction = async (
speckleFunctionCommand,
speckleFunctionId,
speckleFunctionInputSchema,
speckleToken
speckleToken,
speckleFunctionReleaseTag,
speckleFunctionRecommendedCPUm,
speckleFunctionRecommendedMemoryMi
}: InputVariables,
{ gitCommitSha, gitRefName, gitRefType }: RequiredEnvVars
commitId: string
// { gitCommitSha, gitRefName, gitRefType }: RequiredEnvVars
): Promise<FunctionVersionResponseBody> => {
try {
const requestBody: FunctionVersionRequestBody = {
commitId: gitCommitSha,
versionTag: gitRefType === 'tag' ? gitRefName : gitCommitSha,
commitId,
versionTag: speckleFunctionReleaseTag,
command: speckleFunctionCommand,
inputSchema: speckleFunctionInputSchema
inputSchema: speckleFunctionInputSchema,
recommendedCPUm: speckleFunctionRecommendedCPUm,
recommendedMemoryMi: speckleFunctionRecommendedMemoryMi
}
const versionRegisterUrl = new URL(
`/api/v1/functions/${speckleFunctionId}/versions`,
@@ -133,20 +169,45 @@ const registerNewVersionForTheSpeckleAutomateFunction = async (
}
}
)
return FunctionVersionResponseBodySchema.parse(response)
const parsedResult = FunctionVersionResponseBodySchema.safeParse(response)
if (parsedResult.success) return parsedResult.data
throw parsedResult.error
} catch (err) {
core.setFailed(
`Failed to register new function version to the automate server: ${err}`
)
throw err
throw Error('Failed to register new function version to the automate server', {
cause: err
})
}
}
const failAndReject = async (
e: unknown,
errorMessageForUnknownObjectType: string
): Promise<never> => {
if (e instanceof ZodError || e instanceof Error) {
core.setFailed(e.message)
return Promise.reject(e.message)
}
core.setFailed(errorMessageForUnknownObjectType)
return Promise.reject(e)
}
export async function run(): Promise<void> {
core.info('Start registering a new version on the automate instance')
const inputVariables = parseInputs()
let inputVariables: InputVariables = {} as InputVariables
try {
inputVariables = parseInputs()
} catch (e: unknown) {
return failAndReject(e, 'Failed to parse the input variables')
}
core.info(`Parsed input variables to: ${JSON.stringify(inputVariables)}`)
const requiredEnvVars = parseEnvVars()
let requiredEnvVars: RequiredEnvVars = {} as RequiredEnvVars
try {
requiredEnvVars = parseEnvVars()
} catch (e: unknown) {
return failAndReject(e, 'Failed to parse the required environment variables')
}
const { gitCommitSha } = requiredEnvVars
core.info(
`Parsed required environment variables to: ${JSON.stringify(requiredEnvVars)}`
)
@@ -157,12 +218,23 @@ export async function run(): Promise<void> {
`Sending a new function version definition for function ${speckleFunctionId} to the automate server: ${speckleAutomateUrl}`
)
const { versionId } = await registerNewVersionForTheSpeckleAutomateFunction(
inputVariables,
requiredEnvVars
// github uses 7 chars to identify commits
const commitId = gitCommitSha.substring(0, 7)
let versionId = ''
try {
const registrationResponse = await registerNewVersionForTheSpeckleAutomateFunction(
inputVariables,
commitId
)
versionId = registrationResponse.versionId
} catch (e: unknown) {
return failAndReject(e, 'Failed to register the new function version')
}
core.info(
`Registered function version tagged as ${inputVariables.speckleFunctionReleaseTag} with new id: ${versionId}. Recommended CPU: ${inputVariables.speckleFunctionRecommendedCPUm}m, recommended memory: ${inputVariables.speckleFunctionRecommendedMemoryMi}Mi.`
)
core.setOutput('version_id', versionId)
core.info(`Registered function version with new id: ${versionId}`)
core.setOutput('speckle_automate_function_release_id', versionId)
}
run()
+207 -6
View File
@@ -1,16 +1,217 @@
import { run } from '../src/main.js'
import { describe, it, vi } from 'vitest'
import {
describe,
it,
vi,
afterEach,
beforeEach,
expect,
beforeAll,
afterAll
} from 'vitest'
import { mkdtempSync, writeFileSync, rmdirSync, rmSync } from 'node:fs'
import { join } from 'node:path'
import { tmpdir } from 'node:os'
import { setupServer } from 'msw/node'
import { http, HttpResponse } from 'msw'
import { z } from 'zod'
describe('Register new version', () => {
it('send the request', async () => {
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', '{fake}')
let tmpDir: string
let countHappyPath = 0
let count500Errors = 0
const server = setupServer(
http.post(
'http://myfakeautomate.speckle.internal/api/v1/functions/fake_function_id/versions',
async ({ request }) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
expect(parseResult.success).to.be.true
countHappyPath++
return new HttpResponse(JSON.stringify({ versionId: 'fake_version_id' }), {
status: 201,
headers: {
'Content-Type': 'application/json'
}
})
}
),
http.post(
'http://myfakeautomate.speckle.internal/api/v1/functions/network_error/versions',
async ({ request }) => {
const parseResult = FunctionVersionRequestSchema.safeParse(await request.json())
expect(parseResult.success).to.be.true
return HttpResponse.error() // simulates a network error
}
),
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
})
}
)
)
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
afterAll(() => server.close())
beforeEach(() => {
tmpDir = mkdtempSync(join(tmpdir(), 'speckle-automate-github-action-test-'))
})
afterEach(() => {
rmSync(tmpDir, { recursive: true })
vi.unstubAllEnvs()
server.resetHandlers()
})
it('sends the request', async () => {
writeFileSync(join(tmpDir, 'schema.json'), '{}')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', 'fake_function_id')
vi.stubEnv('INPUT_SPECKLE_TOKEN', '{token}')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_COMMAND', 'echo "hello automate"')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_INPUT_SCHEMA', '{}')
vi.stubEnv('INPUT_SPECKLE_AUTOMATE_URL', 'http://automate.speckle.internal:3030')
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_FUNCTION_RECOMMENDED_CPU_M', '1000')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_RECOMMENDED_MEMORY_MI', '500')
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 run()
await expect(run()).resolves.not.toThrow()
expect(countHappyPath).to.equal(1)
countHappyPath = 0
})
it('handles network errors', async () => {
writeFileSync(join(tmpDir, 'schema.json'), '{}')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', 'network_error')
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'
)
})
it('handles 500 responses', async () => {
writeFileSync(join(tmpDir, 'schema.json'), '{}')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', '500_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(count500Errors).to.toBeGreaterThan(1) // we expect the action to retry the request
count500Errors = 0
})
it('errors if the token is empty', async () => {
writeFileSync(join(tmpDir, 'schema.json'), '{}')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', 'fake_function_id')
vi.stubEnv('INPUT_SPECKLE_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(
'Input required and not supplied: speckle_token'
)
})
it('errors if the environment variable is empty', async () => {
writeFileSync(join(tmpDir, 'schema.json'), '{}')
vi.stubEnv('INPUT_SPECKLE_FUNCTION_ID', 'fake_function_id')
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', '')
vi.stubEnv('GITHUB_REF_TYPE', 'commit')
vi.stubEnv('GITHUB_REF_NAME', 'version')
await expect(run()).rejects.toThrow('gitCommitSha')
})
})
//This must be updated to align with the schema in speckle automate
const FunctionVersionRequestSchema = z.object({
commitId: z
.string()
.trim()
.min(6)
.transform((arg: string) => arg.substring(0, 10)),
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({
'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)
})
+4 -4
View File
@@ -20,10 +20,10 @@ export default defineConfig({
'**/*.mjs',
'**/*.js'
],
lines: 95,
functions: 95,
branches: 95,
statements: 95,
lines: 90,
functions: 90,
branches: 70,
statements: 90,
resolve: {
alias: {
'@': path.resolve(__dirname, './src/')
+1743 -377
View File
File diff suppressed because it is too large Load Diff