Skip to content

Commit

Permalink
Merge pull request #1905 from demergent-labs/reorganize_examples
Browse files Browse the repository at this point in the history
reorganize examples and tests
  • Loading branch information
lastmjs authored Jul 17, 2024
2 parents d215374 + bb4064d commit a787888
Show file tree
Hide file tree
Showing 1,449 changed files with 2,941 additions and 23,262 deletions.
197 changes: 96 additions & 101 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
# The basic-integration-tests matrix spins up one job per combination of example directory and code source (repo or npm).
# The check-basic-integration-tests-success job is designed to ensure that all jobs spun up from the matrix in the basic-integration-tests have succeeded

# TODO Restore when https://github.com/demergent-labs/azle/issues/1799 is resolved
# "examples/run_time_errors",
# TODO are these examples ever going to be added back into here?
# "examples/plugins",
# "examples/primitive_ops",

name: Azle Tests
on:
push:
Expand Down Expand Up @@ -66,102 +60,19 @@ jobs:
- id: example_directories
# TODO to improve this further we might be able to create an environment variable that grabs the example directories with a glob
# TODO we want to be able to easily include and exclude examples though
# TODO we have a number of flaky tests and we have moved them to the top of the list here so we can keep a better eye on them until we have resolved their flakyness
run: |
EXAMPLE_DIRECTORIES=$(cat << END
[
"examples/apollo_server",
"examples/async_await",
"examples/audio_and_video",
"examples/audio_recorder",
"examples/autoreload",
"property_tests/tests/service",
"property_tests/tests/stable_b_tree_map",
"tests/end_to_end/http_server/ethers_base",
"tests/end_to_end/http_server/http_outcall_fetch",
"tests/end_to_end/http_server/ic_evm_rpc",
"examples/basic_bitcoin",
"examples/bitcoin",
"examples/bitcoin_psbt",
"examples/bitcoinjs_lib",
"examples/bitcore_lib",
"examples/blob_array",
"examples/bytes",
"examples/call_raw",
"examples/candid_encoding",
"examples/candid_keywords",
"examples/canister",
"examples/ckbtc",
"examples/complex_init",
"examples/complex_types",
"examples/composite_queries",
"examples/counter",
"examples/cross_canister_calls",
"examples/cycles",
"examples/date",
"examples/ethereum_json_rpc",
"examples/ethers",
"examples/ethers_base",
"examples/express",
"examples/fetch_ic",
"examples/file_protocol",
"examples/fs",
"examples/func_types",
"examples/heartbeat",
"examples/hello_world",
"examples/http_outcall_fetch",
"examples/hybrid_canister",
"examples/ic_api",
"examples/ic_evm_rpc",
"examples/icrc",
"examples/imports",
"examples/init",
"examples/inspect_message",
"examples/internet_identity",
"examples/key_value_store",
"examples/large_files",
"examples/ledger_canister",
"examples/list_of_lists",
"examples/management_canister",
"examples/manual_reply",
"examples/motoko_examples/calc",
"examples/motoko_examples/counter",
"examples/motoko_examples/echo",
"examples/motoko_examples/factorial",
"examples/motoko_examples/hello",
"examples/motoko_examples/hello-world",
"examples/motoko_examples/http_counter",
"examples/motoko_examples/minimal-counter-dapp",
"examples/motoko_examples/persistent-storage",
"examples/motoko_examples/phone-book",
"examples/motoko_examples/quicksort",
"examples/motoko_examples/simple-to-do",
"examples/motoko_examples/superheroes",
"examples/motoko_examples/threshold_ecdsa",
"examples/motoko_examples/whoami",
"examples/nest",
"examples/new",
"examples/notify_raw",
"examples/null_example",
"examples/open_value_sharing",
"examples/optional_types",
"examples/outgoing_http_requests",
"examples/pre_and_post_upgrade",
"examples/primitive_types",
"examples/principal",
"examples/query",
"examples/randomness",
"examples/recursion",
"examples/rejections",
"examples/robust_imports",
"examples/simple_erc20",
"examples/simple_user_accounts",
"examples/sqlite",
"examples/sqlite_drizzle",
"examples/sqlite_typeorm",
"examples/stable_b_tree_map_instruction_threshold",
"examples/stable_memory",
"examples/stable_structures",
"examples/tfjs",
"examples/timers",
"examples/tuple_types",
"examples/update",
"examples/vanilla_js",
"examples/web_assembly",
"property_tests/tests/blob",
"property_tests/tests/bool",
"property_tests/tests/canister_methods/http_request",
Expand All @@ -176,22 +87,20 @@ jobs:
"property_tests/tests/float64",
"property_tests/tests/func",
"property_tests/tests/int",
"property_tests/tests/int8",
"property_tests/tests/int16",
"property_tests/tests/int32",
"property_tests/tests/int64",
"property_tests/tests/int8",
"property_tests/tests/nat",
"property_tests/tests/nat8",
"property_tests/tests/nat16",
"property_tests/tests/nat32",
"property_tests/tests/nat64",
"property_tests/tests/nat8",
"property_tests/tests/null",
"property_tests/tests/opt",
"property_tests/tests/principal",
"property_tests/tests/record",
"property_tests/tests/recursive",
"property_tests/tests/service",
"property_tests/tests/stable_b_tree_map",
"property_tests/tests/text",
"property_tests/tests/tuple",
"property_tests/tests/variant",
Expand All @@ -205,7 +114,6 @@ jobs:
"tests/end_to_end/candid_rpc/class_syntax/candid_encoding",
"tests/end_to_end/candid_rpc/class_syntax/candid_keywords",
"tests/end_to_end/candid_rpc/class_syntax/canister",
"tests/end_to_end/candid_rpc/class_syntax/ckbtc",
"tests/end_to_end/candid_rpc/class_syntax/complex_init",
"tests/end_to_end/candid_rpc/class_syntax/complex_types",
"tests/end_to_end/candid_rpc/class_syntax/composite_queries",
Expand Down Expand Up @@ -241,6 +149,7 @@ jobs:
"tests/end_to_end/candid_rpc/class_syntax/motoko_examples/superheroes",
"tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa",
"tests/end_to_end/candid_rpc/class_syntax/motoko_examples/whoami",
"tests/end_to_end/candid_rpc/class_syntax/new",
"tests/end_to_end/candid_rpc/class_syntax/notify_raw",
"tests/end_to_end/candid_rpc/class_syntax/null_example",
"tests/end_to_end/candid_rpc/class_syntax/optional_types",
Expand All @@ -260,7 +169,93 @@ jobs:
"tests/end_to_end/candid_rpc/class_syntax/timers",
"tests/end_to_end/candid_rpc/class_syntax/tuple_types",
"tests/end_to_end/candid_rpc/class_syntax/update",
"tests/end_to_end/candid_rpc/class_syntax/vanilla_js"
"tests/end_to_end/candid_rpc/class_syntax/vanilla_js",
"tests/end_to_end/candid_rpc/functional_syntax/async_await",
"tests/end_to_end/candid_rpc/functional_syntax/audio_recorder",
"tests/end_to_end/candid_rpc/functional_syntax/bitcoin",
"tests/end_to_end/candid_rpc/functional_syntax/blob_array",
"tests/end_to_end/candid_rpc/functional_syntax/bytes",
"tests/end_to_end/candid_rpc/functional_syntax/call_raw",
"tests/end_to_end/candid_rpc/functional_syntax/candid_encoding",
"tests/end_to_end/candid_rpc/functional_syntax/candid_keywords",
"tests/end_to_end/candid_rpc/functional_syntax/canister",
"tests/end_to_end/candid_rpc/functional_syntax/ckbtc",
"tests/end_to_end/candid_rpc/functional_syntax/complex_init",
"tests/end_to_end/candid_rpc/functional_syntax/complex_types",
"tests/end_to_end/candid_rpc/functional_syntax/composite_queries",
"tests/end_to_end/candid_rpc/functional_syntax/counter",
"tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls",
"tests/end_to_end/candid_rpc/functional_syntax/cycles",
"tests/end_to_end/candid_rpc/functional_syntax/date",
"tests/end_to_end/candid_rpc/functional_syntax/ethereum_json_rpc",
"tests/end_to_end/candid_rpc/functional_syntax/func_types",
"tests/end_to_end/candid_rpc/functional_syntax/heartbeat",
"tests/end_to_end/candid_rpc/functional_syntax/ic_api",
"tests/end_to_end/candid_rpc/functional_syntax/icrc",
"tests/end_to_end/candid_rpc/functional_syntax/imports",
"tests/end_to_end/candid_rpc/functional_syntax/init",
"tests/end_to_end/candid_rpc/functional_syntax/inspect_message",
"tests/end_to_end/candid_rpc/functional_syntax/key_value_store",
"tests/end_to_end/candid_rpc/functional_syntax/ledger_canister",
"tests/end_to_end/candid_rpc/functional_syntax/list_of_lists",
"tests/end_to_end/candid_rpc/functional_syntax/management_canister",
"tests/end_to_end/candid_rpc/functional_syntax/manual_reply",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/calc",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/counter",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/echo",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/factorial",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/hello",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/hello-world",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/http_counter",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/minimal-counter-dapp",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/persistent-storage",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/phone-book",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/quicksort",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/simple-to-do",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/superheroes",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/threshold_ecdsa",
"tests/end_to_end/candid_rpc/functional_syntax/motoko_examples/whoami",
"tests/end_to_end/candid_rpc/functional_syntax/notify_raw",
"tests/end_to_end/candid_rpc/functional_syntax/null_example",
"tests/end_to_end/candid_rpc/functional_syntax/optional_types",
"tests/end_to_end/candid_rpc/functional_syntax/outgoing_http_requests",
"tests/end_to_end/candid_rpc/functional_syntax/pre_and_post_upgrade",
"tests/end_to_end/candid_rpc/functional_syntax/primitive_types",
"tests/end_to_end/candid_rpc/functional_syntax/principal",
"tests/end_to_end/candid_rpc/functional_syntax/query",
"tests/end_to_end/candid_rpc/functional_syntax/randomness",
"tests/end_to_end/candid_rpc/functional_syntax/recursion",
"tests/end_to_end/candid_rpc/functional_syntax/rejections",
"tests/end_to_end/candid_rpc/functional_syntax/robust_imports",
"tests/end_to_end/candid_rpc/functional_syntax/simple_erc20",
"tests/end_to_end/candid_rpc/functional_syntax/simple_user_accounts",
"tests/end_to_end/candid_rpc/functional_syntax/stable_b_tree_map_instruction_threshold",
"tests/end_to_end/candid_rpc/functional_syntax/stable_memory",
"tests/end_to_end/candid_rpc/functional_syntax/stable_structures",
"tests/end_to_end/candid_rpc/functional_syntax/timers",
"tests/end_to_end/candid_rpc/functional_syntax/tuple_types",
"tests/end_to_end/candid_rpc/functional_syntax/update",
"tests/end_to_end/candid_rpc/functional_syntax/vanilla_js",
"tests/end_to_end/http_server/apollo_server",
"tests/end_to_end/http_server/audio_and_video",
"tests/end_to_end/http_server/autoreload",
"tests/end_to_end/http_server/bitcoinjs_lib",
"tests/end_to_end/http_server/bitcore_lib",
"tests/end_to_end/http_server/ethers",
"tests/end_to_end/http_server/express",
"tests/end_to_end/http_server/fetch_ic",
"tests/end_to_end/http_server/file_protocol",
"tests/end_to_end/http_server/fs",
"tests/end_to_end/http_server/hybrid_canister",
"tests/end_to_end/http_server/internet_identity",
"tests/end_to_end/http_server/large_files",
"tests/end_to_end/http_server/nest",
"tests/end_to_end/http_server/open_value_sharing",
"tests/end_to_end/http_server/sqlite",
"tests/end_to_end/http_server/sqlite_drizzle",
"tests/end_to_end/http_server/sqlite_typeorm",
"tests/end_to_end/http_server/tfjs",
"tests/end_to_end/http_server/web_assembly"
]
END
)
Expand Down
10 changes: 4 additions & 6 deletions examples/ckbtc/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
"wallet_backend": {
"type": "azle",
"main": "wallet/backend/index.ts",
"candid_gen": "automatic",
"env": ["CK_BTC_PRINCIPAL", "MINTER_PRINCIPAL", "AZLE_TEST_FETCH"],
"assets": [
["minter/minter.did", "minter/minter.did"],
["wallet/backend/icrc.did", "candid/icp/icrc.did"]
],
"candid": "wallet/backend/index.did",
"candid_gen": "custom",
"env": ["CK_BTC_PRINCIPAL", "MINTER_PRINCIPAL"],
"assets": [["minter/minter.did", "minter/minter.did"]],
"declarations": {
"node_compatibility": true,
"output": "wallet/frontend/dfx_generated/wallet_backend"
Expand Down
38 changes: 37 additions & 1 deletion examples/ckbtc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions examples/ckbtc/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"name": "ckbtc_end_to_end_test_functional_syntax",
"scripts": {
"bitcoin": ".bitcoin/bin/bitcoind -conf=$(pwd)/.bitcoin.conf -datadir=$(pwd)/.bitcoin/data --port=18444",
"ic": "dfx start --clean --host 127.0.0.1:8000 --enable-bitcoin",
Expand All @@ -20,16 +19,16 @@
"frontend": "npx open-cli http://ryjl3-tyaaa-aaaaa-aaaba-cai.localhost:8000/",
"mint": ".bitcoin/bin/bitcoin-cli -conf=$(pwd)/.bitcoin.conf generatetoaddress 1 $npm_config_address",
"build": "cd wallet/frontend && npm run build",
"pre_tests": "tsx test/pretest.ts",
"tests": "npm run pre_tests && jest",
"test": "AZLE_TEST_FETCH=false npm run tests && AZLE_TEST_FETCH=true npm run tests"
"pretest": "tsx test/pretest.ts",
"test": "jest"
},
"dependencies": {
"azle": "0.22.0"
},
"devDependencies": {
"@dfinity/agent": "^0.19.2",
"@dfinity/identity": "^0.19.2",
"ckbtc_end_to_end_test_functional_syntax": "file:../../tests/end_to_end/candid_rpc/functional_syntax/ckbtc",
"jest": "^29.7.0",
"ts-jest": "^29.1.4",
"tsx": "^4.15.7",
Expand Down
6 changes: 6 additions & 0 deletions examples/ckbtc/test/pretest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { linkAndInstallPatch } from 'azle/test/jest_link';
import { execSync } from 'child_process';
import { join } from 'path';

function pretest(): void {
linkAndInstallPatch(
join('tests', 'end_to_end', 'candid_rpc', 'functional_syntax', 'ckbtc')
);

uninstall(
'ckbtc',
'internet_identity',
Expand Down
Loading

0 comments on commit a787888

Please sign in to comment.