From b35ea928b75c21642369199848cde0f5ec67a71a Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Sat, 4 Jan 2025 19:34:58 -0700 Subject: [PATCH 1/6] use npm exec --offline for tsc and cuzz to attempt a solution that will work locally and from azle installed from npm --- package-lock.json | 4 +--- package.json | 4 +--- test/fuzz.ts | 6 +++++- test/index.ts | 10 ++-------- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4a5e4c966e..e4768c3348 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,9 +41,7 @@ "wasmedge_quickjs": "github:demergent-labs/wasmedge-quickjs#3b3b0ee91248ccf9cd954ffafbac7e024648af92" }, "bin": { - "azle": "src/build/index.ts", - "cuzz": "node_modules/.bin/cuzz", - "tsc": "node_modules/.bin/tsc" + "azle": "src/build/index.ts" }, "devDependencies": { "@dfinity/identity": "^2.2.0", diff --git a/package.json b/package.json index d4d79f2c4f..a22929d5e7 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,7 @@ }, "type": "module", "bin": { - "azle": "./src/build/index.ts", - "cuzz": "./node_modules/.bin/cuzz", - "tsc": "./node_modules/.bin/tsc" + "azle": "./src/build/index.ts" }, "main": "./src/lib/stable/index.ts", "repository": { diff --git a/test/fuzz.ts b/test/fuzz.ts index afe645c263..5b87b4e0b5 100644 --- a/test/fuzz.ts +++ b/test/fuzz.ts @@ -53,6 +53,10 @@ function getCallDelay(cuzzConfig: CuzzConfig): string { function fuzzTestCanister(canisterName: string, callDelay: string): void { const baseCuzzArgs = [ + 'exec', + '--offline', + 'cuzz', + '--', '--canister-name', canisterName, '--skip-deploy', @@ -69,7 +73,7 @@ function fuzzTestCanister(canisterName: string, callDelay: string): void { : []) ]; - let cuzzProcess = spawn('node_modules/.bin/cuzz', cuzzArgs, { + let cuzzProcess = spawn('npm', cuzzArgs, { stdio: 'inherit' }); diff --git a/test/index.ts b/test/index.ts index 61bcb8ec09..6c9becce25 100644 --- a/test/index.ts +++ b/test/index.ts @@ -3,7 +3,6 @@ dns.setDefaultResultOrder('ipv4first'); import { describe, expect, test } from '@jest/globals'; import * as fc from 'fast-check'; -import { join } from 'path'; import { execSyncPretty } from '../src/build/stable/utils/exec_sync_pretty'; export { expect } from '@jest/globals'; @@ -17,7 +16,7 @@ export { getCanisterActor } from './get_canister_actor'; export function runTests( tests: Test, canisterNames: string | string[] | undefined = undefined, - cwd: string = process.cwd() + _cwd: string = process.cwd() ): void { const { shouldRunTests, @@ -35,12 +34,7 @@ export function runTests( it('checks types', () => { try { execSyncPretty( - `${join( - cwd, - 'node_modules', - '.bin', - 'tsc' - )} --noEmit --skipLibCheck --target es2020 --strict --moduleResolution node --allowJs`, + `npm exec --offline tsc -- --noEmit --skipLibCheck --target es2020 --strict --moduleResolution node --allowJs`, 'inherit' ); } catch { From e50bdbd9d76aeaf19a4c30c9b132e1cc9c2a5291 Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Sat, 4 Jan 2025 20:52:10 -0700 Subject: [PATCH 2/6] remove exclusions from release process, add modules.d.ts --- .github/workflows/release.yml | 40 +++-------------------------------- modules.d.ts | 1 + src/lib/stable/globals.ts | 1 - 3 files changed, 4 insertions(+), 38 deletions(-) create mode 100644 modules.d.ts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53e007d376..b53d5eb835 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,42 +4,12 @@ on: inputs: release-version: required: true - exclude-slow-tests: - description: 'Exclude slow tests' - required: true - type: boolean - default: false - exclude-unstable-tests: - description: 'Exclude unstable tests' - required: true - type: boolean - default: false - exclude-release-only-tests: - description: 'Exclude release tests' - required: true - type: boolean - default: false signing-key-id: required: true type: string default: C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 jobs: - get-exclude-dirs: - name: Get exclude directories - runs-on: ubuntu-latest - outputs: - exclude-dirs: ${{ steps.get-exclude-dirs.outputs.exclude-dirs }} - steps: - - uses: actions/checkout@v4 - - - id: get-exclude-dirs - uses: ./.github/actions/get_exclude_dirs - with: - exclude-slow: ${{ github.event.inputs.exclude-slow-tests }} - exclude-unstable: ${{ github.event.inputs.exclude-unstable-tests }} - exclude-release-only: ${{ github.event.inputs.exclude-release-only-tests }} - create-branch-prefix: uses: ./.github/workflows/create_branch_prefix.yml with: @@ -52,7 +22,6 @@ jobs: prepare-release: name: Prepare Release needs: - - get-exclude-dirs - create-branch-prefix runs-on: ubuntu-latest env: @@ -111,9 +80,7 @@ jobs: - id: get-test-infos uses: ./.github/actions/get_test_infos with: - directories: | - ./examples - exclude-dirs: ${{ needs.get-exclude-dirs.outputs.exclude-dirs }} + directories: ./examples update-test-files-for-release-commit: needs: @@ -152,10 +119,9 @@ jobs: working-directory: ${{ matrix.test.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - - name: Run npm test (continue on error) + - name: Run dfx deploy working-directory: ${{ matrix.test.path }} - continue-on-error: true - run: npm test + run: dfx deploy - name: Create branch name id: create-branch-name diff --git a/modules.d.ts b/modules.d.ts new file mode 100644 index 0000000000..630247d5f2 --- /dev/null +++ b/modules.d.ts @@ -0,0 +1 @@ +declare module '@sinonjs/text-encoding'; diff --git a/src/lib/stable/globals.ts b/src/lib/stable/globals.ts index 2b64ea7173..98f7774186 100644 --- a/src/lib/stable/globals.ts +++ b/src/lib/stable/globals.ts @@ -1,4 +1,3 @@ -// @ts-expect-error import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding'; import { AzleIcExperimental } from '../experimental/ic/azle_ic_experimental'; From b7e712c1885dde953e92033a29bbcbbdd871455d Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Sat, 4 Jan 2025 21:07:25 -0700 Subject: [PATCH 3/6] change from dfx deploy to npm run pretest --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b53d5eb835..bfa3280bd7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,9 +119,9 @@ jobs: working-directory: ${{ matrix.test.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - - name: Run dfx deploy + - name: npm run pretest working-directory: ${{ matrix.test.path }} - run: dfx deploy + run: npm run pretest - name: Create branch name id: create-branch-name From 7159083c66d95349f1184baeb8f14b65eb4680a6 Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Sat, 4 Jan 2025 21:21:24 -0700 Subject: [PATCH 4/6] get rid of the npm test, pretest, process that is trying to generate the candid files, we should do it well in the future --- .github/workflows/release.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfa3280bd7..be1dc716c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -119,9 +119,10 @@ jobs: working-directory: ${{ matrix.test.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - - name: npm run pretest - working-directory: ${{ matrix.test.path }} - run: npm run pretest + # TODO we would like to also update the Candid files + # TODO what we should do is detect if there is a Candid file to generate + # TODO probably by looking at the dfx.json candid property of any azle canisters + # TODO if that is defined and if it does not go to .azle, we should probably generate it - name: Create branch name id: create-branch-name From 3c2637ce32b940b7a5e4f78fd122b3e2e14dc0ce Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Sat, 4 Jan 2025 21:52:29 -0700 Subject: [PATCH 5/6] forgot to add modules.d.ts to the .npmignore --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index e868b38916..ab0775f92f 100644 --- a/.npmignore +++ b/.npmignore @@ -25,6 +25,7 @@ !install_script.sh !LICENSE !LICENSE_EXTENSION.md +!modules.d.ts !NOTICE !package-lock.json !package.json From bf2d50a937a40a8c0c43fb666afcda058a2a0672 Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Sat, 4 Jan 2025 22:14:01 -0700 Subject: [PATCH 6/6] use ts-ignore --- .npmignore | 1 - modules.d.ts | 1 - src/lib/experimental/globals.ts | 2 +- src/lib/stable/globals.ts | 1 + src/lib/stable/ic_apis/reject_code.ts | 2 +- src/lib/stable/stable_structures/stable_json.ts | 2 +- 6 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 modules.d.ts diff --git a/.npmignore b/.npmignore index ab0775f92f..e868b38916 100644 --- a/.npmignore +++ b/.npmignore @@ -25,7 +25,6 @@ !install_script.sh !LICENSE !LICENSE_EXTENSION.md -!modules.d.ts !NOTICE !package-lock.json !package.json diff --git a/modules.d.ts b/modules.d.ts deleted file mode 100644 index 630247d5f2..0000000000 --- a/modules.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module '@sinonjs/text-encoding'; diff --git a/src/lib/experimental/globals.ts b/src/lib/experimental/globals.ts index e493d1ed96..2eb5ccf416 100644 --- a/src/lib/experimental/globals.ts +++ b/src/lib/experimental/globals.ts @@ -1,7 +1,7 @@ import './experimental'; import '../stable/globals'; // We import this to remove type errors having to do with the stable and experimental globals -// @ts-expect-error +// @ts-ignore import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding'; import { Buffer } from 'buffer'; import * as process from 'process'; diff --git a/src/lib/stable/globals.ts b/src/lib/stable/globals.ts index 98f7774186..9145dfd5d1 100644 --- a/src/lib/stable/globals.ts +++ b/src/lib/stable/globals.ts @@ -1,3 +1,4 @@ +// @ts-ignore import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding'; import { AzleIcExperimental } from '../experimental/ic/azle_ic_experimental'; diff --git a/src/lib/stable/ic_apis/reject_code.ts b/src/lib/stable/ic_apis/reject_code.ts index 2704abddde..179f13d990 100644 --- a/src/lib/stable/ic_apis/reject_code.ts +++ b/src/lib/stable/ic_apis/reject_code.ts @@ -1,5 +1,5 @@ // TODO this should be removed once https://github.com/demergent-labs/azle/issues/2271 is resolved -// @ts-expect-error +// @ts-ignore import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding'; globalThis.TextDecoder = TextDecoder; globalThis.TextEncoder = TextEncoder; diff --git a/src/lib/stable/stable_structures/stable_json.ts b/src/lib/stable/stable_structures/stable_json.ts index 52974a09e2..defea82b21 100644 --- a/src/lib/stable/stable_structures/stable_json.ts +++ b/src/lib/stable/stable_structures/stable_json.ts @@ -1,5 +1,5 @@ import { Principal } from '@dfinity/principal'; -// @ts-expect-error +// @ts-ignore import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding'; import { Serializable } from './stable_b_tree_map';