diff --git a/.github/actions/get_test_infos/discover_test_dirs.ts b/.github/actions/get_test_infos/discover_test_dirs.ts index 4f9f68c23a..f4d2bcc6a0 100644 --- a/.github/actions/get_test_infos/discover_test_dirs.ts +++ b/.github/actions/get_test_infos/discover_test_dirs.ts @@ -3,6 +3,16 @@ import { join } from 'path'; // Recursively find directories and check for package.json with a test script export async function discoverTestDirs(dirToSearch: string): Promise { + // Check if the initial directory is a test directory + const initialDirPackageJson = join(dirToSearch, 'package.json'); + const hasInitialTestScript = await checkForTestScript( + initialDirPackageJson + ); + + if (hasInitialTestScript) { + return [dirToSearch]; + } + const files = await readdir(dirToSearch, { withFileTypes: true }); return files.reduce( diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index 57dc01fe90..ceb7adf0eb 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -108,7 +108,7 @@ jobs: - run: npm run lint - - run: npm install + - run: npm install --verbose working-directory: ${{ matrix.test.path }} - run: npm link azle diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 483b532e80..450c14a14f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,57 +91,9 @@ jobs: fail-fast: false matrix: test_group: - - { - name: 'Stable Demo', - directories: './examples/stable/demo' - } - - { - name: 'Stable Demo (Experimental)', - directories: './examples/stable/demo', - run-experimental: true - } - { name: 'Experimental Demo', - directories: './examples/experimental/demo' - } - - { - name: 'Stable E2E CRPC', - directories: './examples/stable/test/end_to_end/candid_rpc' - } - - { - name: 'Stable E2E CRPC (Experimental)', - directories: './examples/stable/test/end_to_end/candid_rpc', - run-experimental: true - } - - { - name: 'Experimental E2E CRPC', - directories: './examples/experimental/test/end_to_end/candid_rpc' - } - - { - name: 'Experimental E2E HTTP Server', - directories: './examples/experimental/test/end_to_end/http_server' - } - - { - name: 'Stable Property CRPC', - directories: './examples/stable/test/property/candid_rpc' - } - - { - name: 'Stable Property CRPC (Experimental)', - directories: './examples/stable/test/property/candid_rpc', - run-experimental: true - } - - { - name: 'Experimental Property CRPC', - directories: './examples/experimental/test/property/candid_rpc' - } - - { - name: 'Stable Property IC API', - directories: './examples/stable/test/property/ic_api' - } - - { - name: 'Stable Property IC API (Experimental)', - directories: './examples/stable/test/property/ic_api', - run-experimental: true + directories: './examples/experimental/demo/bitcoin_psbt' } uses: ./.github/workflows/run_test.yml with: diff --git a/examples/experimental/demo/basic_bitcoin/package-lock.json b/examples/experimental/demo/basic_bitcoin/package-lock.json index 22115b3f9b..36842fdbe1 100644 --- a/examples/experimental/demo/basic_bitcoin/package-lock.json +++ b/examples/experimental/demo/basic_bitcoin/package-lock.json @@ -1,10 +1,12 @@ { "name": "basic_bitcoin", + "version": "0.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "basic_bitcoin", + "version": "0.0.0", "hasInstallScript": true, "dependencies": { "azle": "0.24.1", diff --git a/examples/experimental/demo/basic_bitcoin/package.json b/examples/experimental/demo/basic_bitcoin/package.json index 78ccd67ed0..be6aca71e5 100644 --- a/examples/experimental/demo/basic_bitcoin/package.json +++ b/examples/experimental/demo/basic_bitcoin/package.json @@ -1,5 +1,6 @@ { "name": "basic_bitcoin", + "version": "0.0.0", "scripts": { "install": "./scripts/install.sh", "pretest": "tsx test/pretest.ts", diff --git a/examples/experimental/demo/bitcoin_psbt/.gitignore b/examples/experimental/demo/bitcoin_psbt/.gitignore index d85448bfd1..96d235f8c8 100644 --- a/examples/experimental/demo/bitcoin_psbt/.gitignore +++ b/examples/experimental/demo/bitcoin_psbt/.gitignore @@ -1,5 +1,6 @@ .azle .bitcoin .dfx +basic_bitcoin-0.0.0.tgz dfx_generated node_modules diff --git a/examples/experimental/demo/bitcoin_psbt/jest.config.js b/examples/experimental/demo/bitcoin_psbt/jest.config.js index 43cb5d4f5d..7c3bb47267 100644 --- a/examples/experimental/demo/bitcoin_psbt/jest.config.js +++ b/examples/experimental/demo/bitcoin_psbt/jest.config.js @@ -7,5 +7,5 @@ module.exports = { '^.+\\.ts$': ['ts-jest', { isolatedModules: true }], '^.+\\.js$': 'ts-jest' }, - transformIgnorePatterns: ['/node_modules/(?!(azle)/)'] // Make sure azle is transformed + transformIgnorePatterns: ['/node_modules/(?!(azle|basic_bitcoin)/)'] // Make sure azle is transformed }; diff --git a/examples/experimental/demo/bitcoin_psbt/package-lock.json b/examples/experimental/demo/bitcoin_psbt/package-lock.json index ec801c4b0c..e5c62ce517 100644 --- a/examples/experimental/demo/bitcoin_psbt/package-lock.json +++ b/examples/experimental/demo/bitcoin_psbt/package-lock.json @@ -8,7 +8,7 @@ "dependencies": { "@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3", "azle": "0.24.1", - "basic_bitcoin": "file:../basic_bitcoin", + "basic_bitcoin": "file:basic_bitcoin-0.0.0.tgz", "bitcoinjs-lib": "^6.1.5", "express": "^4.18.2", "tiny-secp256k1": "^2.2.3" @@ -17,17 +17,6 @@ "@types/express": "^4.17.21" } }, - "../basic_bitcoin": { - "hasInstallScript": true, - "dependencies": { - "azle": "0.24.1", - "bitcoinjs-lib": "^6.1.5", - "express": "^4.18.2" - }, - "devDependencies": { - "@types/express": "^4.17.21" - } - }, "node_modules/@adraffy/ens-normalize": { "version": "1.10.1", "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", @@ -844,8 +833,15 @@ "license": "MIT" }, "node_modules/basic_bitcoin": { - "resolved": "../basic_bitcoin", - "link": true + "version": "0.0.0", + "resolved": "file:basic_bitcoin-0.0.0.tgz", + "integrity": "sha512-xVMKhEKuL9G87V5JJWNJuBoYUYEinQ44K6pfr+ZGP3Bo7KVgB+iT5MR5d/QNlvgM51v9Vo+13efRkizfiZQxxg==", + "hasInstallScript": true, + "dependencies": { + "azle": "0.24.1", + "bitcoinjs-lib": "^6.1.5", + "express": "^4.18.2" + } }, "node_modules/bech32": { "version": "2.0.0", diff --git a/examples/experimental/demo/bitcoin_psbt/package.json b/examples/experimental/demo/bitcoin_psbt/package.json index 0dee5a5196..a6633d6ef8 100644 --- a/examples/experimental/demo/bitcoin_psbt/package.json +++ b/examples/experimental/demo/bitcoin_psbt/package.json @@ -11,6 +11,7 @@ "help": ".bitcoin/bin/bitcoin-cli -conf=$(pwd)/.bitcoin.conf help", "premanualtest": "tsx test/pretest.ts", "manualtest": "jest test/manual_test.ts test/manual.test.ts", + "preinstall": "echo 'absolutely running preinstall'", "install": "./scripts/install.sh", "pretest": "tsx test/pretest.ts", "test": "jest test/test.ts" @@ -18,7 +19,7 @@ "dependencies": { "@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3", "azle": "0.24.1", - "basic_bitcoin": "file:../basic_bitcoin", + "basic_bitcoin": "file:basic_bitcoin-0.0.0.tgz", "bitcoinjs-lib": "^6.1.5", "express": "^4.18.2", "tiny-secp256k1": "^2.2.3" diff --git a/examples/experimental/demo/bitcoin_psbt/test/pretest.ts b/examples/experimental/demo/bitcoin_psbt/test/pretest.ts index ecc2d1b307..2ee3e53501 100644 --- a/examples/experimental/demo/bitcoin_psbt/test/pretest.ts +++ b/examples/experimental/demo/bitcoin_psbt/test/pretest.ts @@ -1,11 +1,11 @@ -import { linkAndInstallPatch } from 'azle/test/jest_link'; import { execSync } from 'child_process'; -import { join } from 'path'; function pretest(): void { - linkAndInstallPatch( - join('examples', 'experimental', 'demo', 'basic_bitcoin') - ); + execSync(`npm install $(npm pack ../basic_bitcoin)`); + + if (process.env.AZLE_END_TO_END_TEST_LINK_AZLE !== 'false') { + execSync(`npm link azle`); + } execSync(`dfx canister uninstall-code bitcoin_psbt || true`, { stdio: 'inherit'