From 5ecc6348ca680770175247fd5aa8baddbf5f1bca Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 26 Aug 2024 12:39:54 -0600 Subject: [PATCH 01/58] put service tests in the right place --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86d549f07d..d7c35cb21b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,9 +64,7 @@ jobs: run: | EXAMPLE_DIRECTORIES=$(cat << END [ - "tests/property/candid_rpc/class_api/service", "tests/property/candid_rpc/class_api/stable_b_tree_map", - "tests/property/candid_rpc/functional_api/service", "tests/property/candid_rpc/functional_api/stable_b_tree_map", "tests/end_to_end/http_server/ethers_base", "tests/end_to_end/http_server/http_outcall_fetch", @@ -104,6 +102,7 @@ jobs: "tests/property/candid_rpc/class_api/principal", "tests/property/candid_rpc/class_api/record", "tests/property/candid_rpc/class_api/recursive", + "tests/property/candid_rpc/class_api/service", "tests/property/candid_rpc/class_api/text", "tests/property/candid_rpc/class_api/tuple", "tests/property/candid_rpc/class_api/variant", @@ -136,6 +135,7 @@ jobs: "tests/property/candid_rpc/functional_api/principal", "tests/property/candid_rpc/functional_api/record", "tests/property/candid_rpc/functional_api/recursive", + "tests/property/candid_rpc/functional_api/service", "tests/property/candid_rpc/functional_api/text", "tests/property/candid_rpc/functional_api/tuple", "tests/property/candid_rpc/functional_api/variant", From c30880af651705b8be21edaf4efd711397a16ec5 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 26 Aug 2024 14:55:50 -0600 Subject: [PATCH 02/58] try setting name --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d7c35cb21b..9eb7fe66cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -317,6 +317,7 @@ jobs: echo "::set-output name=should_run_tests::true" fi basic-integration-tests: + name: $(basename ${{matrix.example_directories}}) | ${{matrix.azle_source}} | ${{matrix.example_directories}} needs: release-candidate-deploy runs-on: ${{ matrix.os }} env: @@ -343,6 +344,15 @@ jobs: # If should_run_tests is false, we still want the steps of this job to execute so that check-basic-integration-tests-success will run. We do this by creating an array with one dummy element example_directories: ${{ needs.release-candidate-deploy.outputs.should_run_tests == 'true' && fromJSON(needs.release-candidate-deploy.outputs.example_directories) || fromJSON('["dummy"]') }} steps: + - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + name: Echo test name + id: echo-test-name + run: echo "${{ matrix.example_directories }}" + - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + name: Set test name + id: set-test-name + run: | + echo "TEST_NAME=$(basename ${{ matrix.example_directories }})" >> $GITHUB_ENV - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} uses: actions/checkout@v4 - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} From b68395293e99ac734c40d1f13e9fb3bd2dc8ded1 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 10:48:09 -0600 Subject: [PATCH 03/58] first pass --- scripts/test.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 scripts/test.sh diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000000..dfa7c30144 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Base directories +BASE_DIR="." +EXAMPLES_DIR="$BASE_DIR/examples" +TESTS_DIR="$BASE_DIR/tests" + +# Function to discover test directories +discover_directories() { + local dir=$1 + find "$dir" -type d +} + +# Discover directories in examples and tests +example_directories=$(discover_directories "$EXAMPLES_DIR") +test_directories=$(discover_directories "$TESTS_DIR") + +# Combine all directories into a single list +all_directories=$(echo -e "$example_directories\n$test_directories") + +# Output the directories +echo "$all_directories" From a7f38544c232f95c1ad82fe37131283d45f90f02 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 10:49:37 -0600 Subject: [PATCH 04/58] limit to npm packages --- scripts/test.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index dfa7c30144..28582d5a21 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -5,15 +5,15 @@ BASE_DIR="." EXAMPLES_DIR="$BASE_DIR/examples" TESTS_DIR="$BASE_DIR/tests" -# Function to discover test directories -discover_directories() { +# Function to discover npm package directories +discover_npm_packages() { local dir=$1 - find "$dir" -type d + find "$dir" -type d -exec test -f "{}/package.json" \; -print } -# Discover directories in examples and tests -example_directories=$(discover_directories "$EXAMPLES_DIR") -test_directories=$(discover_directories "$TESTS_DIR") +# Discover npm packages in examples and tests +example_directories=$(discover_npm_packages "$EXAMPLES_DIR") +test_directories=$(discover_npm_packages "$TESTS_DIR") # Combine all directories into a single list all_directories=$(echo -e "$example_directories\n$test_directories") From 4ae2ebd81fd910f115dbb749887a8c3a60dbbec7 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 10:50:41 -0600 Subject: [PATCH 05/58] restrict to npm packages --- scripts/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index 28582d5a21..fdc08504d9 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -5,10 +5,10 @@ BASE_DIR="." EXAMPLES_DIR="$BASE_DIR/examples" TESTS_DIR="$BASE_DIR/tests" -# Function to discover npm package directories +# Function to discover npm package directories, excluding node_modules discover_npm_packages() { local dir=$1 - find "$dir" -type d -exec test -f "{}/package.json" \; -print + find "$dir" -type d -not -path "*/node_modules/*" -exec test -f "{}/package.json" \; -print } # Discover npm packages in examples and tests From b7e5ed11e080ee544bfabf03bc9a24de7172f814 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 10:53:28 -0600 Subject: [PATCH 06/58] add exclusions --- scripts/test.sh | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index fdc08504d9..082ef20f8e 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -5,18 +5,42 @@ BASE_DIR="." EXAMPLES_DIR="$BASE_DIR/examples" TESTS_DIR="$BASE_DIR/tests" -# Function to discover npm package directories, excluding node_modules -discover_npm_packages() { +# Directories to exclude +EXCLUDE_DIRS=( + "tests/property/candid_rpc/class_api/stable_b_tree_map" + "tests/property/candid_rpc/functional_api/stable_b_tree_map" +) + +# Function to discover test directories +discover_directories() { + local dir=$1 + find "$dir" -type d ! -path "*/node_modules/*" +} + +# Function to check if a directory is excluded +is_excluded() { local dir=$1 - find "$dir" -type d -not -path "*/node_modules/*" -exec test -f "{}/package.json" \; -print + for exclude in "${EXCLUDE_DIRS[@]}"; do + if [[ "$dir" == *"$exclude" ]]; then + return 0 + fi + done + return 1 } -# Discover npm packages in examples and tests -example_directories=$(discover_npm_packages "$EXAMPLES_DIR") -test_directories=$(discover_npm_packages "$TESTS_DIR") +# Discover directories in examples and tests +example_directories=$(discover_directories "$EXAMPLES_DIR") +test_directories=$(discover_directories "$TESTS_DIR") -# Combine all directories into a single list -all_directories=$(echo -e "$example_directories\n$test_directories") +# Combine all directories into a single list and filter out excluded directories +all_directories=$(echo -e "$example_directories\n$test_directories" | while read -r dir; do + if is_excluded "$dir"; then + continue + fi + if [[ -f "$dir/package.json" ]]; then + echo "$dir" + fi +done) # Output the directories echo "$all_directories" From 6657880278c8bc5622f3bd78775adf10ffd8cb42 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 10:58:58 -0600 Subject: [PATCH 07/58] alphabetize --- scripts/test.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index 082ef20f8e..2127a4d5ea 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -42,5 +42,7 @@ all_directories=$(echo -e "$example_directories\n$test_directories" | while read fi done) -# Output the directories -echo "$all_directories" +# Sort the directories alphabetically and output them +sorted_directories=$(echo "$all_directories" | sort) + +echo "$sorted_directories" From 181eabcd877eacb11dcc991b45369ada1dfde7d4 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 12:20:29 -0600 Subject: [PATCH 08/58] update to json --- scripts/test.sh | 72 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index 2127a4d5ea..88be4ee3bd 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -5,16 +5,16 @@ BASE_DIR="." EXAMPLES_DIR="$BASE_DIR/examples" TESTS_DIR="$BASE_DIR/tests" -# Directories to exclude +# Excluded directories EXCLUDE_DIRS=( - "tests/property/candid_rpc/class_api/stable_b_tree_map" - "tests/property/candid_rpc/functional_api/stable_b_tree_map" + "$EXAMPLES_DIR/ckbtc/wallet/frontend" + "$TESTS_DIR/end_to_end/candid_rpc/functional_syntax/ckbtc/wallet/frontend" ) # Function to discover test directories discover_directories() { local dir=$1 - find "$dir" -type d ! -path "*/node_modules/*" + find "$dir" -type d -not -path "*/node_modules/*" -exec test -f "{}/package.json" \; -print } # Function to check if a directory is excluded @@ -28,21 +28,57 @@ is_excluded() { return 1 } -# Discover directories in examples and tests -example_directories=$(discover_directories "$EXAMPLES_DIR") -test_directories=$(discover_directories "$TESTS_DIR") +# Generate JSON object for each directory +generate_json() { + local dir=$1 + local name=$(basename "$dir") + local type="" + local syntax="" + local api="" -# Combine all directories into a single list and filter out excluded directories -all_directories=$(echo -e "$example_directories\n$test_directories" | while read -r dir; do - if is_excluded "$dir"; then - continue - fi - if [[ -f "$dir/package.json" ]]; then - echo "$dir" + if [[ "$dir" == "$EXAMPLES_DIR"* ]]; then + type="ex" + elif [[ "$dir" == "$TESTS_DIR/property"* ]]; then + type="prop" + if [[ "$dir" == *"/candid_rpc/"* ]]; then + syntax="crpc" + if [[ "$dir" == *"/functional_api/"* ]]; then + api="functional" + elif [[ "$dir" == *"/class_api/"* ]]; then + api="class" + fi + elif [[ "$dir" == *"/ic_api/"* ]]; then + syntax="ic_api" + fi + elif [[ "$dir" == "$TESTS_DIR/end_to_end"* ]]; then + type="e2e" + if [[ "$dir" == *"/http_server/"* ]]; then + syntax="http" + elif [[ "$dir" == *"/candid_rpc/"* ]]; then + syntax="crpc" + fi fi -done) -# Sort the directories alphabetically and output them -sorted_directories=$(echo "$all_directories" | sort) + # Construct JSON object + echo "{" + echo " \"path\": \"$dir\"," + echo " \"name\": \"$name\"," + echo " \"type\": \"$type\"," + [[ -n "$syntax" ]] && echo " \"syntax\": \"$syntax\"," + [[ -n "$api" ]] && echo " \"api\": \"$api\"," + echo "}," +} + +# Discover directories in examples and tests, excluding specified directories +all_directories=$(discover_directories "$EXAMPLES_DIR") +all_directories+=$'\n' +all_directories+=$(discover_directories "$TESTS_DIR") -echo "$sorted_directories" +# Sort, filter, and generate JSON objects +echo "[" +echo "$all_directories" | sort | while read -r dir; do + if ! is_excluded "$dir"; then + generate_json "$dir" + fi +done | sed '$ s/,$//' # Remove the last comma +echo "]" From 0a4816138bebe416f84ab12bc8106f10a1478934 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 12:24:21 -0600 Subject: [PATCH 09/58] limit to only packages that have tests --- scripts/test.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index 88be4ee3bd..368c6fc4b5 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -7,14 +7,22 @@ TESTS_DIR="$BASE_DIR/tests" # Excluded directories EXCLUDE_DIRS=( - "$EXAMPLES_DIR/ckbtc/wallet/frontend" - "$TESTS_DIR/end_to_end/candid_rpc/functional_syntax/ckbtc/wallet/frontend" + "$EXAMPLES_DIR/filter_example" + "$TESTS_DIR/end_to_end/candid_rpc/functional_syntax/filter_example" ) # Function to discover test directories discover_directories() { local dir=$1 - find "$dir" -type d -not -path "*/node_modules/*" -exec test -f "{}/package.json" \; -print + find "$dir" -type d -not -path "*/node_modules/*" -exec sh -c ' + for pkg in "$@"; do + if [ -f "$pkg/package.json" ]; then + if jq -e ".scripts.test" "$pkg/package.json" > /dev/null; then + echo "$pkg" + fi + fi + done + ' sh {} + } # Function to check if a directory is excluded From 93223941d143b78888ddee98c9fffe282722cfca Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 12:36:12 -0600 Subject: [PATCH 10/58] test new auto generated tests --- .github/workflows/test.yml | 299 ++++++++----------------------------- scripts/just-paths.sh | 14 ++ scripts/test.sh | 47 ++++-- 3 files changed, 117 insertions(+), 243 deletions(-) create mode 100755 scripts/just-paths.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9eb7fe66cc..aa96bffbec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,63 @@ on: - main pull_request: # Runs on pull requests to any branch jobs: + generate-tests: + runs-on: ubuntu-latest + outputs: + all_tests: ${{ steps.get_all_tests.outputs.all_tests }} + steps: + - uses: actions/checkout@v4 + - id: get_all_tests + name: generateTests + run: | + ALL_TESTS=$(./scripts/test.sh | base64 -d) + echo "all_tests=$ALL_TESTS" >> $GITHUB_OUTPUT + - name: Print the captured output + run: | + echo "${{ steps.get_all_tests.outputs.all_tests }}" | tail + debug-generate-tests: + name: ${{matrix.tests.name}} + needs: generate-tests + runs-on: ubuntu-latests + strategy: + fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest + matrix: + tests: ${{ fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} + steps: + - name: Echo test + id: echo-test + run: echo "${{ matrix.tests }}" + - name: Echo test path + id: echo-test-path + run: echo "${{ matrix.tests.path }}" + - name: Echo test name + id: echo-test-name + run: echo "${{ matrix.tests.name }}" + test-path-generate: + runs-on: ubuntu-latest + outputs: + all_tests: ${{ steps.get_all_tests.outputs.all_tests }} + steps: + - uses: actions/checkout@v4 + - id: get_all_tests + name: generateTests + run: | + ALL_TESTS=$(./scripts/test.sh | base64 -d) + echo "::set-output name=all_tests::$ALL_TESTS" + - name: Print the captured output + run: echo "${{ steps.get_all_tests.outputs.all_tests }}" + test-path-debugging: + name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} + runs-on: ubuntu-latest + needs: test-path-generate + strategy: + fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest + matrix: + tests: ${{ fromJSON(needs.test-path-generate.outputs.all_tests) || fromJSON('["dummy"]') }} + steps: + - name: Echo test + id: echo-test + run: echo "${{ matrix.tests.path }}" release-candidate-deploy: runs-on: ubuntu-latest env: @@ -64,240 +121,8 @@ jobs: run: | EXAMPLE_DIRECTORIES=$(cat << END [ - "tests/property/candid_rpc/class_api/stable_b_tree_map", - "tests/property/candid_rpc/functional_api/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_psbt", - "examples/ckbtc", "examples/hello_world", - "examples/hello_world_candid_rpc", - "tests/property/candid_rpc/class_api/blob", - "tests/property/candid_rpc/class_api/bool", - "tests/property/candid_rpc/class_api/canister_methods/http_request", - "tests/property/candid_rpc/class_api/canister_methods/http_request_update", - "tests/property/candid_rpc/class_api/canister_methods/init", - "tests/property/candid_rpc/class_api/canister_methods/inspect_message", - "tests/property/candid_rpc/class_api/canister_methods/post_upgrade", - "tests/property/candid_rpc/class_api/canister_methods/pre_upgrade", - "tests/property/candid_rpc/class_api/canister_methods/query", - "tests/property/candid_rpc/class_api/canister_methods/update", - "tests/property/candid_rpc/class_api/float32", - "tests/property/candid_rpc/class_api/float64", - "tests/property/candid_rpc/class_api/func", - "tests/property/candid_rpc/class_api/int", - "tests/property/candid_rpc/class_api/int16", - "tests/property/candid_rpc/class_api/int32", - "tests/property/candid_rpc/class_api/int64", - "tests/property/candid_rpc/class_api/int8", - "tests/property/candid_rpc/class_api/nat", - "tests/property/candid_rpc/class_api/nat16", - "tests/property/candid_rpc/class_api/nat32", - "tests/property/candid_rpc/class_api/nat64", - "tests/property/candid_rpc/class_api/nat8", - "tests/property/candid_rpc/class_api/null", - "tests/property/candid_rpc/class_api/opt", - "tests/property/candid_rpc/class_api/principal", - "tests/property/candid_rpc/class_api/record", - "tests/property/candid_rpc/class_api/recursive", - "tests/property/candid_rpc/class_api/service", - "tests/property/candid_rpc/class_api/text", - "tests/property/candid_rpc/class_api/tuple", - "tests/property/candid_rpc/class_api/variant", - "tests/property/candid_rpc/class_api/vec", - "tests/property/candid_rpc/functional_api/blob", - "tests/property/candid_rpc/functional_api/bool", - "tests/property/candid_rpc/functional_api/canister_methods/http_request", - "tests/property/candid_rpc/functional_api/canister_methods/http_request_update", - "tests/property/candid_rpc/functional_api/canister_methods/init", - "tests/property/candid_rpc/functional_api/canister_methods/inspect_message", - "tests/property/candid_rpc/functional_api/canister_methods/post_upgrade", - "tests/property/candid_rpc/functional_api/canister_methods/pre_upgrade", - "tests/property/candid_rpc/functional_api/canister_methods/query", - "tests/property/candid_rpc/functional_api/canister_methods/update", - "tests/property/candid_rpc/functional_api/float32", - "tests/property/candid_rpc/functional_api/float64", - "tests/property/candid_rpc/functional_api/func", - "tests/property/candid_rpc/functional_api/int", - "tests/property/candid_rpc/functional_api/int16", - "tests/property/candid_rpc/functional_api/int32", - "tests/property/candid_rpc/functional_api/int64", - "tests/property/candid_rpc/functional_api/int8", - "tests/property/candid_rpc/functional_api/nat", - "tests/property/candid_rpc/functional_api/nat16", - "tests/property/candid_rpc/functional_api/nat32", - "tests/property/candid_rpc/functional_api/nat64", - "tests/property/candid_rpc/functional_api/nat8", - "tests/property/candid_rpc/functional_api/null", - "tests/property/candid_rpc/functional_api/opt", - "tests/property/candid_rpc/functional_api/principal", - "tests/property/candid_rpc/functional_api/record", - "tests/property/candid_rpc/functional_api/recursive", - "tests/property/candid_rpc/functional_api/service", - "tests/property/candid_rpc/functional_api/text", - "tests/property/candid_rpc/functional_api/tuple", - "tests/property/candid_rpc/functional_api/variant", - "tests/property/candid_rpc/functional_api/vec", - "tests/end_to_end/candid_rpc/class_syntax/async_await", - "tests/end_to_end/candid_rpc/class_syntax/audio_recorder", - "tests/end_to_end/candid_rpc/class_syntax/bitcoin", - "tests/end_to_end/candid_rpc/class_syntax/blob_array", - "tests/end_to_end/candid_rpc/class_syntax/bytes", - "tests/end_to_end/candid_rpc/class_syntax/call_raw", - "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/complex_init", - "tests/end_to_end/candid_rpc/class_syntax/complex_types", - "tests/end_to_end/candid_rpc/class_syntax/composite_queries", - "tests/end_to_end/candid_rpc/class_syntax/counter", - "tests/end_to_end/candid_rpc/class_syntax/cross_canister_calls", - "tests/end_to_end/candid_rpc/class_syntax/cycles", - "tests/end_to_end/candid_rpc/class_syntax/date", - "tests/end_to_end/candid_rpc/class_syntax/ethereum_json_rpc", - "tests/end_to_end/candid_rpc/class_syntax/func_types", - "tests/end_to_end/candid_rpc/class_syntax/heartbeat", - "tests/end_to_end/candid_rpc/class_syntax/ic_api", - "tests/end_to_end/candid_rpc/class_syntax/icrc", - "tests/end_to_end/candid_rpc/class_syntax/imports", - "tests/end_to_end/candid_rpc/class_syntax/init", - "tests/end_to_end/candid_rpc/class_syntax/inspect_message", - "tests/end_to_end/candid_rpc/class_syntax/key_value_store", - "tests/end_to_end/candid_rpc/class_syntax/ledger_canister", - "tests/end_to_end/candid_rpc/class_syntax/list_of_lists", - "tests/end_to_end/candid_rpc/class_syntax/management_canister", - "tests/end_to_end/candid_rpc/class_syntax/manual_reply", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/calc", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/counter", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/echo", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/factorial", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/hello", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/hello-world", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/http_counter", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/minimal-counter-dapp", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/persistent-storage", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/phone-book", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/quicksort", - "tests/end_to_end/candid_rpc/class_syntax/motoko_examples/simple-to-do", - "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_candid_rpc", - "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", - "tests/end_to_end/candid_rpc/class_syntax/outgoing_http_requests", - "tests/end_to_end/candid_rpc/class_syntax/pre_and_post_upgrade", - "tests/end_to_end/candid_rpc/class_syntax/primitive_types", - "tests/end_to_end/candid_rpc/class_syntax/principal", - "tests/end_to_end/candid_rpc/class_syntax/query", - "tests/end_to_end/candid_rpc/class_syntax/randomness", - "tests/end_to_end/candid_rpc/class_syntax/recursion", - "tests/end_to_end/candid_rpc/class_syntax/rejections", - "tests/end_to_end/candid_rpc/class_syntax/simple_erc20", - "tests/end_to_end/candid_rpc/class_syntax/simple_user_accounts", - "tests/end_to_end/candid_rpc/class_syntax/stable_b_tree_map_instruction_threshold", - "tests/end_to_end/candid_rpc/class_syntax/stable_structures", - "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/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_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/new", - "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", - "tests/property/ic_api/caller", - "tests/property/ic_api/chunk", - "tests/property/ic_api/id", - "tests/property/ic_api/instruction_counter", - "tests/property/ic_api/is_controller", - "tests/property/ic_api/performance_counter", - "tests/property/ic_api/time", - "tests/property/ic_api/trap" + "examples/hello_world2" ] END ) @@ -305,6 +130,12 @@ jobs: EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\n'/'%0A'}" EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\r'/'%0D'}" echo "::set-output name=example_directories::$EXAMPLE_DIRECTORIES" + echo "Here it is the same" + echo $EXAMPLE_DIRECTORIES + echo "Here is the example dirs differently too" + echo "${{ steps.example_directories.outputs.example_directories }}" + - name: Print the captured output + run: echo "${{ steps.example_directories.outputs.example_directories }}" - id: should_run_tests run: | BRANCH_NAME="${{ github.head_ref }}" @@ -317,7 +148,7 @@ jobs: echo "::set-output name=should_run_tests::true" fi basic-integration-tests: - name: $(basename ${{matrix.example_directories}}) | ${{matrix.azle_source}} | ${{matrix.example_directories}} + name: ${{matrix.example_directories}} from ${{matrix.azle_source}} needs: release-candidate-deploy runs-on: ${{ matrix.os }} env: diff --git a/scripts/just-paths.sh b/scripts/just-paths.sh new file mode 100755 index 0000000000..32026a932a --- /dev/null +++ b/scripts/just-paths.sh @@ -0,0 +1,14 @@ +#!/bin/bash +EXAMPLE_DIRECTORIES=$(cat << END +[ + {path: "HERE/hello_world", name: "basic_bitcoin", type: "ex"}, + {path: "HERE/hello_world2", name: "large_files", type: "e2e", "syntax": "http"}, + {path: "HERE/hello_world3", name: "bool", type: "prop", "syntax": "crpc", "api": "class"} +] +END +) +EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//'%'/'%25'}" +EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\n'/'%0A'}" +EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\r'/'%0D'}" + +echo "$EXAMPLE_DIRECTORIES" | base64 diff --git a/scripts/test.sh b/scripts/test.sh index 368c6fc4b5..03a31c3013 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -71,10 +71,16 @@ generate_json() { echo "{" echo " \"path\": \"$dir\"," echo " \"name\": \"$name\"," - echo " \"type\": \"$type\"," - [[ -n "$syntax" ]] && echo " \"syntax\": \"$syntax\"," - [[ -n "$api" ]] && echo " \"api\": \"$api\"," - echo "}," + echo " \"type\": \"$type\"" + [[ -n "$syntax" ]] && echo " ,\"syntax\": \"$syntax\"" + [[ -n "$api" ]] && echo " ,\"api\": \"$api\"" + echo "}" +} + +generate_json_new() { + local dir=$1 + local name=$(basename "$dir") + echo "{path: \"$dir\", name: \"$name\""} } # Discover directories in examples and tests, excluding specified directories @@ -82,11 +88,34 @@ all_directories=$(discover_directories "$EXAMPLES_DIR") all_directories+=$'\n' all_directories+=$(discover_directories "$TESTS_DIR") +# EXAMPLE_DIRECTORIES=$(cat << END +# "HERE/hello_world", +# "HERE/hello_world2", +# "HERE/hello_world3" +# END +# ) + +# Initialize an empty variable to store the JSON result +json_result="[" + # Sort, filter, and generate JSON objects -echo "[" -echo "$all_directories" | sort | while read -r dir; do +while read -r dir; do if ! is_excluded "$dir"; then - generate_json "$dir" + json_result+=$(generate_json "$dir") + json_result+="," fi -done | sed '$ s/,$//' # Remove the last comma -echo "]" +done <<< "$(echo "$all_directories" | sort)" # Feed sorted directories into the loop + +# Remove the last comma and close the JSON array +json_result=$(echo "$json_result" | sed '$ s/,$//') +# json_result=$(echo "$json_result" | sed ':a;N;$!ba;s/\n//g') # Remove new lines +json_result+="]" + +# Store the result in a variable (you can use it as needed) +result="$json_result" +result="${result//'%'/'%25'}" +result="${result//$'\n'/'%0A'}" +result="${result//$'\r'/'%0D'}" + +# Print the result if needed +echo "$result" | base64 From 7e2adee2ffcb4eedda6fb8f9602799f1d2b203e9 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 21:36:27 -0600 Subject: [PATCH 11/58] hook into real tests --- .github/workflows/test.yml | 73 ++++++++------------------------------ 1 file changed, 15 insertions(+), 58 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa96bffbec..05d523c9e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,51 +28,15 @@ jobs: - uses: actions/checkout@v4 - id: get_all_tests name: generateTests - run: | - ALL_TESTS=$(./scripts/test.sh | base64 -d) - echo "all_tests=$ALL_TESTS" >> $GITHUB_OUTPUT - - name: Print the captured output - run: | - echo "${{ steps.get_all_tests.outputs.all_tests }}" | tail - debug-generate-tests: - name: ${{matrix.tests.name}} - needs: generate-tests - runs-on: ubuntu-latests - strategy: - fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest - matrix: - tests: ${{ fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} - steps: - - name: Echo test - id: echo-test - run: echo "${{ matrix.tests }}" - - name: Echo test path - id: echo-test-path - run: echo "${{ matrix.tests.path }}" - - name: Echo test name - id: echo-test-name - run: echo "${{ matrix.tests.name }}" - test-path-generate: - runs-on: ubuntu-latest - outputs: - all_tests: ${{ steps.get_all_tests.outputs.all_tests }} - steps: - - uses: actions/checkout@v4 - - id: get_all_tests - name: generateTests - run: | - ALL_TESTS=$(./scripts/test.sh | base64 -d) - echo "::set-output name=all_tests::$ALL_TESTS" - - name: Print the captured output - run: echo "${{ steps.get_all_tests.outputs.all_tests }}" + run: echo "::set-output name=all_tests::$(./scripts/test.sh | base64 -d)" test-path-debugging: name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} runs-on: ubuntu-latest - needs: test-path-generate + needs: generate-tests strategy: fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest matrix: - tests: ${{ fromJSON(needs.test-path-generate.outputs.all_tests) || fromJSON('["dummy"]') }} + tests: ${{ fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: - name: Echo test id: echo-test @@ -148,8 +112,10 @@ jobs: echo "::set-output name=should_run_tests::true" fi basic-integration-tests: - name: ${{matrix.example_directories}} from ${{matrix.azle_source}} - needs: release-candidate-deploy + name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} / ${{matrix.azle_source}} + needs: + - release-candidate-deploy + - generate-tests runs-on: ${{ matrix.os }} env: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -173,17 +139,8 @@ jobs: - include_npm: true azle_source: repo # If should_run_tests is false, we still want the steps of this job to execute so that check-basic-integration-tests-success will run. We do this by creating an array with one dummy element - example_directories: ${{ needs.release-candidate-deploy.outputs.should_run_tests == 'true' && fromJSON(needs.release-candidate-deploy.outputs.example_directories) || fromJSON('["dummy"]') }} + tests: ${{ needs.release-candidate-deploy.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} - name: Echo test name - id: echo-test-name - run: echo "${{ matrix.example_directories }}" - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} - name: Set test name - id: set-test-name - run: | - echo "TEST_NAME=$(basename ${{ matrix.example_directories }})" >> $GITHUB_ENV - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} uses: actions/checkout@v4 - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} @@ -211,29 +168,29 @@ jobs: run: npm run lint - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} shell: bash -l {0} - working-directory: ${{ matrix.example_directories }} + working-directory: ${{ matrix.tests.path }} run: npm install - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && matrix.azle_source == 'repo' }} shell: bash -l {0} - working-directory: ${{ matrix.example_directories }} + working-directory: ${{ matrix.tests.path }} run: npm link azle - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} - working-directory: ${{ matrix.example_directories }} + working-directory: ${{ matrix.tests.path }} run: npx azle install-dfx-extension - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} - working-directory: ${{ matrix.example_directories }} + working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && !contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} shell: bash -l {0} - working-directory: ${{ matrix.example_directories }} + working-directory: ${{ matrix.tests.path }} run: AZLE_PROPTEST_NUM_RUNS=5 AZLE_PROPTEST_VERBOSE=true npm test - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} shell: bash -l {0} - working-directory: ${{ matrix.example_directories }} + working-directory: ${{ matrix.tests.path }} run: AZLE_PROPTEST_NUM_RUNS=10 AZLE_PROPTEST_VERBOSE=true npm test - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} shell: bash -l {0} - working-directory: ${{ matrix.example_directories }} + working-directory: ${{ matrix.tests.path }} run: AZLE_PROPTEST_NUM_RUNS=100 AZLE_PROPTEST_VERBOSE=true npm test check-basic-integration-tests-success: From f78eccbe1df664e398d52fd50c17b2554af341af Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 22:10:34 -0600 Subject: [PATCH 12/58] update publish-github-actions --- .github/workflows/test.yml | 39 +++----------------------------------- publish-github-action.sh | 2 +- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05d523c9e4..9c8bf3bc5b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,19 +29,9 @@ jobs: - id: get_all_tests name: generateTests run: echo "::set-output name=all_tests::$(./scripts/test.sh | base64 -d)" - test-path-debugging: - name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} - runs-on: ubuntu-latest - needs: generate-tests - strategy: - fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest - matrix: - tests: ${{ fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} - steps: - - name: Echo test - id: echo-test - run: echo "${{ matrix.tests.path }}" release-candidate-deploy: + name: Deploy Release candidate for release branches + needs: generate-tests runs-on: ubuntu-latest env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified @@ -49,7 +39,6 @@ jobs: outputs: # These outputs are used to pass information along to the next job should_run_tests: ${{ steps.should_run_tests.outputs.should_run_tests }} # We only want the next job to run the tests once we have finished deploying to npm and GitHub - example_directories: ${{ steps.example_directories.outputs.example_directories }} steps: - uses: actions/checkout@v4 # if: contains(github.head_ref, 'release--') @@ -78,28 +67,6 @@ jobs: run: echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import - if: contains(github.head_ref, 'release--') run: git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - - 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/hello_world", - "examples/hello_world2" - ] - END - ) - EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//'%'/'%25'}" - EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\n'/'%0A'}" - EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\r'/'%0D'}" - echo "::set-output name=example_directories::$EXAMPLE_DIRECTORIES" - echo "Here it is the same" - echo $EXAMPLE_DIRECTORIES - echo "Here is the example dirs differently too" - echo "${{ steps.example_directories.outputs.example_directories }}" - - name: Print the captured output - run: echo "${{ steps.example_directories.outputs.example_directories }}" - id: should_run_tests run: | BRANCH_NAME="${{ github.head_ref }}" @@ -107,7 +74,7 @@ jobs: COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") if [[ "${{ contains(github.head_ref, 'release--') }}" == "true" && "$COMMIT_MESSAGE" != "azle-bot automated release $RELEASE_VERSION" ]] then - ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(steps.example_directories.outputs.example_directories) }} + ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} else echo "::set-output name=should_run_tests::true" fi diff --git a/publish-github-action.sh b/publish-github-action.sh index 7972b53127..b3e7269066 100755 --- a/publish-github-action.sh +++ b/publish-github-action.sh @@ -8,7 +8,7 @@ VERSION=$1 directories_json_string_with_linebreaks=$2 directories_json_string="${directories_json_string_with_linebreaks//$'\\n'/''}" -directories=$(echo "$directories_json_string" | jq -c -r '.[]') +directories=$(echo "$directories_json_string" | jq -c -r '.[] | .path') sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" package.json sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" dfx_extension/extension.json From 174bb65095d2cdf76b7bb26c6cf21a7376113bcc Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 22:20:44 -0600 Subject: [PATCH 13/58] move should run tests to it's own job --- .github/workflows/test.yml | 75 +++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9c8bf3bc5b..08515997de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,22 +29,38 @@ jobs: - id: get_all_tests name: generateTests run: echo "::set-output name=all_tests::$(./scripts/test.sh | base64 -d)" + determine-should-run-tests: + name: Determine Should Run Tests + runs-on: ubuntu-latest + outputs: + should_run_tests: ${{ steps.determine_should_run_tests.outputs.should_run_tests }} + steps: + - uses: actions/checkout@v4 + - id: determine_should_run_tests + run: | + BRANCH_NAME="${{ github.head_ref }}" + RELEASE_VERSION="${BRANCH_NAME:9}" + COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") + if [[ "${{ contains(github.head_ref, 'release--') }}" == "true" && "$COMMIT_MESSAGE" != "azle-bot automated release $RELEASE_VERSION" ]] + then + echo "::set-output name=should_run_tests::false" + else + echo "::set-output name=should_run_tests::true" + fi release-candidate-deploy: name: Deploy Release candidate for release branches - needs: generate-tests + needs: + - generate-tests + - determine-should-run-tests runs-on: ubuntu-latest env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - outputs: - # These outputs are used to pass information along to the next job - should_run_tests: ${{ steps.should_run_tests.outputs.should_run_tests }} # We only want the next job to run the tests once we have finished deploying to npm and GitHub steps: - uses: actions/checkout@v4 - # if: contains(github.head_ref, 'release--') with: - ref: ${{ contains(github.head_ref, 'release--') && github.event.pull_request.head.ref || github.ref }} # This is necessary for this job to be able to commit and push to the origin remote properly - token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} # A personal GitHub token is setup as a secret so that committing and pushing to GitHub from the Action will trigger another workflow + ref: ${{ contains(github.head_ref, 'release--') && github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - uses: actions/setup-node@v4 with: node-version: 20 @@ -67,21 +83,12 @@ jobs: run: echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import - if: contains(github.head_ref, 'release--') run: git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - - id: should_run_tests - run: | - BRANCH_NAME="${{ github.head_ref }}" - RELEASE_VERSION="${BRANCH_NAME:9}" - COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - if [[ "${{ contains(github.head_ref, 'release--') }}" == "true" && "$COMMIT_MESSAGE" != "azle-bot automated release $RELEASE_VERSION" ]] - then - ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} - else - echo "::set-output name=should_run_tests::true" - fi + - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} + run: ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} basic-integration-tests: name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} / ${{matrix.azle_source}} needs: - - release-candidate-deploy + - determine-should-run-tests - generate-tests runs-on: ${{ matrix.os }} env: @@ -106,56 +113,56 @@ jobs: - include_npm: true azle_source: repo # If should_run_tests is false, we still want the steps of this job to execute so that check-basic-integration-tests-success will run. We do this by creating an array with one dummy element - tests: ${{ needs.release-candidate-deploy.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} + tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} uses: actions/checkout@v4 - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} uses: actions/setup-node@v4 with: node-version: 20 - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} name: Install dfx run: | DFXVM_INIT_YES=true DFX_VERSION=0.21.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && matrix.os == 'macos-latest' }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && matrix.os == 'macos-latest' }} shell: bash -l {0} # The DNS server stuff is because of this: https://github.com/actions/runner-images/issues/6383 run: | sudo networksetup -setdnsservers Ethernet 9.9.9.9 - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} shell: bash -l {0} # TODO figure out why this is here and comment about it run: npm install - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && matrix.azle_source == 'repo' }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && matrix.azle_source == 'repo' }} shell: bash -l {0} run: npm link - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} shell: bash -l {0} run: npm run lint - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} shell: bash -l {0} working-directory: ${{ matrix.tests.path }} run: npm install - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && matrix.azle_source == 'repo' }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && matrix.azle_source == 'repo' }} shell: bash -l {0} working-directory: ${{ matrix.tests.path }} run: npm link azle - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} working-directory: ${{ matrix.tests.path }} run: npx azle install-dfx-extension - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && !contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && !contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} shell: bash -l {0} working-directory: ${{ matrix.tests.path }} run: AZLE_PROPTEST_NUM_RUNS=5 AZLE_PROPTEST_VERBOSE=true npm test - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} shell: bash -l {0} working-directory: ${{ matrix.tests.path }} run: AZLE_PROPTEST_NUM_RUNS=10 AZLE_PROPTEST_VERBOSE=true npm test - - if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} shell: bash -l {0} working-directory: ${{ matrix.tests.path }} run: AZLE_PROPTEST_NUM_RUNS=100 AZLE_PROPTEST_VERBOSE=true npm test From 27dce5050edc4431de154acbe5caf09ad4632895 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 27 Aug 2024 22:29:32 -0600 Subject: [PATCH 14/58] clean up --- .github/workflows/test.yml | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08515997de..4947a84f9d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,8 @@ # Feature branch pull requests (pull requests without release-- in the base branch name) will run all tests against the code found in the repository. # Release branch pull requests (pull requests with release-- in the base branch name) will run all tests against the code found in the repository and the code deployed by the GitHub Action to npm. # Pushes to main will run all tests against the code in the repository if the latest commit was not a merge of a release branch, and will run tests against the code in the repository and the code deployed by the GitHub Action to npm otherwise. -# 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 +# The azle-tests matrix spins up one job per combination of example directory and code source (repo or npm). +# The check-azle-tests-success job is designed to ensure that all jobs spun up from the matrix in the azle-tests have succeeded name: Azle Tests on: @@ -21,6 +21,7 @@ on: pull_request: # Runs on pull requests to any branch jobs: generate-tests: + name: Generate Tests runs-on: ubuntu-latest outputs: all_tests: ${{ steps.get_all_tests.outputs.all_tests }} @@ -74,18 +75,15 @@ jobs: echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH # TODO we should use some Action-specific bot account - if: contains(github.head_ref, 'release--') - run: git config --global user.name 'Jordan Last' - - if: contains(github.head_ref, 'release--') - run: git config --global user.email 'jordan.michael.last@gmail.com' - - if: contains(github.head_ref, 'release--') - run: git config --global commit.gpgsign true - - if: contains(github.head_ref, 'release--') - run: echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import - - if: contains(github.head_ref, 'release--') - run: git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 + run: | + git config --global user.name 'Jordan Last' + git config --global user.email 'jordan.michael.last@gmail.com' + git config --global commit.gpgsign true + echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import + git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} run: ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} - basic-integration-tests: + azle-tests: name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} / ${{matrix.azle_source}} needs: - determine-should-run-tests @@ -112,7 +110,7 @@ jobs: azle_source: npm - include_npm: true azle_source: repo - # If should_run_tests is false, we still want the steps of this job to execute so that check-basic-integration-tests-success will run. We do this by creating an array with one dummy element + # If should_run_tests is false, we still want the steps of this job to execute so that check-azle-tests-success will run. We do this by creating an array with one dummy element tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} @@ -167,15 +165,15 @@ jobs: working-directory: ${{ matrix.tests.path }} run: AZLE_PROPTEST_NUM_RUNS=100 AZLE_PROPTEST_VERBOSE=true npm test - check-basic-integration-tests-success: - needs: basic-integration-tests + check-azle-tests-success: + needs: azle-tests runs-on: ubuntu-latest if: success() steps: - run: exit 0 - check-basic-integration-tests-failure: - needs: basic-integration-tests + check-azle-tests-failure: + needs: azle-tests runs-on: ubuntu-latest if: failure() steps: From 21748dac03198ef0763cc349da137748a27083a2 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 09:58:43 -0600 Subject: [PATCH 15/58] make num runs a variable --- .github/workflows/test.yml | 49 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4947a84f9d..508aaec3cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,10 +10,13 @@ # Feature branch pull requests (pull requests without release-- in the base branch name) will run all tests against the code found in the repository. # Release branch pull requests (pull requests with release-- in the base branch name) will run all tests against the code found in the repository and the code deployed by the GitHub Action to npm. # Pushes to main will run all tests against the code in the repository if the latest commit was not a merge of a release branch, and will run tests against the code in the repository and the code deployed by the GitHub Action to npm otherwise. -# The azle-tests matrix spins up one job per combination of example directory and code source (repo or npm). -# The check-azle-tests-success job is designed to ensure that all jobs spun up from the matrix in the azle-tests have succeeded +# The run-test matrix spins up one job per combination of example directory and code source (repo or npm). +# The check-run-test-success job is designed to ensure that all jobs spun up from the matrix in the run-test have succeeded -name: Azle Tests +## TODO make variable for isRelease +## TODO make sure comments are throughout and not all at the top + +name: Tests on: push: branches: @@ -83,7 +86,7 @@ jobs: git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} run: ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} - azle-tests: + run-test: name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} / ${{matrix.azle_source}} needs: - determine-should-run-tests @@ -110,7 +113,7 @@ jobs: azle_source: npm - include_npm: true azle_source: repo - # If should_run_tests is false, we still want the steps of this job to execute so that check-azle-tests-success will run. We do this by creating an array with one dummy element + # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} @@ -130,7 +133,7 @@ jobs: run: | sudo networksetup -setdnsservers Ethernet 9.9.9.9 - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} - shell: bash -l {0} # TODO figure out why this is here and comment about it + shell: bash -l {0} # This ensures that the script runs in a login shell, making it easier to work with environment variables run: npm install - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && matrix.azle_source == 'repo' }} shell: bash -l {0} @@ -152,28 +155,34 @@ jobs: - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && !contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} - shell: bash -l {0} - working-directory: ${{ matrix.tests.path }} - run: AZLE_PROPTEST_NUM_RUNS=5 AZLE_PROPTEST_VERBOSE=true npm test - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && contains(github.head_ref, 'release--') && !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} - shell: bash -l {0} - working-directory: ${{ matrix.tests.path }} - run: AZLE_PROPTEST_NUM_RUNS=10 AZLE_PROPTEST_VERBOSE=true npm test - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }} + - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + name: Run Test + run: | + if [[ !contains('${{ github.head_ref }}', 'release--') && !('${{ github.ref }}' == 'refs/heads/main' && contains('${{ github.event.head_commit.message }}', 'Merge pull request') && contains('${{ github.event.head_commit.message }}', 'demergent-labs/release--')) ]]; then + export RUNS=5 + elif [[ contains('${{ github.head_ref }}', 'release--') && !('${{ github.ref }}' == 'refs/heads/main' && contains('${{ github.event.head_commit.message }}', 'Merge pull request') && contains('${{ github.event.head_commit.message }}', 'demergent-labs/release--')) ]]; then + export RUNS=10 + elif [[ '${{ github.ref }}' == 'refs/heads/main' && contains('${{ github.event.head_commit.message }}', 'Merge pull request') && contains('${{ github.event.head_commit.message }}', 'demergent-labs/release--') ]]; then + export RUNS=100 + else + export RUNS=5 + fi + + AZLE_PROPTEST_NUM_RUNS=$RUNS AZLE_PROPTEST_VERBOSE=true npm test shell: bash -l {0} working-directory: ${{ matrix.tests.path }} - run: AZLE_PROPTEST_NUM_RUNS=100 AZLE_PROPTEST_VERBOSE=true npm test - check-azle-tests-success: - needs: azle-tests + check-basic-integration-test-success: + name: Check Azle Tests Succeeded + needs: run-test runs-on: ubuntu-latest if: success() steps: - run: exit 0 - check-azle-tests-failure: - needs: azle-tests + check-basic-integration-test-failure: + name: Check Azle Tests Didn't Fail + needs: run-test runs-on: ubuntu-latest if: failure() steps: From fd4b9c01a62da97dd8cf68e09a5bd2566f33de93 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 10:13:10 -0600 Subject: [PATCH 16/58] join similar command into one job --- .github/workflows/test.yml | 78 ++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 508aaec3cd..60c37dda56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,6 +78,7 @@ jobs: echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH # TODO we should use some Action-specific bot account - if: contains(github.head_ref, 'release--') + name: Configure git for Publishing Release run: | git config --global user.name 'Jordan Last' git config --global user.email 'jordan.michael.last@gmail.com' @@ -85,6 +86,7 @@ jobs: echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} + name: Publish Release run: ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} run-test: name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} / ${{matrix.azle_source}} @@ -123,49 +125,67 @@ jobs: with: node-version: 20 - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} - name: Install dfx + name: Run Pre-Test Azle Setup run: | + + # Install dfx DFXVM_INIT_YES=true DFX_VERSION=0.21.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && matrix.os == 'macos-latest' }} + + # MacOS-specific DNS configuration + if [[ "${{ matrix.os }}" == "macos-latest" ]]; then + sudo networksetup -setdnsservers Ethernet 9.9.9.9 + fi + + # Install dependencies + npm install + + # Link azle if the source is repo + if [[ "${{ matrix.azle_source }}" == "repo" ]]; then + npm link + fi + + # Run linting + npm run lint + shell: bash -l {0} - # The DNS server stuff is because of this: https://github.com/actions/runner-images/issues/6383 + - if: ${{needs.determine-should-run-tests.outputs.should_run_tests}} + name: Run Pre-Test Test Setup run: | - sudo networksetup -setdnsservers Ethernet 9.9.9.9 - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} - shell: bash -l {0} # This ensures that the script runs in a login shell, making it easier to work with environment variables - run: npm install - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && matrix.azle_source == 'repo' }} - shell: bash -l {0} - run: npm link - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} - shell: bash -l {0} - run: npm run lint - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} - shell: bash -l {0} + + npm install + + # Link azle in the test directory if the source is repo + if [[ "${{ matrix.azle_source }}" == "repo" ]]; then + npm link azle + fi + + # Install the azle dfx extension + npx azle install-dfx-extension working-directory: ${{ matrix.tests.path }} - run: npm install - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests && matrix.azle_source == 'repo' }} shell: bash -l {0} - working-directory: ${{ matrix.tests.path }} - run: npm link azle - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} - working-directory: ${{ matrix.tests.path }} - run: npx azle install-dfx-extension - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + name: Start dfx working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} name: Run Test run: | - if [[ !contains('${{ github.head_ref }}', 'release--') && !('${{ github.ref }}' == 'refs/heads/main' && contains('${{ github.event.head_commit.message }}', 'Merge pull request') && contains('${{ github.event.head_commit.message }}', 'demergent-labs/release--')) ]]; then - export RUNS=5 - elif [[ contains('${{ github.head_ref }}', 'release--') && !('${{ github.ref }}' == 'refs/heads/main' && contains('${{ github.event.head_commit.message }}', 'Merge pull request') && contains('${{ github.event.head_commit.message }}', 'demergent-labs/release--')) ]]; then - export RUNS=10 - elif [[ '${{ github.ref }}' == 'refs/heads/main' && contains('${{ github.event.head_commit.message }}', 'Merge pull request') && contains('${{ github.event.head_commit.message }}', 'demergent-labs/release--') ]]; then - export RUNS=100 + BRANCH_NAME="${{ github.head_ref }}" + MAIN_BRANCH='refs/heads/main' + COMMIT_MESSAGE="${{ github.event.head_commit.message }}" + RELEASE_TAG='release--' + RELEASE_PR_MERGE_MSG='Merge pull request' + RELEASE_REPO_MSG='demergent-labs/release--' + + if [[ $BRANCH_NAME != *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then + RUNS=5 + elif [[ $BRANCH_NAME == *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then + RUNS=10 + elif [[ ${{ github.ref }} == "$MAIN_BRANCH" && $COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"* ]]; then + RUNS=100 else - export RUNS=5 + RUNS=5 fi AZLE_PROPTEST_NUM_RUNS=$RUNS AZLE_PROPTEST_VERBOSE=true npm test From 5f1de5071de570ce94221db15bfc497d54a3cbe4 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 11:34:53 -0600 Subject: [PATCH 17/58] move generate-tests script --- scripts/test.sh => .github/scripts/generate_tests.sh | 0 .../scripts/publish_github_action.sh | 0 .github/workflows/test.yml | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename scripts/test.sh => .github/scripts/generate_tests.sh (100%) rename publish-github-action.sh => .github/scripts/publish_github_action.sh (100%) diff --git a/scripts/test.sh b/.github/scripts/generate_tests.sh similarity index 100% rename from scripts/test.sh rename to .github/scripts/generate_tests.sh diff --git a/publish-github-action.sh b/.github/scripts/publish_github_action.sh similarity index 100% rename from publish-github-action.sh rename to .github/scripts/publish_github_action.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60c37dda56..98d8c1d4ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v4 - id: get_all_tests name: generateTests - run: echo "::set-output name=all_tests::$(./scripts/test.sh | base64 -d)" + run: echo "::set-output name=all_tests::$(./.github/scripts/generate_tests.sh | base64 -d)" determine-should-run-tests: name: Determine Should Run Tests runs-on: ubuntu-latest @@ -87,7 +87,7 @@ jobs: git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} name: Publish Release - run: ./publish-github-action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} + run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} run-test: name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} / ${{matrix.azle_source}} needs: From 57031d1589b27f4d6109328e694425e93d0d0991 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 12:13:53 -0600 Subject: [PATCH 18/58] update to variables --- .github/workflows/test.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 98d8c1d4ba..6341377072 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,10 +31,11 @@ jobs: steps: - uses: actions/checkout@v4 - id: get_all_tests - name: generateTests + name: Generate Tests run: echo "::set-output name=all_tests::$(./.github/scripts/generate_tests.sh | base64 -d)" + determine-should-run-tests: - name: Determine Should Run Tests + name: Determine If Tests Should Run runs-on: ubuntu-latest outputs: should_run_tests: ${{ steps.determine_should_run_tests.outputs.should_run_tests }} @@ -51,6 +52,7 @@ jobs: else echo "::set-output name=should_run_tests::true" fi + release-candidate-deploy: name: Deploy Release candidate for release branches needs: @@ -60,6 +62,7 @@ jobs: env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SHOULD_RUN_TEST: ${{needs.determine-should-run-tests.outputs.should_run_tests}} steps: - uses: actions/checkout@v4 with: @@ -85,11 +88,12 @@ jobs: git config --global commit.gpgsign true echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} + - if: ${{ !env.SHOULD_RUN_TEST }} name: Publish Release run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} + run-test: - name: ${{matrix.tests.name}} / ${{matrix.tests.type}} / ${{matrix.tests.syntax}} / ${{matrix.tests.api}} / ${{matrix.azle_source}} + name: '${{matrix.tests.name}} | ${{matrix.tests.type}} | ${{matrix.tests.syntax}} | ${{matrix.tests.api}} | ${{matrix.azle_source}}' needs: - determine-should-run-tests - generate-tests @@ -99,6 +103,7 @@ jobs: AZLE_IDENTITY_STORAGE_MODE: 'plaintext' AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }} AZLE_TEST_RUN_ON_RELEASE: ${{ contains(github.head_ref, 'release--') }} + SHOULD_RUN_TEST: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} strategy: fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest matrix: @@ -118,13 +123,13 @@ jobs: # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + - if: ${{ env.SHOULD_RUN_TEST }} uses: actions/checkout@v4 - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + - if: ${{ env.SHOULD_RUN_TEST }} uses: actions/setup-node@v4 with: node-version: 20 - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + - if: ${{ env.SHOULD_RUN_TEST }} name: Run Pre-Test Azle Setup run: | @@ -149,7 +154,7 @@ jobs: npm run lint shell: bash -l {0} - - if: ${{needs.determine-should-run-tests.outputs.should_run_tests}} + - if: ${{env.SHOULD_RUN_TEST}} name: Run Pre-Test Test Setup run: | @@ -164,11 +169,11 @@ jobs: npx azle install-dfx-extension working-directory: ${{ matrix.tests.path }} shell: bash -l {0} - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + - if: ${{ env.SHOULD_RUN_TEST }} name: Start dfx working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + - if: ${{ env.SHOULD_RUN_TEST }} name: Run Test run: | BRANCH_NAME="${{ github.head_ref }}" From e03f5acc83d0d43c7e5417073f0bf893bc5720db Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 12:18:33 -0600 Subject: [PATCH 19/58] add report of full path of tests just incase it isn't obvious from the name --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6341377072..82ba2ad902 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -123,6 +123,9 @@ jobs: # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: + - if: ${{env.SHOULD_RUN_TEST}} + name: Report full path of test + run: echo ${{matrix.tests.path}} - if: ${{ env.SHOULD_RUN_TEST }} uses: actions/checkout@v4 - if: ${{ env.SHOULD_RUN_TEST }} From 45273a642e8af602f94c49133206a325178eef0e Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 14:54:49 -0600 Subject: [PATCH 20/58] update yml to use new outputs --- .github/scripts/generate_tests.sh | 25 ++++++------------------- .github/workflows/test.yml | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/.github/scripts/generate_tests.sh b/.github/scripts/generate_tests.sh index 03a31c3013..8b58dcac2a 100755 --- a/.github/scripts/generate_tests.sh +++ b/.github/scripts/generate_tests.sh @@ -69,32 +69,19 @@ generate_json() { # Construct JSON object echo "{" - echo " \"path\": \"$dir\"," - echo " \"name\": \"$name\"," - echo " \"type\": \"$type\"" - [[ -n "$syntax" ]] && echo " ,\"syntax\": \"$syntax\"" - [[ -n "$api" ]] && echo " ,\"api\": \"$api\"" + echo "\"path\":\"$dir\"," + echo "\"name\":\"$name\"," + echo "\"type\":\"$type\"" + [[ -n "$syntax" ]] && echo ",\"syntax\":\"$syntax\"" + [[ -n "$api" ]] && echo ",\"api\":\"$api\"" echo "}" } -generate_json_new() { - local dir=$1 - local name=$(basename "$dir") - echo "{path: \"$dir\", name: \"$name\""} -} - # Discover directories in examples and tests, excluding specified directories all_directories=$(discover_directories "$EXAMPLES_DIR") all_directories+=$'\n' all_directories+=$(discover_directories "$TESTS_DIR") -# EXAMPLE_DIRECTORIES=$(cat << END -# "HERE/hello_world", -# "HERE/hello_world2", -# "HERE/hello_world3" -# END -# ) - # Initialize an empty variable to store the JSON result json_result="[" @@ -108,7 +95,7 @@ done <<< "$(echo "$all_directories" | sort)" # Feed sorted directories into the # Remove the last comma and close the JSON array json_result=$(echo "$json_result" | sed '$ s/,$//') -# json_result=$(echo "$json_result" | sed ':a;N;$!ba;s/\n//g') # Remove new lines +json_result=$(echo "$json_result" | sed ':a;N;$!ba;s/\n//g') # Remove new lines json_result+="]" # Store the result in a variable (you can use it as needed) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82ba2ad902..00ed9a60ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,9 +30,9 @@ jobs: all_tests: ${{ steps.get_all_tests.outputs.all_tests }} steps: - uses: actions/checkout@v4 - - id: get_all_tests - name: Generate Tests - run: echo "::set-output name=all_tests::$(./.github/scripts/generate_tests.sh | base64 -d)" + - name: Generate Tests + id: get_all_tests + run: echo "all_tests=$(./.github/scripts/generate_tests.sh | base64 -d)" >> "$GITHUB_OUTPUT" determine-should-run-tests: name: Determine If Tests Should Run @@ -46,11 +46,18 @@ jobs: BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - if [[ "${{ contains(github.head_ref, 'release--') }}" == "true" && "$COMMIT_MESSAGE" != "azle-bot automated release $RELEASE_VERSION" ]] - then - echo "::set-output name=should_run_tests::false" + + IS_RELEASE_CANDIDATE="${{ contains(github.head_ref, 'release--') }}" + + IS_AUTOMATED_RELEASE="false" + if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then + IS_AUTOMATED_RELEASE="true" + fi + + if [[ "$IS_RELEASE_CANDIDATE" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then + echo "should_run_tests=false" >> "$GITHUB_OUTPUT" else - echo "::set-output name=should_run_tests::true" + echo "should_run_tests=true" >> "$GITHUB_OUTPUT" fi release-candidate-deploy: From 8127bd47db45b5d8a697ba72cb01ae629efc8076 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 16:03:14 -0600 Subject: [PATCH 21/58] move out conditionals to top levels --- .github/workflows/test.yml | 112 ++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00ed9a60ed..0cb84fed11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,20 +1,7 @@ -# TODO the next great simplification might be deploying multiple examples to one dfx replica instance: https://forum.dfinity.org/t/use-the-same-local-replica-for-multiple-projects/11900 -# TODO this might allow us to avoid spinning up so many jobs in the matrix - # This GitHub Action flow works as follows: -# The tests are currently simple example-based integration tests. -# Each directory in the examples directory represents an example project and is intended to have tests that ensure the canisters contained in that example function properly. +# Each directory in the examples and tests directory represents an example project and is intended to have tests that ensure the canisters contained in that example function properly. # These tests are currently written in TypeScript and are intended to be run in a Node.js environment. # This GitHub Action takes care of deploying to npm and GitHub. -# Tests can either run against the current code of Azle found in the repository, or the code deployed by the GitHub Action to npm. -# Feature branch pull requests (pull requests without release-- in the base branch name) will run all tests against the code found in the repository. -# Release branch pull requests (pull requests with release-- in the base branch name) will run all tests against the code found in the repository and the code deployed by the GitHub Action to npm. -# Pushes to main will run all tests against the code in the repository if the latest commit was not a merge of a release branch, and will run tests against the code in the repository and the code deployed by the GitHub Action to npm otherwise. -# The run-test matrix spins up one job per combination of example directory and code source (repo or npm). -# The check-run-test-success job is designed to ensure that all jobs spun up from the matrix in the run-test have succeeded - -## TODO make variable for isRelease -## TODO make sure comments are throughout and not all at the top name: Tests on: @@ -22,6 +9,8 @@ on: branches: - main pull_request: # Runs on pull requests to any branch +env: + IS_RELEASE_CANDIDATE: ${{ contains(github.head_ref, 'release--') }} jobs: generate-tests: name: Generate Tests @@ -32,6 +21,7 @@ jobs: - uses: actions/checkout@v4 - name: Generate Tests id: get_all_tests + # Automatically find all azle tests run: echo "all_tests=$(./.github/scripts/generate_tests.sh | base64 -d)" >> "$GITHUB_OUTPUT" determine-should-run-tests: @@ -42,6 +32,7 @@ jobs: steps: - uses: actions/checkout@v4 - id: determine_should_run_tests + # Determine if tests should run for this pr. If it's a manually submitted release candidate no tests will run. run: | BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" @@ -54,14 +45,16 @@ jobs: IS_AUTOMATED_RELEASE="true" fi - if [[ "$IS_RELEASE_CANDIDATE" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then + if [[ "${{env.IS_RELEASE_CANDIDATE}}" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then echo "should_run_tests=false" >> "$GITHUB_OUTPUT" else echo "should_run_tests=true" >> "$GITHUB_OUTPUT" fi release-candidate-deploy: - name: Deploy Release candidate for release branches + name: Deploy Release Candidate for Release Branches + # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested + if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} needs: - generate-tests - determine-should-run-tests @@ -69,11 +62,10 @@ jobs: env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SHOULD_RUN_TEST: ${{needs.determine-should-run-tests.outputs.should_run_tests}} steps: - uses: actions/checkout@v4 with: - ref: ${{ contains(github.head_ref, 'release--') && github.event.pull_request.head.ref || github.ref }} + ref: ${{ github.event.pull_request.head.ref || github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - uses: actions/setup-node@v4 with: @@ -81,39 +73,40 @@ jobs: registry-url: https://registry.npmjs.org env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - if: contains(github.head_ref, 'release--') - name: Install dfx + - name: Install dfx run: | DFXVM_INIT_YES=true DFX_VERSION=0.21.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH # TODO we should use some Action-specific bot account - - if: contains(github.head_ref, 'release--') - name: Configure git for Publishing Release + - name: Configure git for Publishing Release run: | git config --global user.name 'Jordan Last' git config --global user.email 'jordan.michael.last@gmail.com' git config --global commit.gpgsign true echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - - if: ${{ !env.SHOULD_RUN_TEST }} - name: Publish Release + - name: Publish Release run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} run-test: + # Tests can either run against the current code of Azle found in the repository, or the code deployed by the GitHub Action to npm. + # Feature branch pull requests (pull requests without release-- in the base branch name) will run all tests against the code found in the repository. + # Release branch pull requests (pull requests with release-- in the base branch name) will run all tests against the code found in the repository and the code deployed by the GitHub Action to npm. + # Pushes to main will run all tests against the code in the repository if the latest commit was not a merge of a release branch, and will run tests against the code in the repository and the code deployed by the GitHub Action to npm otherwise. name: '${{matrix.tests.name}} | ${{matrix.tests.type}} | ${{matrix.tests.syntax}} | ${{matrix.tests.api}} | ${{matrix.azle_source}}' needs: - determine-should-run-tests - generate-tests + if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} runs-on: ${{ matrix.os }} env: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} AZLE_IDENTITY_STORAGE_MODE: 'plaintext' AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }} AZLE_TEST_RUN_ON_RELEASE: ${{ contains(github.head_ref, 'release--') }} - SHOULD_RUN_TEST: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} strategy: fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest - matrix: + matrix: # spins up one job per combination of test and code source (repo or npm). # os: [macos-latest] os: [ubuntu-latest] include_npm: @@ -130,17 +123,16 @@ jobs: # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} steps: - - if: ${{env.SHOULD_RUN_TEST}} - name: Report full path of test + - name: Report full path of test run: echo ${{matrix.tests.path}} - - if: ${{ env.SHOULD_RUN_TEST }} - uses: actions/checkout@v4 - - if: ${{ env.SHOULD_RUN_TEST }} - uses: actions/setup-node@v4 + + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 with: node-version: 20 - - if: ${{ env.SHOULD_RUN_TEST }} - name: Run Pre-Test Azle Setup + + - name: Run Pre-Test Azle Setup run: | # Install dfx @@ -152,39 +144,32 @@ jobs: sudo networksetup -setdnsservers Ethernet 9.9.9.9 fi - # Install dependencies npm install - # Link azle if the source is repo if [[ "${{ matrix.azle_source }}" == "repo" ]]; then npm link fi - # Run linting npm run lint - shell: bash -l {0} - - if: ${{env.SHOULD_RUN_TEST}} - name: Run Pre-Test Test Setup - run: | + - name: Run Pre-Test Test Setup + run: | npm install - # Link azle in the test directory if the source is repo if [[ "${{ matrix.azle_source }}" == "repo" ]]; then npm link azle fi - # Install the azle dfx extension npx azle install-dfx-extension working-directory: ${{ matrix.tests.path }} shell: bash -l {0} - - if: ${{ env.SHOULD_RUN_TEST }} - name: Start dfx + + - name: Start dfx working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - - if: ${{ env.SHOULD_RUN_TEST }} - name: Run Test + + - name: Run Test run: | BRANCH_NAME="${{ github.head_ref }}" MAIN_BRANCH='refs/heads/main' @@ -193,12 +178,36 @@ jobs: RELEASE_PR_MERGE_MSG='Merge pull request' RELEASE_REPO_MSG='demergent-labs/release--' + IS_FEATURE_PR=true + IS_RELEASE_PR=false + IS_MERGE_TO_MAIN_FROM_RELEASE=false + + # Check if it's a feature pull request if [[ $BRANCH_NAME != *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then - RUNS=5 - elif [[ $BRANCH_NAME == *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then - RUNS=10 - elif [[ ${{ github.ref }} == "$MAIN_BRANCH" && $COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"* ]]; then + IS_FEATURE_PR=true + else + IS_FEATURE_PR=false + fi + + # Check if it's a release candidate pull request + if [[ $BRANCH_NAME == *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then + IS_RELEASE_PR=true + else + IS_RELEASE_PR=false + fi + + # Check if it's a merge from a release candidate into main + if [[ ${{ github.ref }} == "$MAIN_BRANCH" && $COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"* ]]; then + IS_MERGE_TO_MAIN_FROM_RELEASE=true + else + IS_MERGE_TO_MAIN_FROM_RELEASE=false + fi + + # Determine the number of runs based on the conditions + if [[ $IS_MERGE_TO_MAIN_FROM_RELEASE == true ]]; then RUNS=100 + elif [[ $IS_RELEASE_PR == true ]]; then + RUNS=10 else RUNS=5 fi @@ -207,6 +216,7 @@ jobs: shell: bash -l {0} working-directory: ${{ matrix.tests.path }} + # These final jobs are designed to ensure that all jobs spun up from the matrix in the run-test have succeeded check-basic-integration-test-success: name: Check Azle Tests Succeeded needs: run-test From 1b24bb62bb54a8c4cc548194284ce1d1529140be Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 21:35:15 -0600 Subject: [PATCH 22/58] get rid of artificial delay for feature prs --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0cb84fed11..d080f22c6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -166,6 +166,12 @@ jobs: shell: bash -l {0} - name: Start dfx + if: ${{ !env.IS_RELEASE_CANDIDATE }} + working-directory: ${{ matrix.tests.path }} + run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 + + - name: Start dfx with artifical delay + if: ${{ env.IS_RELEASE_CANDIDATE }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 From 2c51bbaddea9656f8ebe442e76d0aadf6c757651 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 28 Aug 2024 22:02:47 -0600 Subject: [PATCH 23/58] move versions to env variables --- .github/workflows/test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d080f22c6a..990f692324 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,8 @@ on: pull_request: # Runs on pull requests to any branch env: IS_RELEASE_CANDIDATE: ${{ contains(github.head_ref, 'release--') }} + DFX_VERSION: 0.21.0 + NODE_VERSION: 20 jobs: generate-tests: name: Generate Tests @@ -69,13 +71,13 @@ jobs: token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: ${{ env.NODE_VERSION }} registry-url: https://registry.npmjs.org env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Install dfx run: | - DFXVM_INIT_YES=true DFX_VERSION=0.21.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" + DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH # TODO we should use some Action-specific bot account - name: Configure git for Publishing Release @@ -136,7 +138,7 @@ jobs: run: | # Install dfx - DFXVM_INIT_YES=true DFX_VERSION=0.21.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" + DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH # MacOS-specific DNS configuration From e76c4feb7cd2ad92ecf18acde22151d5c3686f17 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 10:00:03 -0600 Subject: [PATCH 24/58] create custom action for finding test dirs --- .github/actions/generate_tests/action.yml | 29 +++++++++++++++++++++++ .github/scripts/generate_tests.sh | 29 ++++++++++------------- .github/workflows/test.yml | 25 +++++++++++++++---- 3 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 .github/actions/generate_tests/action.yml diff --git a/.github/actions/generate_tests/action.yml b/.github/actions/generate_tests/action.yml new file mode 100644 index 0000000000..cf9e54547d --- /dev/null +++ b/.github/actions/generate_tests/action.yml @@ -0,0 +1,29 @@ +name: Generate Tests +description: Generates a list of directories of npm projects with a tests script +inputs: + directories: + description: List of directories to search for npm projects with tests. + required: true + exclude_dirs: + description: List of directories to exclude from the search. + required: false + default: '' +outputs: + all_tests: + description: All of the tests found by this action + value: ${{ steps.get_all_tests.outputs.all_tests }} +runs: + using: composite + steps: + - uses: actions/checkout@v4 + + - name: Generate Tests + id: get_all_tests + run: | + # Export the input variables to make them available to the script + export INPUT_DIRECTORIES="${{ inputs.directories }}" + export INPUT_EXCLUDE_DIRS="${{ inputs.exclude_dirs }}" + # Run the script + all_tests=$(./.github/scripts/generate_tests.sh | base64 -d) + echo "all_tests=${all_tests}" >> "$GITHUB_OUTPUT" + shell: bash diff --git a/.github/scripts/generate_tests.sh b/.github/scripts/generate_tests.sh index 8b58dcac2a..a68c597b09 100755 --- a/.github/scripts/generate_tests.sh +++ b/.github/scripts/generate_tests.sh @@ -1,15 +1,9 @@ #!/bin/bash -# Base directories +# Inputs from action.yml BASE_DIR="." -EXAMPLES_DIR="$BASE_DIR/examples" -TESTS_DIR="$BASE_DIR/tests" - -# Excluded directories -EXCLUDE_DIRS=( - "$EXAMPLES_DIR/filter_example" - "$TESTS_DIR/end_to_end/candid_rpc/functional_syntax/filter_example" -) +DIRECTORIES=($INPUT_DIRECTORIES) +EXCLUDE_DIRS=($INPUT_EXCLUDE_DIRS) # Function to discover test directories discover_directories() { @@ -29,7 +23,7 @@ discover_directories() { is_excluded() { local dir=$1 for exclude in "${EXCLUDE_DIRS[@]}"; do - if [[ "$dir" == *"$exclude" ]]; then + if [[ "$dir" == *"$exclude"* ]]; then return 0 fi done @@ -44,9 +38,9 @@ generate_json() { local syntax="" local api="" - if [[ "$dir" == "$EXAMPLES_DIR"* ]]; then + if [[ "$dir" == *"/examples/"* ]]; then type="ex" - elif [[ "$dir" == "$TESTS_DIR/property"* ]]; then + elif [[ "$dir" == *"/property/"* ]]; then type="prop" if [[ "$dir" == *"/candid_rpc/"* ]]; then syntax="crpc" @@ -58,7 +52,7 @@ generate_json() { elif [[ "$dir" == *"/ic_api/"* ]]; then syntax="ic_api" fi - elif [[ "$dir" == "$TESTS_DIR/end_to_end"* ]]; then + elif [[ "$dir" == *"/end_to_end/"* ]]; then type="e2e" if [[ "$dir" == *"/http_server/"* ]]; then syntax="http" @@ -77,10 +71,11 @@ generate_json() { echo "}" } -# Discover directories in examples and tests, excluding specified directories -all_directories=$(discover_directories "$EXAMPLES_DIR") -all_directories+=$'\n' -all_directories+=$(discover_directories "$TESTS_DIR") +# Discover directories in the provided directories, excluding specified directories +all_directories="" +for dir in "${DIRECTORIES[@]}"; do + all_directories+=$(discover_directories "$dir") +done # Initialize an empty variable to store the JSON result json_result="[" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 990f692324..192169466f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,8 @@ # These tests are currently written in TypeScript and are intended to be run in a Node.js environment. # This GitHub Action takes care of deploying to npm and GitHub. +# TODO give every step a name + name: Tests on: push: @@ -11,6 +13,7 @@ on: pull_request: # Runs on pull requests to any branch env: IS_RELEASE_CANDIDATE: ${{ contains(github.head_ref, 'release--') }} + IS_FEATURE: ${{ !contains(github.head_ref, 'release--') }} DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: @@ -23,8 +26,22 @@ jobs: - uses: actions/checkout@v4 - name: Generate Tests id: get_all_tests - # Automatically find all azle tests - run: echo "all_tests=$(./.github/scripts/generate_tests.sh | base64 -d)" >> "$GITHUB_OUTPUT" + uses: ./.github/actions/generate_tests + with: + directories: | + ./examples + ./tests + exclude_dirs: | + ${{ env.IS_FEATURE == 'true' && format(' + ./examples/basic_bitcoin + ./examples/bitcoin_psbt + ./examples/ckbtc + ./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 + ./tests/property/candid_rpc/class_api/stable_b_tree_map + ./tests/property/candid_rpc/functional_api/stable_b_tree_map + ') || '' }} determine-should-run-tests: name: Determine If Tests Should Run @@ -40,8 +57,6 @@ jobs: RELEASE_VERSION="${BRANCH_NAME:9}" COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - IS_RELEASE_CANDIDATE="${{ contains(github.head_ref, 'release--') }}" - IS_AUTOMATED_RELEASE="false" if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then IS_AUTOMATED_RELEASE="true" @@ -132,7 +147,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: ${{ env.NODE_VERSION }} - name: Run Pre-Test Azle Setup run: | From 2434e2a5ac79b6153f81dd80bd95c8205c30eff8 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 10:44:32 -0600 Subject: [PATCH 25/58] first pass at build job --- .github/workflows/build.yml | 89 +++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..1fd2de57d8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,89 @@ +name: Build +on: + push: + branches: + - main + pull_request: # Runs on pull requests to any branch +env: + IS_RELEASE_CANDIDATE: ${{ contains(github.head_ref, 'release--') }} + IS_FEATURE: ${{ !contains(github.head_ref, 'release--') }} + DFX_VERSION: 0.21.0 + NODE_VERSION: 20 +jobs: + generate-tests: + name: Get all test dirs + runs-on: ubuntu-latest + outputs: + all_tests: ${{ steps.get_all_tests.outputs.all_tests }} + steps: + - uses: actions/checkout@v4 + - name: Get all test dirs + id: get_all_tests + uses: ./.github/actions/generate_tests + with: + directories: | + ./examples + ./tests + exclude_dirs: '' + + determine-should-run-tests: + name: Determine If Tests Should Run + runs-on: ubuntu-latest + outputs: + should_run_tests: ${{ steps.determine_should_run_tests.outputs.should_run_tests }} + steps: + - uses: actions/checkout@v4 + - id: determine_should_run_tests + # Determine if tests should run for this pr. If it's a manually submitted release candidate no tests will run. + run: | + BRANCH_NAME="${{ github.head_ref }}" + RELEASE_VERSION="${BRANCH_NAME:9}" + COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") + + IS_AUTOMATED_RELEASE="false" + if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then + IS_AUTOMATED_RELEASE="true" + fi + + if [[ "${{env.IS_RELEASE_CANDIDATE}}" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then + echo "should_run_tests=false" >> "$GITHUB_OUTPUT" + else + echo "should_run_tests=true" >> "$GITHUB_OUTPUT" + fi + + release-candidate-deploy: + name: Deploy Release Candidate for Release Branches + # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested + if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} + needs: + - generate-tests + - determine-should-run-tests + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: https://registry.npmjs.org + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Install dfx + run: | + DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" + echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH + # TODO we should use some Action-specific bot account + - name: Configure git for Publishing Release + run: | + git config --global user.name 'Jordan Last' + git config --global user.email 'jordan.michael.last@gmail.com' + git config --global commit.gpgsign true + echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import + git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 + - name: Publish Release + run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} From 6a1993c5bc389810d5ede71d3e8a5e67d61acc2b Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 12:39:02 -0600 Subject: [PATCH 26/58] move build to it's own workflow --- .github/workflows/build.yml | 25 +++++++++++++------------ .github/workflows/test.yml | 37 ------------------------------------- 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1fd2de57d8..e970140713 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,8 @@ env: DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: - generate-tests: + get-all-test-dirs: + if: ${{ contains(github.head_ref, 'release--') }} name: Get all test dirs runs-on: ubuntu-latest outputs: @@ -26,15 +27,15 @@ jobs: ./tests exclude_dirs: '' - determine-should-run-tests: + determine-is-manual-release: + if: ${{ contains(github.head_ref, 'release--') }} name: Determine If Tests Should Run runs-on: ubuntu-latest outputs: - should_run_tests: ${{ steps.determine_should_run_tests.outputs.should_run_tests }} + is_manual_release: ${{ steps.determine_is_manual_release.outputs.is_manual_release }} steps: - uses: actions/checkout@v4 - - id: determine_should_run_tests - # Determine if tests should run for this pr. If it's a manually submitted release candidate no tests will run. + - id: determine_is_manual_release run: | BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" @@ -45,19 +46,19 @@ jobs: IS_AUTOMATED_RELEASE="true" fi - if [[ "${{env.IS_RELEASE_CANDIDATE}}" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then - echo "should_run_tests=false" >> "$GITHUB_OUTPUT" + if [[ "$IS_AUTOMATED_RELEASE" == "false" ]]; then + echo "is_manual_release=false" >> "$GITHUB_OUTPUT" else - echo "should_run_tests=true" >> "$GITHUB_OUTPUT" + echo "is_manual_release=true" >> "$GITHUB_OUTPUT" fi release-candidate-deploy: name: Deploy Release Candidate for Release Branches # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} + if: ${{ !needs.determine-is-manual-release.outputs.is_manual_release }} needs: - - generate-tests - - determine-should-run-tests + - get-all-test-dirs + - determine-is-manual-release runs-on: ubuntu-latest env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified @@ -86,4 +87,4 @@ jobs: echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - name: Publish Release - run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} + run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-all-test-dirs.outputs.all_tests) }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 192169466f..153dee108a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,43 +68,6 @@ jobs: echo "should_run_tests=true" >> "$GITHUB_OUTPUT" fi - release-candidate-deploy: - name: Deploy Release Candidate for Release Branches - # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested - if: ${{ !needs.determine-should-run-tests.outputs.should_run_tests }} - needs: - - generate-tests - - determine-should-run-tests - runs-on: ubuntu-latest - env: - GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} - token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - registry-url: https://registry.npmjs.org - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Install dfx - run: | - DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" - echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH - # TODO we should use some Action-specific bot account - - name: Configure git for Publishing Release - run: | - git config --global user.name 'Jordan Last' - git config --global user.email 'jordan.michael.last@gmail.com' - git config --global commit.gpgsign true - echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import - git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - - name: Publish Release - run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.generate-tests.outputs.all_tests) }} - run-test: # Tests can either run against the current code of Azle found in the repository, or the code deployed by the GitHub Action to npm. # Feature branch pull requests (pull requests without release-- in the base branch name) will run all tests against the code found in the repository. From 35954b936d60661f8e79167ccac7adf175d10577 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 15:10:51 -0600 Subject: [PATCH 27/58] file clean up --- scripts/just-paths.sh | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100755 scripts/just-paths.sh diff --git a/scripts/just-paths.sh b/scripts/just-paths.sh deleted file mode 100755 index 32026a932a..0000000000 --- a/scripts/just-paths.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -EXAMPLE_DIRECTORIES=$(cat << END -[ - {path: "HERE/hello_world", name: "basic_bitcoin", type: "ex"}, - {path: "HERE/hello_world2", name: "large_files", type: "e2e", "syntax": "http"}, - {path: "HERE/hello_world3", name: "bool", type: "prop", "syntax": "crpc", "api": "class"} -] -END -) -EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//'%'/'%25'}" -EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\n'/'%0A'}" -EXAMPLE_DIRECTORIES="${EXAMPLE_DIRECTORIES//$'\r'/'%0D'}" - -echo "$EXAMPLE_DIRECTORIES" | base64 From 45c87d74005f1f981faf879f1d447ce2e2f9448d Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 15:11:08 -0600 Subject: [PATCH 28/58] try object filtering --- .github/scripts/publish_github_action.sh | 2 +- .github/workflows/build.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/publish_github_action.sh b/.github/scripts/publish_github_action.sh index b3e7269066..7972b53127 100755 --- a/.github/scripts/publish_github_action.sh +++ b/.github/scripts/publish_github_action.sh @@ -8,7 +8,7 @@ VERSION=$1 directories_json_string_with_linebreaks=$2 directories_json_string="${directories_json_string_with_linebreaks//$'\\n'/''}" -directories=$(echo "$directories_json_string" | jq -c -r '.[] | .path') +directories=$(echo "$directories_json_string" | jq -c -r '.[]') sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" package.json sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" dfx_extension/extension.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e970140713..db326d6d99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,4 +87,4 @@ jobs: echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - name: Publish Release - run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-all-test-dirs.outputs.all_tests) }} + run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-all-test-dirs.outputs.all_tests).*.path }} From 35932382b8c47279041c532e90ce5d04f34ac624 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 16:28:32 -0600 Subject: [PATCH 29/58] pr fixes --- .github/actions/generate_tests/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/generate_tests/action.yml b/.github/actions/generate_tests/action.yml index cf9e54547d..cf7bd0af3c 100644 --- a/.github/actions/generate_tests/action.yml +++ b/.github/actions/generate_tests/action.yml @@ -1,11 +1,11 @@ name: Generate Tests -description: Generates a list of directories of npm projects with a tests script +description: Generates a list of directories of npm projects with an npm test script inputs: directories: - description: List of directories to search for npm projects with tests. + description: List of directories to search for npm projects with tests required: true exclude_dirs: - description: List of directories to exclude from the search. + description: List of directories to exclude from the search required: false default: '' outputs: From 2a2d8c0287381aa74b8ca34564ba305454c5e973 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 16:28:44 -0600 Subject: [PATCH 30/58] pr fixes --- .github/workflows/build.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db326d6d99..fcef115040 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: Deploy release candidate on: push: branches: @@ -25,11 +25,10 @@ jobs: directories: | ./examples ./tests - exclude_dirs: '' determine-is-manual-release: if: ${{ contains(github.head_ref, 'release--') }} - name: Determine If Tests Should Run + name: Determine if tests should run runs-on: ubuntu-latest outputs: is_manual_release: ${{ steps.determine_is_manual_release.outputs.is_manual_release }} @@ -53,7 +52,7 @@ jobs: fi release-candidate-deploy: - name: Deploy Release Candidate for Release Branches + name: Deploy release candidate for release branches # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested if: ${{ !needs.determine-is-manual-release.outputs.is_manual_release }} needs: @@ -79,12 +78,12 @@ jobs: DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH # TODO we should use some Action-specific bot account - - name: Configure git for Publishing Release + - name: Configure git for publishing release run: | git config --global user.name 'Jordan Last' git config --global user.email 'jordan.michael.last@gmail.com' git config --global commit.gpgsign true echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - - name: Publish Release + - name: Publish release run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-all-test-dirs.outputs.all_tests).*.path }} From 006a615ce36d3ed21c67138243ba53344dbcce87 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 16:34:41 -0600 Subject: [PATCH 31/58] better wording in action --- .github/actions/generate_tests/action.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/actions/generate_tests/action.yml b/.github/actions/generate_tests/action.yml index cf7bd0af3c..0afd7219ef 100644 --- a/.github/actions/generate_tests/action.yml +++ b/.github/actions/generate_tests/action.yml @@ -1,29 +1,29 @@ -name: Generate Tests +name: Generate tests description: Generates a list of directories of npm projects with an npm test script inputs: directories: - description: List of directories to search for npm projects with tests + description: List of directories to search for npm projects with an npm test script required: true exclude_dirs: description: List of directories to exclude from the search required: false default: '' outputs: - all_tests: + tests: description: All of the tests found by this action - value: ${{ steps.get_all_tests.outputs.all_tests }} + value: ${{ steps.get_tests.outputs.tests }} runs: using: composite steps: - uses: actions/checkout@v4 - - name: Generate Tests - id: get_all_tests + - name: Generate tests + id: get_tests run: | # Export the input variables to make them available to the script export INPUT_DIRECTORIES="${{ inputs.directories }}" export INPUT_EXCLUDE_DIRS="${{ inputs.exclude_dirs }}" # Run the script - all_tests=$(./.github/scripts/generate_tests.sh | base64 -d) - echo "all_tests=${all_tests}" >> "$GITHUB_OUTPUT" + tests=$(./.github/scripts/generate_tests.sh | base64 -d) + echo "tests=${tests}" >> "$GITHUB_OUTPUT" shell: bash From 96a37f5f91c21dbc2d59973cce4c2f149d84bd6c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 16:38:10 -0600 Subject: [PATCH 32/58] naming updates --- .github/workflows/build.yml | 2 +- .github/workflows/test.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fcef115040..0344e6d32f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: determine-is-manual-release: if: ${{ contains(github.head_ref, 'release--') }} - name: Determine if tests should run + name: Determine if this job is for a manual release runs-on: ubuntu-latest outputs: is_manual_release: ${{ steps.determine_is_manual_release.outputs.is_manual_release }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 153dee108a..918f75a952 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,13 +18,13 @@ env: NODE_VERSION: 20 jobs: generate-tests: - name: Generate Tests + name: Generate tests runs-on: ubuntu-latest outputs: all_tests: ${{ steps.get_all_tests.outputs.all_tests }} steps: - uses: actions/checkout@v4 - - name: Generate Tests + - name: Generate tests id: get_all_tests uses: ./.github/actions/generate_tests with: @@ -44,7 +44,7 @@ jobs: ') || '' }} determine-should-run-tests: - name: Determine If Tests Should Run + name: Determine if tests should run runs-on: ubuntu-latest outputs: should_run_tests: ${{ steps.determine_should_run_tests.outputs.should_run_tests }} From d95051ff8da1e0f57a7ffbcde0f77c635bfad240 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 16:42:11 -0600 Subject: [PATCH 33/58] get rid of unused var --- .github/scripts/generate_tests.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/scripts/generate_tests.sh b/.github/scripts/generate_tests.sh index a68c597b09..c8bab2c67f 100755 --- a/.github/scripts/generate_tests.sh +++ b/.github/scripts/generate_tests.sh @@ -1,7 +1,6 @@ #!/bin/bash # Inputs from action.yml -BASE_DIR="." DIRECTORIES=($INPUT_DIRECTORIES) EXCLUDE_DIRS=($INPUT_EXCLUDE_DIRS) From fe2c5a62b3f6a0d3c2c42015ef624568449feaf2 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 17:03:43 -0600 Subject: [PATCH 34/58] pr fixes --- .github/workflows/build.yml | 16 ++++++++++------ .github/workflows/test.yml | 16 +++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0344e6d32f..06a1c69f41 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,16 +10,16 @@ env: DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: - get-all-test-dirs: + get-tests: if: ${{ contains(github.head_ref, 'release--') }} - name: Get all test dirs + name: Get tests runs-on: ubuntu-latest outputs: - all_tests: ${{ steps.get_all_tests.outputs.all_tests }} + tests: ${{ steps.get_tests.outputs.tests }} steps: - uses: actions/checkout@v4 - name: Get all test dirs - id: get_all_tests + id: get_tests uses: ./.github/actions/generate_tests with: directories: | @@ -56,7 +56,7 @@ jobs: # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested if: ${{ !needs.determine-is-manual-release.outputs.is_manual_release }} needs: - - get-all-test-dirs + - get-tests - determine-is-manual-release runs-on: ubuntu-latest env: @@ -67,16 +67,19 @@ jobs: with: ref: ${{ github.event.pull_request.head.ref || github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} + - uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} registry-url: https://registry.npmjs.org env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Install dfx run: | DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH + # TODO we should use some Action-specific bot account - name: Configure git for publishing release run: | @@ -85,5 +88,6 @@ jobs: git config --global commit.gpgsign true echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --import git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 + - name: Publish release - run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-all-test-dirs.outputs.all_tests).*.path }} + run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests).*.path }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 918f75a952..e4a1192604 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,15 +17,16 @@ env: DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: - generate-tests: - name: Generate tests + get-tests: + name: Get tests runs-on: ubuntu-latest outputs: - all_tests: ${{ steps.get_all_tests.outputs.all_tests }} + tests: ${{ steps.get_tests.outputs.tests }} steps: - uses: actions/checkout@v4 - - name: Generate tests - id: get_all_tests + + - name: Get tests + id: get_tests uses: ./.github/actions/generate_tests with: directories: | @@ -50,6 +51,7 @@ jobs: should_run_tests: ${{ steps.determine_should_run_tests.outputs.should_run_tests }} steps: - uses: actions/checkout@v4 + - id: determine_should_run_tests # Determine if tests should run for this pr. If it's a manually submitted release candidate no tests will run. run: | @@ -76,7 +78,7 @@ jobs: name: '${{matrix.tests.name}} | ${{matrix.tests.type}} | ${{matrix.tests.syntax}} | ${{matrix.tests.api}} | ${{matrix.azle_source}}' needs: - determine-should-run-tests - - generate-tests + - get-tests if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} runs-on: ${{ matrix.os }} env: @@ -101,7 +103,7 @@ jobs: - include_npm: true azle_source: repo # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element - tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.generate-tests.outputs.all_tests) || fromJSON('["dummy"]') }} + tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.get-tests.outputs.tests) || fromJSON('["dummy"]') }} steps: - name: Report full path of test run: echo ${{matrix.tests.path}} From 3ff7ef183805bafa0a5139f7c3596fa2e1d2e425 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 09:18:57 -0600 Subject: [PATCH 35/58] make sure empty all_directories leads to empty result --- .github/scripts/generate_tests.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/scripts/generate_tests.sh b/.github/scripts/generate_tests.sh index c8bab2c67f..3bde851a58 100755 --- a/.github/scripts/generate_tests.sh +++ b/.github/scripts/generate_tests.sh @@ -79,13 +79,21 @@ done # Initialize an empty variable to store the JSON result json_result="[" -# Sort, filter, and generate JSON objects -while read -r dir; do - if ! is_excluded "$dir"; then - json_result+=$(generate_json "$dir") - json_result+="," - fi -done <<< "$(echo "$all_directories" | sort)" # Feed sorted directories into the loop +if [[ -n "$all_directories" ]]; then # Check if all_directories is not an empty string + while read -r dir; do + if [[ -n "$dir" ]]; then # Check if dir is not an empty string + echo "This is the dir" >&2 + echo "$dir" >&2 + if ! is_excluded "$dir"; then + json_result+=$(generate_json "$dir") + json_result+="," + fi + fi + done <<< "$(echo "$all_directories" | sort)" # Feed sorted directories into the loop + + # Remove the trailing comma from the json_result, if necessary + json_result="${json_result%,}" +fi # Remove the last comma and close the JSON array json_result=$(echo "$json_result" | sed '$ s/,$//') From c410511b4c4ba0c11b8ff09b9b4dbbb340845e58 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 09:23:04 -0600 Subject: [PATCH 36/58] fix capitalization --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4a1192604..526eecee19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -135,7 +135,7 @@ jobs: npm run lint shell: bash -l {0} - - name: Run Pre-Test Test Setup + - name: Run pre-test setup run: | npm install @@ -157,7 +157,7 @@ jobs: working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - - name: Run Test + - name: Run test run: | BRANCH_NAME="${{ github.head_ref }}" MAIN_BRANCH='refs/heads/main' @@ -206,7 +206,7 @@ jobs: # These final jobs are designed to ensure that all jobs spun up from the matrix in the run-test have succeeded check-basic-integration-test-success: - name: Check Azle Tests Succeeded + name: Check Azle tests succeeded needs: run-test runs-on: ubuntu-latest if: success() @@ -214,7 +214,7 @@ jobs: - run: exit 0 check-basic-integration-test-failure: - name: Check Azle Tests Didn't Fail + name: Check Azle tests didn't fail needs: run-test runs-on: ubuntu-latest if: failure() From c30465180000a3a3dddc4d9266993c4c7b5d9436 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 09:31:30 -0600 Subject: [PATCH 37/58] rename generate_tests --- .github/actions/{generate_tests => get_tests}/action.yml | 8 ++++---- .github/scripts/{generate_tests.sh => get_tests.sh} | 0 .github/workflows/build.yml | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename .github/actions/{generate_tests => get_tests}/action.yml (80%) rename .github/scripts/{generate_tests.sh => get_tests.sh} (100%) diff --git a/.github/actions/generate_tests/action.yml b/.github/actions/get_tests/action.yml similarity index 80% rename from .github/actions/generate_tests/action.yml rename to .github/actions/get_tests/action.yml index 0afd7219ef..d6a1391ccc 100644 --- a/.github/actions/generate_tests/action.yml +++ b/.github/actions/get_tests/action.yml @@ -1,5 +1,5 @@ -name: Generate tests -description: Generates a list of directories of npm projects with an npm test script +name: Get tests +description: Gets a list of directories of npm projects with an npm test script inputs: directories: description: List of directories to search for npm projects with an npm test script @@ -17,13 +17,13 @@ runs: steps: - uses: actions/checkout@v4 - - name: Generate tests + - name: Get tests id: get_tests run: | # Export the input variables to make them available to the script export INPUT_DIRECTORIES="${{ inputs.directories }}" export INPUT_EXCLUDE_DIRS="${{ inputs.exclude_dirs }}" # Run the script - tests=$(./.github/scripts/generate_tests.sh | base64 -d) + tests=$(./.github/scripts/get_tests.sh | base64 -d) echo "tests=${tests}" >> "$GITHUB_OUTPUT" shell: bash diff --git a/.github/scripts/generate_tests.sh b/.github/scripts/get_tests.sh similarity index 100% rename from .github/scripts/generate_tests.sh rename to .github/scripts/get_tests.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06a1c69f41..7cef006a2a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: Get all test dirs id: get_tests - uses: ./.github/actions/generate_tests + uses: ./.github/actions/get_tests with: directories: | ./examples diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 526eecee19..b6aaf50a3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Get tests id: get_tests - uses: ./.github/actions/generate_tests + uses: ./.github/actions/get_tests with: directories: | ./examples From b4e9f2c801a15187ee1a0c52b4d24fd30aaadd85 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 09:42:47 -0600 Subject: [PATCH 38/58] variable clean up --- .github/workflows/build.yml | 22 ++++++++-------------- .github/workflows/test.yml | 18 +++++++++--------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7cef006a2a..7f793f4079 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,6 @@ on: - main pull_request: # Runs on pull requests to any branch env: - IS_RELEASE_CANDIDATE: ${{ contains(github.head_ref, 'release--') }} - IS_FEATURE: ${{ !contains(github.head_ref, 'release--') }} DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: @@ -26,38 +24,34 @@ jobs: ./examples ./tests - determine-is-manual-release: + determine-should-release: if: ${{ contains(github.head_ref, 'release--') }} name: Determine if this job is for a manual release runs-on: ubuntu-latest outputs: - is_manual_release: ${{ steps.determine_is_manual_release.outputs.is_manual_release }} + should_release: ${{ steps.determine_should_release.outputs.should_release }} steps: - uses: actions/checkout@v4 - - id: determine_is_manual_release + - id: determine_should_release run: | BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - IS_AUTOMATED_RELEASE="false" + SHOULD_RELEASE="false" if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then - IS_AUTOMATED_RELEASE="true" + SHOULD_RELEASE="true" fi - if [[ "$IS_AUTOMATED_RELEASE" == "false" ]]; then - echo "is_manual_release=false" >> "$GITHUB_OUTPUT" - else - echo "is_manual_release=true" >> "$GITHUB_OUTPUT" - fi + echo "should_release=${SHOULD_RELEASE}" >> "$GITHUB_OUTPUT" release-candidate-deploy: name: Deploy release candidate for release branches # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested - if: ${{ !needs.determine-is-manual-release.outputs.is_manual_release }} + if: ${{ !needs.determine-should-release.outputs.should_release }} needs: - get-tests - - determine-is-manual-release + - determine-should-release runs-on: ubuntu-latest env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6aaf50a3f..7f810ba797 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,8 +12,8 @@ on: - main pull_request: # Runs on pull requests to any branch env: - IS_RELEASE_CANDIDATE: ${{ contains(github.head_ref, 'release--') }} - IS_FEATURE: ${{ !contains(github.head_ref, 'release--') }} + IS_RELEASE: ${{ contains(github.head_ref, 'release--') }} + IS_FEATURE_BRANCH_PR: ${{ !contains(github.head_ref, 'release--') }} DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: @@ -33,7 +33,7 @@ jobs: ./examples ./tests exclude_dirs: | - ${{ env.IS_FEATURE == 'true' && format(' + ${{ env.IS_FEATURE_BRANCH_PR == 'true' && format(' ./examples/basic_bitcoin ./examples/bitcoin_psbt ./examples/ckbtc @@ -64,7 +64,7 @@ jobs: IS_AUTOMATED_RELEASE="true" fi - if [[ "${{env.IS_RELEASE_CANDIDATE}}" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then + if [[ "${{env.IS_RELEASE}}" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then echo "should_run_tests=false" >> "$GITHUB_OUTPUT" else echo "should_run_tests=true" >> "$GITHUB_OUTPUT" @@ -148,12 +148,12 @@ jobs: shell: bash -l {0} - name: Start dfx - if: ${{ !env.IS_RELEASE_CANDIDATE }} + if: ${{ !env.IS_RELEASE }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - name: Start dfx with artifical delay - if: ${{ env.IS_RELEASE_CANDIDATE }} + if: ${{ env.IS_RELEASE }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 @@ -166,15 +166,15 @@ jobs: RELEASE_PR_MERGE_MSG='Merge pull request' RELEASE_REPO_MSG='demergent-labs/release--' - IS_FEATURE_PR=true + IS_FEATURE_BRANCH_PR_PR=true IS_RELEASE_PR=false IS_MERGE_TO_MAIN_FROM_RELEASE=false # Check if it's a feature pull request if [[ $BRANCH_NAME != *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then - IS_FEATURE_PR=true + IS_FEATURE_BRANCH_PR_PR=true else - IS_FEATURE_PR=false + IS_FEATURE_BRANCH_PR_PR=false fi # Check if it's a release candidate pull request From 8e3dac1c3f57ca97c30d8364fbf1970fd899063e Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 09:42:58 -0600 Subject: [PATCH 39/58] test commit message --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f810ba797..d82acfe1e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,14 @@ env: DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: + test-commit-message: + runs-on: ubuntu-latest + steps: + - run: | + echo "perfered message" + echo \"${{ github.event.head_commit.message }}\" + echo "back up" + $(git log -1 --pretty=format:"%s") get-tests: name: Get tests runs-on: ubuntu-latest From e86a15731e20642ac3d42aeeb16417c1792fb5a5 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 10:12:46 -0600 Subject: [PATCH 40/58] pr fixes --- .github/workflows/build.yml | 2 ++ .github/workflows/test.yml | 16 ---------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f793f4079..d44d648952 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ jobs: tests: ${{ steps.get_tests.outputs.tests }} steps: - uses: actions/checkout@v4 + - name: Get all test dirs id: get_tests uses: ./.github/actions/get_tests @@ -32,6 +33,7 @@ jobs: should_release: ${{ steps.determine_should_release.outputs.should_release }} steps: - uses: actions/checkout@v4 + - id: determine_should_release run: | BRANCH_NAME="${{ github.head_ref }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d82acfe1e3..10c31e070f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,14 +17,6 @@ env: DFX_VERSION: 0.21.0 NODE_VERSION: 20 jobs: - test-commit-message: - runs-on: ubuntu-latest - steps: - - run: | - echo "perfered message" - echo \"${{ github.event.head_commit.message }}\" - echo "back up" - $(git log -1 --pretty=format:"%s") get-tests: name: Get tests runs-on: ubuntu-latest @@ -174,17 +166,9 @@ jobs: RELEASE_PR_MERGE_MSG='Merge pull request' RELEASE_REPO_MSG='demergent-labs/release--' - IS_FEATURE_BRANCH_PR_PR=true IS_RELEASE_PR=false IS_MERGE_TO_MAIN_FROM_RELEASE=false - # Check if it's a feature pull request - if [[ $BRANCH_NAME != *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then - IS_FEATURE_BRANCH_PR_PR=true - else - IS_FEATURE_BRANCH_PR_PR=false - fi - # Check if it's a release candidate pull request if [[ $BRANCH_NAME == *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then IS_RELEASE_PR=true From 3772934514856165fefeae0193a45293a0211744 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 10:13:16 -0600 Subject: [PATCH 41/58] rename build workflow --- .github/workflows/{build.yml => release_candidate_deploy.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{build.yml => release_candidate_deploy.yml} (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/release_candidate_deploy.yml similarity index 100% rename from .github/workflows/build.yml rename to .github/workflows/release_candidate_deploy.yml From e7581083418f2f8135b04548daf7881989378c92 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 10:16:08 -0600 Subject: [PATCH 42/58] rename to release candidate deploy --- .../workflows/{release_candidate_deploy.yml => release.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{release_candidate_deploy.yml => release.yml} (97%) diff --git a/.github/workflows/release_candidate_deploy.yml b/.github/workflows/release.yml similarity index 97% rename from .github/workflows/release_candidate_deploy.yml rename to .github/workflows/release.yml index d44d648952..367ea4a8ee 100644 --- a/.github/workflows/release_candidate_deploy.yml +++ b/.github/workflows/release.yml @@ -47,8 +47,8 @@ jobs: echo "should_release=${SHOULD_RELEASE}" >> "$GITHUB_OUTPUT" - release-candidate-deploy: - name: Deploy release candidate for release branches + release: + name: Deploy release # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested if: ${{ !needs.determine-should-release.outputs.should_release }} needs: From a98b9cacddaf9fc1d9567dcde6a65bc88af1335c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 10:43:28 -0600 Subject: [PATCH 43/58] move should release to it's own action --- .github/actions/should_release/action.yml | 27 +++++++++++++++++++++++ .github/workflows/release.yml | 14 ++---------- .github/workflows/test.yml | 25 +++++---------------- 3 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 .github/actions/should_release/action.yml diff --git a/.github/actions/should_release/action.yml b/.github/actions/should_release/action.yml new file mode 100644 index 0000000000..ccc14e6295 --- /dev/null +++ b/.github/actions/should_release/action.yml @@ -0,0 +1,27 @@ +# TODO I feel like the wording on this is a little clunky and/or ethereal. +# TODO we have is release vs should release and I don't feel like it's clear what the answer is +name: Should release +description: Determines if the current workflow should spawn a something that Jordan can figure out the wording for +outputs: + should_release: + description: Returns true if this branch needs should spawn a something that Jordan can figure out the wording for, otherwise false + value: ${{ steps.determine_should_release.outputs.should_release }} +runs: + using: composite + steps: + - uses: actions/checkout@v4 + + - id: determine_should_release + run: | + BRANCH_NAME="${{ github.head_ref }}" + RELEASE_VERSION="${BRANCH_NAME:9}" + COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") + IS_RELEASE = ${{ contains(github.head_ref, 'release--') }} + + SHOULD_RELEASE="false" + if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then + SHOULD_RELEASE="true" + fi + + echo "should_release=${SHOULD_RELEASE}" >> "$GITHUB_OUTPUT" + shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 367ea4a8ee..a777af6c95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: determine-should-release: if: ${{ contains(github.head_ref, 'release--') }} - name: Determine if this job is for a manual release + name: Determine if this branch should release runs-on: ubuntu-latest outputs: should_release: ${{ steps.determine_should_release.outputs.should_release }} @@ -35,17 +35,7 @@ jobs: - uses: actions/checkout@v4 - id: determine_should_release - run: | - BRANCH_NAME="${{ github.head_ref }}" - RELEASE_VERSION="${BRANCH_NAME:9}" - COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - - SHOULD_RELEASE="false" - if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then - SHOULD_RELEASE="true" - fi - - echo "should_release=${SHOULD_RELEASE}" >> "$GITHUB_OUTPUT" + uses: ./.github/actions/should_release release: name: Deploy release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 10c31e070f..c32178ca6e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,27 +48,14 @@ jobs: name: Determine if tests should run runs-on: ubuntu-latest outputs: - should_run_tests: ${{ steps.determine_should_run_tests.outputs.should_run_tests }} + # If the branch should release then it shouldn't run tests. + should_run_tests: ${{ !steps.determine_should_run_tests.outputs.should_release }} steps: - uses: actions/checkout@v4 - - id: determine_should_run_tests - # Determine if tests should run for this pr. If it's a manually submitted release candidate no tests will run. - run: | - BRANCH_NAME="${{ github.head_ref }}" - RELEASE_VERSION="${BRANCH_NAME:9}" - COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - - IS_AUTOMATED_RELEASE="false" - if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then - IS_AUTOMATED_RELEASE="true" - fi - - if [[ "${{env.IS_RELEASE}}" == "true" && "$IS_AUTOMATED_RELEASE" == "false" ]]; then - echo "should_run_tests=false" >> "$GITHUB_OUTPUT" - else - echo "should_run_tests=true" >> "$GITHUB_OUTPUT" - fi + - name: Should release + id: determine_should_run_tests + uses: ./.github/actions/should_release run-test: # Tests can either run against the current code of Azle found in the repository, or the code deployed by the GitHub Action to npm. @@ -152,7 +139,7 @@ jobs: working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - - name: Start dfx with artifical delay + - name: Start dfx with artifcial delay if: ${{ env.IS_RELEASE }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 From 4fc40610e73a51fd42780d0ae5e4491e3788d041 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 13:43:50 -0600 Subject: [PATCH 44/58] clean up and stabilize should run action --- .github/actions/should_release/action.yml | 4 ++-- .github/scripts/get_tests.sh | 2 -- .github/workflows/test.yml | 20 +++++++------------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/actions/should_release/action.yml b/.github/actions/should_release/action.yml index ccc14e6295..1109ba32ff 100644 --- a/.github/actions/should_release/action.yml +++ b/.github/actions/should_release/action.yml @@ -16,10 +16,10 @@ runs: BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - IS_RELEASE = ${{ contains(github.head_ref, 'release--') }} + IS_RELEASE="${{ contains(github.head_ref, 'release--') }}" SHOULD_RELEASE="false" - if [[ "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then + if [[ $IS_RELEASE == "true" && "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then SHOULD_RELEASE="true" fi diff --git a/.github/scripts/get_tests.sh b/.github/scripts/get_tests.sh index 3bde851a58..cc34aa7695 100755 --- a/.github/scripts/get_tests.sh +++ b/.github/scripts/get_tests.sh @@ -82,8 +82,6 @@ json_result="[" if [[ -n "$all_directories" ]]; then # Check if all_directories is not an empty string while read -r dir; do if [[ -n "$dir" ]]; then # Check if dir is not an empty string - echo "This is the dir" >&2 - echo "$dir" >&2 if ! is_excluded "$dir"; then json_result+=$(generate_json "$dir") json_result+="," diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c32178ca6e..7ff76da156 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,8 +3,6 @@ # These tests are currently written in TypeScript and are intended to be run in a Node.js environment. # This GitHub Action takes care of deploying to npm and GitHub. -# TODO give every step a name - name: Tests on: push: @@ -53,15 +51,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Should release - id: determine_should_run_tests + - id: determine_should_run_tests uses: ./.github/actions/should_release run-test: - # Tests can either run against the current code of Azle found in the repository, or the code deployed by the GitHub Action to npm. - # Feature branch pull requests (pull requests without release-- in the base branch name) will run all tests against the code found in the repository. - # Release branch pull requests (pull requests with release-- in the base branch name) will run all tests against the code found in the repository and the code deployed by the GitHub Action to npm. - # Pushes to main will run all tests against the code in the repository if the latest commit was not a merge of a release branch, and will run tests against the code in the repository and the code deployed by the GitHub Action to npm otherwise. name: '${{matrix.tests.name}} | ${{matrix.tests.type}} | ${{matrix.tests.syntax}} | ${{matrix.tests.api}} | ${{matrix.azle_source}}' needs: - determine-should-run-tests @@ -90,9 +83,10 @@ jobs: - include_npm: true azle_source: repo # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element - tests: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' && fromJSON(needs.get-tests.outputs.tests) || fromJSON('["dummy"]') }} + tests: ${{ fromJSON(needs.get-tests.outputs.tests) }} steps: - name: Report full path of test + # Just in case the path isn't obvious from the name, this will remove ambiguity run: echo ${{matrix.tests.path}} - uses: actions/checkout@v4 @@ -101,7 +95,7 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - name: Run Pre-Test Azle Setup + - name: Run pre-test Azle setup run: | # Install dfx @@ -122,7 +116,7 @@ jobs: npm run lint shell: bash -l {0} - - name: Run pre-test setup + - name: Run pre-test setup for ${{ matrix.tests.name }} run: | npm install @@ -184,7 +178,7 @@ jobs: working-directory: ${{ matrix.tests.path }} # These final jobs are designed to ensure that all jobs spun up from the matrix in the run-test have succeeded - check-basic-integration-test-success: + check-test-success: name: Check Azle tests succeeded needs: run-test runs-on: ubuntu-latest @@ -192,7 +186,7 @@ jobs: steps: - run: exit 0 - check-basic-integration-test-failure: + check-test-failure: name: Check Azle tests didn't fail needs: run-test runs-on: ubuntu-latest From e86715e4cb57dae4893c1812021f5f1785ea54d7 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 14:03:28 -0600 Subject: [PATCH 45/58] pr fixes --- .github/actions/should_release/action.yml | 8 ++++---- .github/workflows/test.yml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/should_release/action.yml b/.github/actions/should_release/action.yml index 1109ba32ff..805bc9715d 100644 --- a/.github/actions/should_release/action.yml +++ b/.github/actions/should_release/action.yml @@ -1,10 +1,10 @@ # TODO I feel like the wording on this is a little clunky and/or ethereal. # TODO we have is release vs should release and I don't feel like it's clear what the answer is name: Should release -description: Determines if the current workflow should spawn a something that Jordan can figure out the wording for +description: Determines if the current pull request is for testing or for starting a release outputs: should_release: - description: Returns true if this branch needs should spawn a something that Jordan can figure out the wording for, otherwise false + description: Returns true if this branch should start a release, otherwise false value: ${{ steps.determine_should_release.outputs.should_release }} runs: using: composite @@ -16,10 +16,10 @@ runs: BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s") - IS_RELEASE="${{ contains(github.head_ref, 'release--') }}" + IS_RELEASE_BRANCH_PR="${{ contains(github.head_ref, 'release--') }}" SHOULD_RELEASE="false" - if [[ $IS_RELEASE == "true" && "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then + if [[ $IS_RELEASE_BRANCH_PR == "true" && "$COMMIT_MESSAGE" == "azle-bot automated release $RELEASE_VERSION" ]]; then SHOULD_RELEASE="true" fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ff76da156..a49b2594a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ on: - main pull_request: # Runs on pull requests to any branch env: - IS_RELEASE: ${{ contains(github.head_ref, 'release--') }} + IS_RELEASE_BRANCH_PR: ${{ contains(github.head_ref, 'release--') }} IS_FEATURE_BRANCH_PR: ${{ !contains(github.head_ref, 'release--') }} DFX_VERSION: 0.21.0 NODE_VERSION: 20 @@ -129,12 +129,12 @@ jobs: shell: bash -l {0} - name: Start dfx - if: ${{ !env.IS_RELEASE }} + if: ${{ env.IS_FEATURE_BRANCH_PR }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - name: Start dfx with artifcial delay - if: ${{ env.IS_RELEASE }} + if: ${{ env.IS_RELEASE_BRANCH_PR }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 From bc5b66625b29bf711673de8b28d817246e88264e Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 14:26:42 -0600 Subject: [PATCH 46/58] simplify logic for num runs --- .github/workflows/test.yml | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a49b2594a5..1d1fdc3744 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,7 @@ on: - main pull_request: # Runs on pull requests to any branch env: + IS_MAIN_BRANCH: ${{ github.ref == 'refs/heads/main' }} IS_RELEASE_BRANCH_PR: ${{ contains(github.head_ref, 'release--') }} IS_FEATURE_BRANCH_PR: ${{ !contains(github.head_ref, 'release--') }} DFX_VERSION: 0.21.0 @@ -140,34 +141,11 @@ jobs: - name: Run test run: | - BRANCH_NAME="${{ github.head_ref }}" - MAIN_BRANCH='refs/heads/main' - COMMIT_MESSAGE="${{ github.event.head_commit.message }}" - RELEASE_TAG='release--' - RELEASE_PR_MERGE_MSG='Merge pull request' - RELEASE_REPO_MSG='demergent-labs/release--' - - IS_RELEASE_PR=false - IS_MERGE_TO_MAIN_FROM_RELEASE=false - - # Check if it's a release candidate pull request - if [[ $BRANCH_NAME == *"$RELEASE_TAG"* && ${{ github.ref }} != "$MAIN_BRANCH" && !($COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"*) ]]; then - IS_RELEASE_PR=true - else - IS_RELEASE_PR=false - fi - - # Check if it's a merge from a release candidate into main - if [[ ${{ github.ref }} == "$MAIN_BRANCH" && $COMMIT_MESSAGE == *"$RELEASE_PR_MERGE_MSG"* && $COMMIT_MESSAGE == *"$RELEASE_REPO_MSG"* ]]; then - IS_MERGE_TO_MAIN_FROM_RELEASE=true - else - IS_MERGE_TO_MAIN_FROM_RELEASE=false - fi + IS_MERGE_TO_MAIN_FROM_RELEASE=${{ env.IS_MAIN_BRANCH && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--') }} - # Determine the number of runs based on the conditions - if [[ $IS_MERGE_TO_MAIN_FROM_RELEASE == true ]]; then + if $IS_MERGE_TO_MAIN_FROM_RELEASE; then RUNS=100 - elif [[ $IS_RELEASE_PR == true ]]; then + elif ${{ env.IS_RELEASE_BRANCH_PR && !env.IS_MAIN_BRANCH }}; then RUNS=10 else RUNS=5 From 0e319a46a3bc319da3293913a5ced92c7b02fe05 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 14:29:13 -0600 Subject: [PATCH 47/58] move configurable options to the top of the env --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1d1fdc3744..61f510e2d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,11 +10,11 @@ on: - main pull_request: # Runs on pull requests to any branch env: + DFX_VERSION: 0.21.0 + NODE_VERSION: 20 IS_MAIN_BRANCH: ${{ github.ref == 'refs/heads/main' }} IS_RELEASE_BRANCH_PR: ${{ contains(github.head_ref, 'release--') }} IS_FEATURE_BRANCH_PR: ${{ !contains(github.head_ref, 'release--') }} - DFX_VERSION: 0.21.0 - NODE_VERSION: 20 jobs: get-tests: name: Get tests From 50f898ce04e2a4c14e3b94e462389a54b2ad2ab0 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 15:36:25 -0600 Subject: [PATCH 48/58] update env logic --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61f510e2d6..def489df13 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -130,22 +130,22 @@ jobs: shell: bash -l {0} - name: Start dfx - if: ${{ env.IS_FEATURE_BRANCH_PR }} + if: ${{ env.IS_FEATURE_BRANCH_PR == 'true' }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - name: Start dfx with artifcial delay - if: ${{ env.IS_RELEASE_BRANCH_PR }} + if: ${{ env.IS_RELEASE_BRANCH_PR == 'true' }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 - name: Run test run: | - IS_MERGE_TO_MAIN_FROM_RELEASE=${{ env.IS_MAIN_BRANCH && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--') }} + IS_MERGE_TO_MAIN_FROM_RELEASE=${{ env.IS_MAIN_BRANCH == 'true' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--') }} if $IS_MERGE_TO_MAIN_FROM_RELEASE; then RUNS=100 - elif ${{ env.IS_RELEASE_BRANCH_PR && !env.IS_MAIN_BRANCH }}; then + elif ${{ env.IS_RELEASE_BRANCH_PR == 'true' && env.IS_MAIN_BRANCH == 'false' }}; then RUNS=10 else RUNS=5 From e83c98d176f93416f831ea887f9c493b1c825c6e Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Thu, 29 Aug 2024 16:19:00 -0600 Subject: [PATCH 49/58] release --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 56bb0ab610..50c7b9fc84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "azle", - "version": "0.23.0", + "version": "0.24.0-rc.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "azle", - "version": "0.23.0", + "version": "0.24.0-rc.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index c3936730a3..d0d1f1d3fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azle", - "version": "0.23.0", + "version": "0.24.0-rc.0", "description": "TypeScript and JavaScript CDK for the Internet Computer", "scripts": { "typecheck": "tsc --noEmit", From 640a6ed069c70f940b1c14564a1b2cc445789048 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 15:41:14 -0600 Subject: [PATCH 50/58] try this for skipping tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index def489df13..2ba3d61ea8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,7 +60,7 @@ jobs: needs: - determine-should-run-tests - get-tests - if: ${{ needs.determine-should-run-tests.outputs.should_run_tests }} + if: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' }} runs-on: ${{ matrix.os }} env: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} From d95f45ab97657c295f28788ad8c074701836c688 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 15:45:04 -0600 Subject: [PATCH 51/58] fix logic --- .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 a777af6c95..02b519411d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Deploy release candidate +name: Release on: push: branches: @@ -40,7 +40,7 @@ jobs: release: name: Deploy release # Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested - if: ${{ !needs.determine-should-release.outputs.should_release }} + if: ${{ needs.determine-should-release.outputs.should_release }} needs: - get-tests - determine-should-release From b58417831c5c8f6061e768263def22c34998d1d0 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 15:49:53 -0600 Subject: [PATCH 52/58] restore release_version to release.yml --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02b519411d..aefe686221 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,4 +76,7 @@ jobs: git config --global user.signingkey C8B77BCBE16CD2B94B43F9C8757397B82D4ED7B0 - name: Publish release - run: ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests).*.path }} + run: | + BRANCH_NAME="${{ github.head_ref }}" + RELEASE_VERSION="${BRANCH_NAME:9}" + ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests).*.path }} From 91f1478950a87371c38ec986649e66b25c28a8e9 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 15:55:32 -0600 Subject: [PATCH 53/58] trouble shooting --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aefe686221..6a934e52b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,4 +79,5 @@ jobs: run: | BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" + echo $RELEASE_VERSION ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests).*.path }} From ee81e63c576ca592d569ed61be8d4e5f396c38c8 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 16:00:32 -0600 Subject: [PATCH 54/58] try that --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a934e52b0..91b27f99e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,4 +80,5 @@ jobs: BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" echo $RELEASE_VERSION - ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests).*.path }} + echo ${{toJson(needs.get-tests.outputs.tests)}} + # ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests).*.path }} From c67c9d2dd3749fe1f9f1ee9ff48af24760cc990d Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 16:04:01 -0600 Subject: [PATCH 55/58] try this --- .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 91b27f99e0..16688b43d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,5 +80,5 @@ jobs: BRANCH_NAME="${{ github.head_ref }}" RELEASE_VERSION="${BRANCH_NAME:9}" echo $RELEASE_VERSION - echo ${{toJson(needs.get-tests.outputs.tests)}} - # ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests).*.path }} + echo ${{toJson(needs.get-tests.outputs.tests.*.path)}} + ./.github/scripts/publish_github_action.sh $RELEASE_VERSION ${{ toJSON(needs.get-tests.outputs.tests.*.path) }} From 95857c66321e3fbdd089ef84b4ad40a81640ef2b Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 16:14:21 -0600 Subject: [PATCH 56/58] try this --- .github/actions/should_release/action.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/actions/should_release/action.yml b/.github/actions/should_release/action.yml index 805bc9715d..8a41ed930f 100644 --- a/.github/actions/should_release/action.yml +++ b/.github/actions/should_release/action.yml @@ -23,5 +23,15 @@ runs: SHOULD_RELEASE="true" fi + if [[ "${{ contains(github.head_ref, 'release--') }}" == "true" && "$COMMIT_MESSAGE" != "azle-bot automated release $RELEASE_VERSION" ]] + then + echo "Expecting TRUE. Received: ${SHOULD_RELEASE}" + else + echo "Expecting FALSE. Received: ${SHOULD_RELEASE}" + fi + + echo "This is the value of should release" + echo $SHOULD_RELEASE + echo "should_release=${SHOULD_RELEASE}" >> "$GITHUB_OUTPUT" shell: bash From f735119baea6506aa111b783241e90af83329c28 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 30 Aug 2024 16:15:32 -0600 Subject: [PATCH 57/58] update version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50c7b9fc84..881d25579b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "azle", - "version": "0.24.0-rc.0", + "version": "0.24.0-rc.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "azle", - "version": "0.24.0-rc.0", + "version": "0.24.0-rc.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index d0d1f1d3fc..b9eac73f3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azle", - "version": "0.24.0-rc.0", + "version": "0.24.0-rc.1", "description": "TypeScript and JavaScript CDK for the Internet Computer", "scripts": { "typecheck": "tsc --noEmit", From da6dc02294ebd95abf6dc3ac4224ff1a108c8384 Mon Sep 17 00:00:00 2001 From: Jordan Last Date: Fri, 30 Aug 2024 22:17:53 +0000 Subject: [PATCH 58/58] azle-bot automated release 0.24.0-rc.1 --- dfx_extension/extension.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dfx_extension/extension.json b/dfx_extension/extension.json index a6d2bab0f4..b876c37fc3 100644 --- a/dfx_extension/extension.json +++ b/dfx_extension/extension.json @@ -1,6 +1,6 @@ { "name": "azle", - "version": "0.23.0", + "version": "0.24.0-rc.1", "homepage": "https://github.com/dfinity/dfx-extensions", "authors": "", "summary": "",