From a34922673803be175c13a937262a86c6de58e52d Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 28 Oct 2024 13:19:56 -0600 Subject: [PATCH 01/20] run parallel benchmarks --- .github/workflows/benchmark.yml | 141 ++++++++++++++++++++ .github/workflows/benchmark_parallel.yml | 156 +++++++++++++++++++++++ 2 files changed, 297 insertions(+) create mode 100644 .github/workflows/benchmark.yml create mode 100644 .github/workflows/benchmark_parallel.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 0000000000..8038acf3c3 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,141 @@ +name: Benchmark + +on: + push: + branches: + - main + pull_request: + +jobs: + determine-should-run-benchmarks: + name: Determine if benchmarks should run + runs-on: ubuntu-latest + outputs: + # If the branch should release then it shouldn't run benchmarks. + should-run-benchmarks: ${{ steps.determine-should-run-benchmarks.outputs.should-release == 'false' }} + steps: + - uses: actions/checkout@v4 + + - id: determine-should-run-benchmarks + uses: ./.github/actions/should_release + + set-exclude-dirs: + name: Set exclude directories + runs-on: ubuntu-latest + outputs: + exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} + steps: + - uses: actions/checkout@v4 + + - id: set-conditions + uses: ./.github/actions/set_run_conditions + + - id: set-exclude-dirs + run: | + RELEASE_BENCHMARKS="${{ format(' + tests/end_to_end/candid_rpc/class_syntax/new + tests/end_to_end/http_server/new + ') }}" + + UNSTABLE_BENCHMARKS="${{ 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 + tests/property/ic_api/performance_counter + tests/property/ic_api/instruction_counter + ') }}" + + SLOW_BENCHMARKS="${{ format(' + tests/end_to_end/candid_rpc/functional_syntax/ckbtc + tests/end_to_end/candid_rpc/class_syntax/bitcoin + tests/end_to_end/http_server/large_files + tests/end_to_end/http_server/open_value_sharing + tests/end_to_end/candid_rpc/class_syntax/stable_structures + tests/end_to_end/candid_rpc/functional_syntax/bitcoin + tests/end_to_end/candid_rpc/functional_syntax/composite_queries + tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls + tests/end_to_end/candid_rpc/functional_syntax/management_canister + tests/end_to_end/candid_rpc/functional_syntax/stable_structures + tests/end_to_end/http_server/autoreload + ') }}" + + AZLE_IS_MAIN_BRANCH_PUSH="${{ steps.set-conditions.outputs.is_main_branch_push }}" + AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE="${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" + AZLE_IS_RELEASE_BRANCH_PR="${{ steps.set-conditions.outputs.is_release_branch_pr }}" + AZLE_IS_FEATURE_BRANCH_PR="${{ steps.set-conditions.outputs.is_feature_branch_pr }}" + AZLE_IS_FEATURE_BRANCH_DRAFT_PR="${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" + + EXCLUDE_DIRS="" + + if [[ "$AZLE_IS_MAIN_BRANCH_PUSH" == "true" ]]; then + EXCLUDE_DIRS="" + fi + + if [[ "$AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" == "true" ]]; then + EXCLUDE_DIRS="" + fi + + if [[ "$AZLE_IS_RELEASE_BRANCH_PR" == "true" ]]; then + EXCLUDE_DIRS="" + fi + + if [[ "$AZLE_IS_FEATURE_BRANCH_PR" == "true" ]]; then + EXCLUDE_DIRS="$RELEASE_BENCHMARKS $UNSTABLE_BENCHMARKS" + fi + + if [[ "$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then + EXCLUDE_DIRS="$RELEASE_BENCHMARKS $UNSTABLE_BENCHMARKS $SLOW_BENCHMARKS" + fi + + # Trim leading or trailing spaces and save the exclude-dirs in the environment + EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) + echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT + + run-benchmarks: + name: ${{ matrix.benchmark_group.name }} + needs: + - determine-should-run-benchmarks + - set-exclude-dirs + if: ${{ needs.determine-should-run-benchmarks.outputs.should-run-benchmarks == 'true' }} + strategy: + fail-fast: false + matrix: + benchmark_group: + - { name: 'Examples', directories: './examples' } + - { + name: 'E2E Class', + directories: './tests/end_to_end/candid_rpc/class_syntax' + } + - { + name: 'E2E Functional', + directories: './tests/end_to_end/candid_rpc/functional_syntax' + } + - { + name: 'E2E HTTP Server', + directories: './tests/end_to_end/http_server' + } + - { + name: 'Property Class', + directories: './tests/property/candid_rpc/class_api' + } + - { + name: 'Property Functional', + directories: './tests/property/candid_rpc/functional_api' + } + - { + name: 'Property IC API', + directories: './tests/property/ic_api' + } + uses: ./.github/workflows/benchmark_parallel.yml + secrets: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + with: + directories: ${{ matrix.benchmark_group.directories }} + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml new file mode 100644 index 0000000000..3a94273c40 --- /dev/null +++ b/.github/workflows/benchmark_parallel.yml @@ -0,0 +1,156 @@ +name: Parallel Benchmark +on: + workflow_call: + inputs: + directories: + required: true + type: string + exclude-dirs: + required: false + type: string + default: '' + secrets: + GPG_SIGNING_KEY: + required: true + GH_TOKEN: + required: true + LASTMJS_GITHUB_TOKEN: + required: true + +jobs: + prepare-benchmark: + name: Prepare Benchmark + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + outputs: + azle-version: ${{ steps.get-version.outputs.azle-version }} + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + + - id: get-version + run: | + VERSION=$(jq -r '.version' package.json) + echo "azle-version=$VERSION" >> $GITHUB_OUTPUT + + - id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + directories: ${{ inputs.directories }} + exclude-dirs: ${{ inputs.exclude-dirs }} + + run-benchmarks: + needs: prepare-benchmark + name: Run benchmarks for ${{ matrix.test.name }} + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strategy: + fail-fast: false + matrix: + test: ${{ fromJson(needs.prepare-benchmark.outputs.test-infos) }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} + + - uses: ./.github/actions/setup_node + + - uses: ./.github/actions/setup_dfx + + - name: Install dependencies + run: | + npm install + cd ${{ matrix.test.path }} + npm install + + - name: Start dfx with artificial delay 0 + working-directory: ${{ matrix.test.path }} + run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 + + - name: Run npm test (continue on error) + working-directory: ${{ matrix.test.path }} + continue-on-error: true + run: npm test + + - uses: ./.github/actions/configure_git + with: + gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} + + - name: Commit and push changes + run: | + BRANCH_NAME="benchmark--${{ needs.prepare-benchmark.outputs.azle-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" + git switch -c "$BRANCH_NAME" + git add --all + if ! git diff --cached --quiet; then + git commit -m "Run benchmarks for ${{ matrix.test.displayPath }}" + else + echo "No changes to commit. Skipping commit and push." + fi + git push origin "$BRANCH_NAME" + + finalize-benchmark: + needs: [prepare-benchmark, run-benchmarks] + name: Finalize Benchmark + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + 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 }} + fetch-depth: 0 + + - uses: ./.github/actions/configure_git + with: + gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} + + - name: Collect branches + id: collect-branches + run: | + # Get branches and convert to space-separated list + BRANCHES=$(git branch -r | grep "origin/benchmark--${{ needs.prepare-benchmark.outputs.azle-version }}-" | sed 's/origin\///' | xargs) + echo "branches=$BRANCHES" >> $GITHUB_OUTPUT + + - name: Display collected branches + run: | + echo "Collected branches:" + for branch in ${{ steps.collect-branches.outputs.branches }}; do + echo " - $branch" + done + echo "End of branch list" + + - name: Fetch branches + run: | + echo "Fetching all branches..." + BRANCHES_TO_FETCH="" + for branch in ${{ steps.collect-branches.outputs.branches }}; do + BRANCHES_TO_FETCH+=" $branch:$branch" + done + git fetch origin $BRANCHES_TO_FETCH + + - name: Squash changes + env: + PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + run: | + CURRENT_BRANCH=$(git branch --show-current) + + for branch in ${{ steps.collect-branches.outputs.branches }}; do + git merge --squash $branch + done + + # Create a merge commit with a descriptive message + git commit -am "Update all dependencies for benchmark ${{ needs.prepare-benchmark.outputs.azle-version }}" + + git push origin HEAD:$CURRENT_BRANCH + + - name: Delete branches + run: | + echo "Starting branch deletion process..." + git push origin --delete ${{ steps.collect-branches.outputs.branches }} From 255f0f168cf6818b8a723e1eaef516265d827e04 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 28 Oct 2024 14:04:44 -0600 Subject: [PATCH 02/20] update http tests to run benchmarks --- tests/end_to_end/http_server/apollo_server/test/test.ts | 5 +++-- tests/end_to_end/http_server/audio_and_video/test/test.ts | 5 +++-- tests/end_to_end/http_server/autoreload/test/test.ts | 5 +++-- tests/end_to_end/http_server/bitcoinjs_lib/test/test.ts | 5 +++-- tests/end_to_end/http_server/bitcore_lib/test/test.ts | 5 +++-- tests/end_to_end/http_server/ethers/test/test.ts | 5 +++-- tests/end_to_end/http_server/ethers_base/test/test.ts | 5 +++-- tests/end_to_end/http_server/express/test/test.ts | 5 +++-- tests/end_to_end/http_server/fetch_ic/test/test.ts | 4 +++- tests/end_to_end/http_server/file_protocol/test/test.ts | 5 +++-- tests/end_to_end/http_server/fs/test/test.ts | 5 +++-- .../end_to_end/http_server/http_outcall_fetch/test/test.ts | 5 +++-- tests/end_to_end/http_server/ic_evm_rpc/test/test.ts | 5 +++-- .../end_to_end/http_server/internet_identity/test/test.ts | 4 +++- tests/end_to_end/http_server/large_files/test/test.ts | 5 +++-- tests/end_to_end/http_server/nest/test/test.ts | 5 +++-- .../end_to_end/http_server/open_value_sharing/test/test.ts | 6 ++++-- tests/end_to_end/http_server/sqlite/test/test.ts | 5 +++-- tests/end_to_end/http_server/sqlite_drizzle/test/test.ts | 7 ++++--- tests/end_to_end/http_server/sqlite_typeorm/test/test.ts | 5 +++-- tests/end_to_end/http_server/tfjs/test/test.ts | 5 +++-- tests/end_to_end/http_server/web_assembly/test/test.ts | 5 +++-- 22 files changed, 68 insertions(+), 43 deletions(-) diff --git a/tests/end_to_end/http_server/apollo_server/test/test.ts b/tests/end_to_end/http_server/apollo_server/test/test.ts index c39221986e..a75088c499 100644 --- a/tests/end_to_end/http_server/apollo_server/test/test.ts +++ b/tests/end_to_end/http_server/apollo_server/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('apollo_server'); +const canisterName = 'apollo_server'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/audio_and_video/test/test.ts b/tests/end_to_end/http_server/audio_and_video/test/test.ts index bd945d95c7..3862bbc932 100644 --- a/tests/end_to_end/http_server/audio_and_video/test/test.ts +++ b/tests/end_to_end/http_server/audio_and_video/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('backend'); +const canisterName = 'backend'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/autoreload/test/test.ts b/tests/end_to_end/http_server/autoreload/test/test.ts index 3c54d7f29e..21aa4594e7 100644 --- a/tests/end_to_end/http_server/autoreload/test/test.ts +++ b/tests/end_to_end/http_server/autoreload/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('autoreload'); +const canisterName = 'autoreload'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/bitcoinjs_lib/test/test.ts b/tests/end_to_end/http_server/bitcoinjs_lib/test/test.ts index 6df2b5432c..c33432b203 100644 --- a/tests/end_to_end/http_server/bitcoinjs_lib/test/test.ts +++ b/tests/end_to_end/http_server/bitcoinjs_lib/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('bitcoinjs_lib'); +const canisterName = 'bitcoinjs_lib'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/bitcore_lib/test/test.ts b/tests/end_to_end/http_server/bitcore_lib/test/test.ts index 2eca2497a9..624de176fa 100644 --- a/tests/end_to_end/http_server/bitcore_lib/test/test.ts +++ b/tests/end_to_end/http_server/bitcore_lib/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('bitcore_lib'); +const canisterName = 'bitcore_lib'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/ethers/test/test.ts b/tests/end_to_end/http_server/ethers/test/test.ts index eeb3cf7726..d79925532d 100644 --- a/tests/end_to_end/http_server/ethers/test/test.ts +++ b/tests/end_to_end/http_server/ethers/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('ethers'); +const canisterName = 'ethers'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/ethers_base/test/test.ts b/tests/end_to_end/http_server/ethers_base/test/test.ts index 0a8b49527f..3a732d551e 100644 --- a/tests/end_to_end/http_server/ethers_base/test/test.ts +++ b/tests/end_to_end/http_server/ethers_base/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('server'); +const canisterName = 'server'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/express/test/test.ts b/tests/end_to_end/http_server/express/test/test.ts index f0f03fa3ed..158c722cbe 100644 --- a/tests/end_to_end/http_server/express/test/test.ts +++ b/tests/end_to_end/http_server/express/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('express'); +const canisterName = 'express'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/fetch_ic/test/test.ts b/tests/end_to_end/http_server/fetch_ic/test/test.ts index c26dcfa29a..52a8f7566d 100644 --- a/tests/end_to_end/http_server/fetch_ic/test/test.ts +++ b/tests/end_to_end/http_server/fetch_ic/test/test.ts @@ -2,4 +2,6 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -runTests(getTests('backend')); +const canisterName = 'backend'; + +runTests(getTests(canisterName), canisterName); diff --git a/tests/end_to_end/http_server/file_protocol/test/test.ts b/tests/end_to_end/http_server/file_protocol/test/test.ts index bd945d95c7..3862bbc932 100644 --- a/tests/end_to_end/http_server/file_protocol/test/test.ts +++ b/tests/end_to_end/http_server/file_protocol/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('backend'); +const canisterName = 'backend'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/fs/test/test.ts b/tests/end_to_end/http_server/fs/test/test.ts index c91d144342..d487891b80 100644 --- a/tests/end_to_end/http_server/fs/test/test.ts +++ b/tests/end_to_end/http_server/fs/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('fs'); +const canisterName = 'fs'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/http_outcall_fetch/test/test.ts b/tests/end_to_end/http_server/http_outcall_fetch/test/test.ts index 0a8b49527f..3a732d551e 100644 --- a/tests/end_to_end/http_server/http_outcall_fetch/test/test.ts +++ b/tests/end_to_end/http_server/http_outcall_fetch/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('server'); +const canisterName = 'server'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/ic_evm_rpc/test/test.ts b/tests/end_to_end/http_server/ic_evm_rpc/test/test.ts index 0a8b49527f..3a732d551e 100644 --- a/tests/end_to_end/http_server/ic_evm_rpc/test/test.ts +++ b/tests/end_to_end/http_server/ic_evm_rpc/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('server'); +const canisterName = 'server'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/internet_identity/test/test.ts b/tests/end_to_end/http_server/internet_identity/test/test.ts index c26dcfa29a..52a8f7566d 100644 --- a/tests/end_to_end/http_server/internet_identity/test/test.ts +++ b/tests/end_to_end/http_server/internet_identity/test/test.ts @@ -2,4 +2,6 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -runTests(getTests('backend')); +const canisterName = 'backend'; + +runTests(getTests(canisterName), canisterName); diff --git a/tests/end_to_end/http_server/large_files/test/test.ts b/tests/end_to_end/http_server/large_files/test/test.ts index bd945d95c7..3862bbc932 100644 --- a/tests/end_to_end/http_server/large_files/test/test.ts +++ b/tests/end_to_end/http_server/large_files/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('backend'); +const canisterName = 'backend'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/nest/test/test.ts b/tests/end_to_end/http_server/nest/test/test.ts index 519e141ad2..0cdf9444d9 100644 --- a/tests/end_to_end/http_server/nest/test/test.ts +++ b/tests/end_to_end/http_server/nest/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('api'); +const canisterName = 'api'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/open_value_sharing/test/test.ts b/tests/end_to_end/http_server/open_value_sharing/test/test.ts index 43b3a29f62..bd7a3c9de1 100644 --- a/tests/end_to_end/http_server/open_value_sharing/test/test.ts +++ b/tests/end_to_end/http_server/open_value_sharing/test/test.ts @@ -5,10 +5,12 @@ import { agent, consumerActor } from './consumer_actor'; import { createActor as createWalletActor } from './dfx_generated/wallet'; import { getTests } from './tests'; -const walletActor = createWalletActor(getCanisterId('wallet'), { +const canisterName = 'backend'; +const canisterId = getCanisterId(canisterName); +const walletActor = createWalletActor(canisterId, { agentOptions: { host: 'http://127.0.0.1:8000' } }); -runTests(getTests(consumerActor, walletActor, agent)); +runTests(getTests(consumerActor, walletActor, agent), canisterName); diff --git a/tests/end_to_end/http_server/sqlite/test/test.ts b/tests/end_to_end/http_server/sqlite/test/test.ts index 89fc73328b..7431d1d64e 100644 --- a/tests/end_to_end/http_server/sqlite/test/test.ts +++ b/tests/end_to_end/http_server/sqlite/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('sqlite'); +const canisterName = 'sqlite'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts b/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts index 6e764d1823..f9772ada08 100644 --- a/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts +++ b/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts @@ -1,7 +1,8 @@ import { getCanisterId } from 'azle/dfx'; import { runTests } from 'azle/test'; -import { getTests } from 'sqlite_example/test/tests'; +import { getTests } from 'sqlite_drizzle/test/tests'; -const canisterId = getCanisterId('sqlite_drizzle'); +const canisterName = 'sqlite_drizzle'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/sqlite_typeorm/test/test.ts b/tests/end_to_end/http_server/sqlite_typeorm/test/test.ts index c6ddad17f5..04d8e37556 100644 --- a/tests/end_to_end/http_server/sqlite_typeorm/test/test.ts +++ b/tests/end_to_end/http_server/sqlite_typeorm/test/test.ts @@ -2,6 +2,7 @@ import { getCanisterId } from 'azle/dfx'; import { runTests } from 'azle/test'; import { getTests } from 'sqlite_example/test/tests'; -const canisterId = getCanisterId('sqlite_typeorm'); +const canisterName = 'sqlite_typeorm'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/tfjs/test/test.ts b/tests/end_to_end/http_server/tfjs/test/test.ts index 519e141ad2..0cdf9444d9 100644 --- a/tests/end_to_end/http_server/tfjs/test/test.ts +++ b/tests/end_to_end/http_server/tfjs/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('api'); +const canisterName = 'api'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); diff --git a/tests/end_to_end/http_server/web_assembly/test/test.ts b/tests/end_to_end/http_server/web_assembly/test/test.ts index 23b8952a1e..5c0bd8020c 100644 --- a/tests/end_to_end/http_server/web_assembly/test/test.ts +++ b/tests/end_to_end/http_server/web_assembly/test/test.ts @@ -3,6 +3,7 @@ import { runTests } from 'azle/test'; import { getTests } from './tests'; -const canisterId = getCanisterId('web_assembly'); +const canisterName = 'web_assembly'; +const canisterId = getCanisterId(canisterName); -runTests(getTests(canisterId)); +runTests(getTests(canisterId), canisterName); From ac72d8d763044169cccb007dee45a921d253765e Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 12:46:09 -0600 Subject: [PATCH 03/20] pull out finalize step into it's wn workflow --- .github/workflows/benchmark.yml | 26 ++++++++ .github/workflows/benchmark_parallel.yml | 73 ++-------------------- .github/workflows/finalize_changes.yml | 79 ++++++++++++++++++++++++ .github/workflows/release_parallel.yml | 67 +++++--------------- 4 files changed, 124 insertions(+), 121 deletions(-) create mode 100644 .github/workflows/finalize_changes.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8038acf3c3..436853b2cc 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -96,11 +96,25 @@ jobs: EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT + get-version: + name: Get Azle Version + runs-on: ubuntu-latest + outputs: + azle-version: ${{ steps.get-version.outputs.azle-version }} + steps: + - uses: actions/checkout@v4 + + - id: get-version + run: | + VERSION=$(jq -r '.version' package.json) + echo "azle-version=$VERSION" >> $GITHUB_OUTPUT + run-benchmarks: name: ${{ matrix.benchmark_group.name }} needs: - determine-should-run-benchmarks - set-exclude-dirs + - get-version if: ${{ needs.determine-should-run-benchmarks.outputs.should-run-benchmarks == 'true' }} strategy: fail-fast: false @@ -139,3 +153,15 @@ jobs: with: directories: ${{ matrix.benchmark_group.directories }} exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + azle-version: ${{ needs.get-version.outputs.azle-version }} + + finalize-benchmark: + needs: [run-benchmarks, get-version] + uses: ./.github/workflows/finalize_changes.yml + with: + branch-prefix: 'benchmark--${{ needs.get-version.outputs.azle-version }}-' + commit-message: 'Update all dependencies for benchmark ${{ needs.get-version.outputs.azle-version }}' + secrets: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 3a94273c40..6b68b93bdb 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -9,6 +9,10 @@ on: required: false type: string default: '' + azle-version: + required: true + type: string + secrets: GPG_SIGNING_KEY: required: true @@ -25,16 +29,11 @@ jobs: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: - azle-version: ${{ steps.get-version.outputs.azle-version }} + azle-version: ${{ inputs.azle-version }} test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-version - run: | - VERSION=$(jq -r '.version' package.json) - echo "azle-version=$VERSION" >> $GITHUB_OUTPUT - - id: get-test-infos uses: ./.github/actions/get_test_infos with: @@ -92,65 +91,3 @@ jobs: echo "No changes to commit. Skipping commit and push." fi git push origin "$BRANCH_NAME" - - finalize-benchmark: - needs: [prepare-benchmark, run-benchmarks] - name: Finalize Benchmark - runs-on: ubuntu-latest - env: - GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} - 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 }} - fetch-depth: 0 - - - uses: ./.github/actions/configure_git - with: - gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - - - name: Collect branches - id: collect-branches - run: | - # Get branches and convert to space-separated list - BRANCHES=$(git branch -r | grep "origin/benchmark--${{ needs.prepare-benchmark.outputs.azle-version }}-" | sed 's/origin\///' | xargs) - echo "branches=$BRANCHES" >> $GITHUB_OUTPUT - - - name: Display collected branches - run: | - echo "Collected branches:" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - echo " - $branch" - done - echo "End of branch list" - - - name: Fetch branches - run: | - echo "Fetching all branches..." - BRANCHES_TO_FETCH="" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - BRANCHES_TO_FETCH+=" $branch:$branch" - done - git fetch origin $BRANCHES_TO_FETCH - - - name: Squash changes - env: - PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - run: | - CURRENT_BRANCH=$(git branch --show-current) - - for branch in ${{ steps.collect-branches.outputs.branches }}; do - git merge --squash $branch - done - - # Create a merge commit with a descriptive message - git commit -am "Update all dependencies for benchmark ${{ needs.prepare-benchmark.outputs.azle-version }}" - - git push origin HEAD:$CURRENT_BRANCH - - - name: Delete branches - run: | - echo "Starting branch deletion process..." - git push origin --delete ${{ steps.collect-branches.outputs.branches }} diff --git a/.github/workflows/finalize_changes.yml b/.github/workflows/finalize_changes.yml new file mode 100644 index 0000000000..738dcaf67d --- /dev/null +++ b/.github/workflows/finalize_changes.yml @@ -0,0 +1,79 @@ +name: Finalize Changes +on: + workflow_call: + inputs: + branch-prefix: + required: true + type: string + commit-message: + required: true + type: string + secrets: + GPG_SIGNING_KEY: + required: true + GH_TOKEN: + required: true + LASTMJS_GITHUB_TOKEN: + required: true + +jobs: + finalize: + name: Finalize Changes + runs-on: ubuntu-latest + env: + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + 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 }} + fetch-depth: 0 + + - uses: ./.github/actions/configure_git + with: + gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} + + - name: Collect branches + id: collect-branches + run: | + # Get branches and convert to space-separated list + BRANCHES=$(git branch -r | grep "origin/${{ inputs.branch-prefix }}" | sed 's/origin\///' | xargs) + echo "branches=$BRANCHES" >> $GITHUB_OUTPUT + + - name: Display collected branches + run: | + echo "Collected branches:" + for branch in ${{ steps.collect-branches.outputs.branches }}; do + echo " - $branch" + done + echo "End of branch list" + + - name: Fetch branches + run: | + echo "Fetching all branches..." + BRANCHES_TO_FETCH="" + for branch in ${{ steps.collect-branches.outputs.branches }}; do + BRANCHES_TO_FETCH+=" $branch:$branch" + done + git fetch origin $BRANCHES_TO_FETCH + + - name: Squash changes + env: + PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + run: | + CURRENT_BRANCH=$(git branch --show-current) + + for branch in ${{ steps.collect-branches.outputs.branches }}; do + git merge --squash $branch + done + + # Create a merge commit with a descriptive message + git commit -am "${{ inputs.commit-message }}" + + git push origin HEAD:$CURRENT_BRANCH + + - name: Delete branches + run: | + echo "Starting branch deletion process..." + git push origin --delete ${{ steps.collect-branches.outputs.branches }} diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 7ed4c13120..b4169f00f2 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -129,67 +129,28 @@ jobs: finalize-release: needs: [prepare-release, update-test-files-for-release-commit] - name: Finalize Release - runs-on: ubuntu-latest - env: + uses: ./.github/workflows/finalize_changes.yml + with: + branch-prefix: 'update--${{ needs.prepare-release.outputs.release-version }}-' + commit-message: 'Update test files for all tests and examples ${{ needs.prepare-release.outputs.release-version }}' + secrets: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + + create-release: + needs: [prepare-release, finalize-release] + name: Create Release + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref || github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - fetch-depth: 0 - - - uses: ./.github/actions/configure_git - with: - gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - - - name: Collect branches - id: collect-branches - run: | - # Get branches and convert to space-separated list - BRANCHES=$(git branch -r | grep "origin/update--${{ needs.prepare-release.outputs.release-version }}-" | sed 's/origin\///' | xargs) - echo "branches=$BRANCHES" >> $GITHUB_OUTPUT - - - name: Display collected branches - run: | - echo "Collected branches:" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - echo " - $branch" - done - echo "End of branch list" - - - name: Fetch branches - run: | - echo "Fetching all branches..." - BRANCHES_TO_FETCH="" - for branch in ${{ steps.collect-branches.outputs.branches }}; do - BRANCHES_TO_FETCH+=" $branch:$branch" - done - git fetch origin $BRANCHES_TO_FETCH - - - name: Squash changes - env: - PAT: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - run: | - CURRENT_BRANCH=$(git branch --show-current) - - for branch in ${{ steps.collect-branches.outputs.branches }}; do - git merge --squash $branch - done - - # Create a merge commit with a descriptive message - git commit -am "Update test files for all tests and examples ${{ needs.prepare-release.outputs.release-version }}" - - git push origin HEAD:$CURRENT_BRANCH - - - name: Delete branches - run: | - echo "Starting branch deletion process..." - git push origin --delete ${{ steps.collect-branches.outputs.branches }} - name: Create release + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | VERSION=${{ needs.prepare-release.outputs.release-version }} git tag $VERSION From dd77bb9bae78efb71ea3a197208a6f5ff5a3b795 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 13:32:40 -0600 Subject: [PATCH 04/20] update delete branches --- .github/workflows/delete_branches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/delete_branches.yml b/.github/workflows/delete_branches.yml index 8a8c593405..477cbaa320 100644 --- a/.github/workflows/delete_branches.yml +++ b/.github/workflows/delete_branches.yml @@ -14,7 +14,7 @@ on: jobs: delete-branches: - name: Delete Branches + name: 'Delete branches with prefix ${{ inputs.branch-prefix }} | Dry run: ${{ inputs.dry-run }}' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 80b28f9e2b237baadd12e945cecc989010882ea3 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 13:43:29 -0600 Subject: [PATCH 05/20] temporarily remove complex_init and audio recorder --- .github/workflows/benchmark.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 436853b2cc..d382a042aa 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -35,6 +35,8 @@ jobs: RELEASE_BENCHMARKS="${{ format(' tests/end_to_end/candid_rpc/class_syntax/new tests/end_to_end/http_server/new + tests/end_to_end/candid_rpc/class_syntax/audio_recorder + tests/end_to_end/candid_rpc/class_syntax/complex_init ') }}" UNSTABLE_BENCHMARKS="${{ format(' From 7e70a097c17019d39e7622d7dff39aae770783c4 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 14:16:37 -0600 Subject: [PATCH 06/20] make commit and push action --- .github/actions/commit_and_push/action.yml | 33 ++++++++++++++++++ .github/workflows/benchmark.yml | 20 +++++------ .github/workflows/benchmark_parallel.yml | 40 +++++++++++++--------- .github/workflows/release_parallel.yml | 16 ++------- 4 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 .github/actions/commit_and_push/action.yml diff --git a/.github/actions/commit_and_push/action.yml b/.github/actions/commit_and_push/action.yml new file mode 100644 index 0000000000..41c7589529 --- /dev/null +++ b/.github/actions/commit_and_push/action.yml @@ -0,0 +1,33 @@ +name: Commit and Push Changes +description: 'Configures git, commits changes and pushes to a new branch' +inputs: + branch-name: + description: 'Name of the branch to create' + required: true + commit-message: + description: 'Commit message' + required: true + gpg_signing_key: + description: 'The GPG signing key to use for signing commits' + required: true +runs: + using: composite + steps: + - uses: ./.github/actions/configure_git + with: + gpg_signing_key: ${{ inputs.gpg_signing_key }} + + - name: Commit and push changes + shell: bash + run: | + # Create and switch to new branch + git switch -c "${{ inputs.branch-name }}" + + # Add and commit changes if there are any + git add --all + if ! git diff --cached --quiet; then + git commit -m "${{ inputs.commit-message }}" + git push origin "${{ inputs.branch-name }}" + else + echo "No changes to commit. Skipping commit and push." + fi diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d382a042aa..7387e80a57 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -98,25 +98,25 @@ jobs: EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT - get-version: - name: Get Azle Version + create-branch-prefix: + name: Create Branch Prefix runs-on: ubuntu-latest outputs: - azle-version: ${{ steps.get-version.outputs.azle-version }} + branch-prefix: ${{ steps.create-prefix.outputs.branch-prefix }} steps: - uses: actions/checkout@v4 - - id: get-version + - id: create-prefix run: | VERSION=$(jq -r '.version' package.json) - echo "azle-version=$VERSION" >> $GITHUB_OUTPUT + echo "branch-prefix=benchmark--$VERSION-" >> $GITHUB_OUTPUT run-benchmarks: name: ${{ matrix.benchmark_group.name }} needs: - determine-should-run-benchmarks - set-exclude-dirs - - get-version + - create-branch-prefix if: ${{ needs.determine-should-run-benchmarks.outputs.should-run-benchmarks == 'true' }} strategy: fail-fast: false @@ -155,14 +155,14 @@ jobs: with: directories: ${{ matrix.benchmark_group.directories }} exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - azle-version: ${{ needs.get-version.outputs.azle-version }} + branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }} finalize-benchmark: - needs: [run-benchmarks, get-version] + needs: [run-benchmarks, create-branch-prefix] uses: ./.github/workflows/finalize_changes.yml with: - branch-prefix: 'benchmark--${{ needs.get-version.outputs.azle-version }}-' - commit-message: 'Update all dependencies for benchmark ${{ needs.get-version.outputs.azle-version }}' + branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }} + commit-message: 'Update all dependencies for benchmark' secrets: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 6b68b93bdb..6a9a0b097d 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -9,7 +9,7 @@ on: required: false type: string default: '' - azle-version: + branch-prefix: required: true type: string @@ -25,11 +25,7 @@ jobs: prepare-benchmark: name: Prepare Benchmark runs-on: ubuntu-latest - env: - GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: - azle-version: ${{ inputs.azle-version }} test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 @@ -71,23 +67,33 @@ jobs: working-directory: ${{ matrix.test.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 + - name: Print benchmark.md contents (before test) + working-directory: ${{ matrix.test.path }} + run: | + if [ -f benchmark.md ]; then + echo "Contents of benchmark.md before test:" + cat benchmark.md + else + echo "benchmark.md does not exist before test" + fi + - name: Run npm test (continue on error) working-directory: ${{ matrix.test.path }} continue-on-error: true run: npm test - - uses: ./.github/actions/configure_git - with: - gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - - - name: Commit and push changes + - name: Print benchmark.md contents (after test) + working-directory: ${{ matrix.test.path }} run: | - BRANCH_NAME="benchmark--${{ needs.prepare-benchmark.outputs.azle-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" - git switch -c "$BRANCH_NAME" - git add --all - if ! git diff --cached --quiet; then - git commit -m "Run benchmarks for ${{ matrix.test.displayPath }}" + if [ -f benchmark.md ]; then + echo "Contents of benchmark.md after test:" + cat benchmark.md else - echo "No changes to commit. Skipping commit and push." + echo "benchmark.md does not exist after test" fi - git push origin "$BRANCH_NAME" + + - uses: ./.github/actions/commit_and_push + with: + branch-name: "${{ inputs.branch-prefix }}$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" + commit-message: 'Run benchmarks for ${{ matrix.test.displayPath }}' + gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index b4169f00f2..026570e390 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -111,22 +111,12 @@ jobs: continue-on-error: true run: npm test - - uses: ./.github/actions/configure_git + - uses: ./.github/actions/commit_and_push with: + branch-name: "update--${{ needs.prepare-release.outputs.release-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" + commit-message: 'Update dependencies for ${{ matrix.test.displayPath }}' gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - - name: Commit and push changes - run: | - BRANCH_NAME="update--${{ needs.prepare-release.outputs.release-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" - git switch -c "$BRANCH_NAME" - git add --all - if ! git diff --cached --quiet; then - git commit -m "Update dependencies for ${{ matrix.test.displayPath }}" - else - echo "No changes to commit. Skipping commit and push." - fi - git push origin "$BRANCH_NAME" - finalize-release: needs: [prepare-release, update-test-files-for-release-commit] uses: ./.github/workflows/finalize_changes.yml From e2be3245961459b3d3729cf7c997a9bc3456eaea Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 14:20:49 -0600 Subject: [PATCH 07/20] update commit message --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7387e80a57..ebf4b255dd 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -162,7 +162,7 @@ jobs: uses: ./.github/workflows/finalize_changes.yml with: branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }} - commit-message: 'Update all dependencies for benchmark' + commit-message: 'run benchmarks' secrets: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 262a8321e69ea68a35a0dac717083988aae4acb1 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 14:27:45 -0600 Subject: [PATCH 08/20] update inputs --- .github/workflows/benchmark_parallel.yml | 9 ++++++++- .github/workflows/release_parallel.yml | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 6a9a0b097d..1c55708e9e 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -92,8 +92,15 @@ jobs: echo "benchmark.md does not exist after test" fi + - name: Create branch name + id: create-branch-name + run: | + SAFE_PATH=$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g') + echo "branch-name=${{ inputs.branch-prefix }}${SAFE_PATH}" >> $GITHUB_OUTPUT + shell: bash + - uses: ./.github/actions/commit_and_push with: - branch-name: "${{ inputs.branch-prefix }}$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" + branch-name: ${{ steps.create-branch-name.outputs.branch-name }} commit-message: 'Run benchmarks for ${{ matrix.test.displayPath }}' gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 026570e390..8aa155a023 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -111,9 +111,16 @@ jobs: continue-on-error: true run: npm test + - name: Create branch name + id: create-branch-name + run: | + SAFE_PATH=$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g') + echo "branch-name=update--${{ needs.prepare-release.outputs.release-version }}-${SAFE_PATH}" >> $GITHUB_OUTPUT + shell: bash + - uses: ./.github/actions/commit_and_push with: - branch-name: "update--${{ needs.prepare-release.outputs.release-version }}-$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g')" + branch-name: ${{ steps.create-branch-name.outputs.branch-name }} commit-message: 'Update dependencies for ${{ matrix.test.displayPath }}' gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} From 1bc9b8f550c9f1f8845e0ffa246a9eda386e5a3e Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 15:20:45 -0600 Subject: [PATCH 09/20] explicitly record benchmarks --- .github/workflows/benchmark_parallel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 1c55708e9e..5fd3afae3b 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -80,7 +80,7 @@ jobs: - name: Run npm test (continue on error) working-directory: ${{ matrix.test.path }} continue-on-error: true - run: npm test + run: AZLE_RECORD_BENCHMARKS=true npm test - name: Print benchmark.md contents (after test) working-directory: ${{ matrix.test.path }} From 9836554810231358761dd34a5002c28f583fa0cf Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 15:34:45 -0600 Subject: [PATCH 10/20] add git status for troubleshooting --- .github/actions/commit_and_push/README.md | 23 ++++++++++++++++++++++ .github/actions/commit_and_push/action.yml | 4 ++++ .github/workflows/release_parallel.yml | 4 ---- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 .github/actions/commit_and_push/README.md diff --git a/.github/actions/commit_and_push/README.md b/.github/actions/commit_and_push/README.md new file mode 100644 index 0000000000..96338cdb57 --- /dev/null +++ b/.github/actions/commit_and_push/README.md @@ -0,0 +1,23 @@ +## Prerequisite + +This action assumes that the repository has already been checked out before +calling the action, typically using `actions/checkout@v4`. If you have not +checked out the code in a previous step, make sure to do so to avoid errors. + +This action does **not** perform a checkout action itself because it would be +redundant. This action is part of the repository's codebase, so if the code +hasn't already been checked out, the action itself wouldn't even be available to +call. + +## Example Usage + +```yaml +steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/commit_and_push + with: + gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} + branch-name: 'branch-name' + commit-message: 'commit message' +``` diff --git a/.github/actions/commit_and_push/action.yml b/.github/actions/commit_and_push/action.yml index 41c7589529..b160cde5b1 100644 --- a/.github/actions/commit_and_push/action.yml +++ b/.github/actions/commit_and_push/action.yml @@ -23,6 +23,10 @@ runs: # Create and switch to new branch git switch -c "${{ inputs.branch-name }}" + # Show status of working directory + echo "Current git status:" + git status + # Add and commit changes if there are any git add --all if ! git diff --cached --quiet; then diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 8aa155a023..0fdd3a05bc 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -46,10 +46,6 @@ jobs: run: | AZLE_VERBOSE=true npx azle install-global-dependencies --rust --wasi2ic - - uses: ./.github/actions/configure_git - with: - gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - - name: Update version and build templates run: | VERSION=${{ steps.get-version.outputs.release-version }} From c77a440bf97326cf698ee2c6bd16459f8ee86486 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 15:45:14 -0600 Subject: [PATCH 11/20] try linking --- .github/workflows/benchmark_parallel.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 5fd3afae3b..5465f87468 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -60,8 +60,10 @@ jobs: - name: Install dependencies run: | npm install + npm link cd ${{ matrix.test.path }} npm install + npm link azle - name: Start dfx with artificial delay 0 working-directory: ${{ matrix.test.path }} From 2b4bbbc1eb65b7987a9b5a1db6f778ad8996ba4c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 16:00:13 -0600 Subject: [PATCH 12/20] add logs to help understand the commit history --- .github/actions/commit_and_push/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/commit_and_push/action.yml b/.github/actions/commit_and_push/action.yml index b160cde5b1..ea2fbca71c 100644 --- a/.github/actions/commit_and_push/action.yml +++ b/.github/actions/commit_and_push/action.yml @@ -23,6 +23,9 @@ runs: # Create and switch to new branch git switch -c "${{ inputs.branch-name }}" + echo "Current git log:" + git log --oneline -n 20 + # Show status of working directory echo "Current git status:" git status @@ -35,3 +38,6 @@ runs: else echo "No changes to commit. Skipping commit and push." fi + + echo "Current git log after commit and push:" + git log --oneline -n 20 From c8dd0fe1e08d4406b282f9311540376bc5c9ce61 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 16:49:21 -0600 Subject: [PATCH 13/20] update release and benchmarks to run on workflow dispatch --- .github/actions/get_exclude_dirs/README.md | 15 +++ .github/actions/get_exclude_dirs/action.yml | 71 ++++++++++++ .github/actions/should_release/README.md | 19 --- .github/actions/should_release/action.yml | 27 ----- .github/workflows/benchmark.yml | 122 +++++--------------- .github/workflows/release.yml | 34 ------ .github/workflows/release_parallel.yml | 37 +++--- .github/workflows/test.yml | 95 ++------------- 8 files changed, 139 insertions(+), 281 deletions(-) create mode 100644 .github/actions/get_exclude_dirs/README.md create mode 100644 .github/actions/get_exclude_dirs/action.yml delete mode 100644 .github/actions/should_release/README.md delete mode 100644 .github/actions/should_release/action.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/actions/get_exclude_dirs/README.md b/.github/actions/get_exclude_dirs/README.md new file mode 100644 index 0000000000..3104e1623b --- /dev/null +++ b/.github/actions/get_exclude_dirs/README.md @@ -0,0 +1,15 @@ +## Example Usage + +```yaml +steps: + - uses: actions/checkout@v4 + + - id: get-exclude-dirs + uses: ./.github/actions/get_exclude_dirs + with: + exclude-slow: true + exclude-unstable: true + exclude-release: true + + - run: echo "${{ steps.get-exclude-dirs.outputs.exclude-dirs }}" +``` diff --git a/.github/actions/get_exclude_dirs/action.yml b/.github/actions/get_exclude_dirs/action.yml new file mode 100644 index 0000000000..0635483625 --- /dev/null +++ b/.github/actions/get_exclude_dirs/action.yml @@ -0,0 +1,71 @@ +name: Get Exclude Directories +description: 'Gets a list of directories to exclude based on input parameters' +inputs: + exclude-slow: + description: 'Whether to exclude slow benchmarks' + required: true + exclude-unstable: + description: 'Whether to exclude unstable benchmarks' + required: true + exclude-release-only: + description: 'Whether to exclude release benchmarks only' + required: true +outputs: + exclude-dirs: + description: 'Space-separated list of directories to exclude' + value: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} +runs: + using: composite + steps: + - id: set-exclude-dirs + shell: bash + run: | + RELEASE_ONLY_EXCLUSIONS="${{ format(' + tests/end_to_end/candid_rpc/class_syntax/new + tests/end_to_end/http_server/new + ') }}" + + UNSTABLE_EXCLUSIONS="${{ 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 + tests/property/ic_api/performance_counter + tests/property/ic_api/instruction_counter + ') }}" + + SLOW_EXCLUSIONS="${{ format(' + tests/end_to_end/candid_rpc/functional_syntax/ckbtc + tests/end_to_end/candid_rpc/class_syntax/bitcoin + tests/end_to_end/http_server/large_files + tests/end_to_end/http_server/open_value_sharing + tests/end_to_end/candid_rpc/class_syntax/stable_structures + tests/end_to_end/candid_rpc/functional_syntax/bitcoin + tests/end_to_end/candid_rpc/functional_syntax/composite_queries + tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls + tests/end_to_end/candid_rpc/functional_syntax/management_canister + tests/end_to_end/candid_rpc/functional_syntax/stable_structures + tests/end_to_end/http_server/autoreload + ') }}" + + EXCLUDE_DIRS="" + + if [[ "${{ inputs.exclude-release-only }}" == "true" ]]; then + EXCLUDE_DIRS="$EXCLUDE_DIRS $RELEASE_ONLY_EXCLUSIONS" + fi + + if [[ "${{ inputs.exclude-unstable }}" == "true" ]]; then + EXCLUDE_DIRS="$EXCLUDE_DIRS $UNSTABLE_EXCLUSIONS" + fi + + if [[ "${{ inputs.exclude-slow }}" == "true" ]]; then + EXCLUDE_DIRS="$EXCLUDE_DIRS $SLOW_EXCLUSIONS" + fi + + # Trim leading or trailing spaces and save the exclude-dirs in the environment + EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) + echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT diff --git a/.github/actions/should_release/README.md b/.github/actions/should_release/README.md deleted file mode 100644 index 5c62d4bfd2..0000000000 --- a/.github/actions/should_release/README.md +++ /dev/null @@ -1,19 +0,0 @@ -> [!IMPORTANT] -> This action performs a checkout using `actions/checkout@v4`, specifically -> checking out the `github.event.pull_request.head.ref`. If your workflow -> includes other checkout steps, be mindful that this checkout will override -> previous checkouts, as it checks out a specific branch for the action to -> function correctly. You should consider this when planning future steps in -> your workflow, especially if those steps rely on a different commit or branch. - -## Example Usage - -```yaml -steps: - - uses: actions/checkout@v4 - - - id: should-release - uses: ./.github/actions/should_release - - - run: echo "${{ steps.should-release.outputs.should-release }}" -``` diff --git a/.github/actions/should_release/action.yml b/.github/actions/should_release/action.yml deleted file mode 100644 index 38f1f06ae4..0000000000 --- a/.github/actions/should_release/action.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Should release -description: Determines if the current pull request is for testing or for starting a release -outputs: - should-release: - description: Returns true if this branch should start a release, otherwise false - value: ${{ steps.determine-should-release.outputs.should-release }} -runs: - using: composite - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref }} # This is necessary for this job to be able to get the correct commit message from `git log` - - - 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_BRANCH_PR="${{ startsWith(github.head_ref, 'release--') }}" - - SHOULD_RELEASE="false" - if [[ $IS_RELEASE_BRANCH_PR == "true" && "$COMMIT_MESSAGE" == "release--$RELEASE_VERSION" ]]; then - SHOULD_RELEASE="true" - fi - - echo "should-release=${SHOULD_RELEASE}" >> "$GITHUB_OUTPUT" - shell: bash diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ebf4b255dd..c2f622b84b 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,102 +1,38 @@ name: Benchmark - on: - push: - branches: - - main - pull_request: + workflow_dispatch: + inputs: + exclude-slow-benchmarks: + description: 'Exclude slow benchmarks' + required: true + type: boolean + default: false + exclude-unstable-benchmarks: + description: 'Exclude unstable benchmarks' + required: true + type: boolean + default: false + exclude-release-benchmarks: + description: 'Exclude release benchmarks' + required: true + type: boolean + default: false jobs: - determine-should-run-benchmarks: - name: Determine if benchmarks should run - runs-on: ubuntu-latest - outputs: - # If the branch should release then it shouldn't run benchmarks. - should-run-benchmarks: ${{ steps.determine-should-run-benchmarks.outputs.should-release == 'false' }} - steps: - - uses: actions/checkout@v4 - - - id: determine-should-run-benchmarks - uses: ./.github/actions/should_release - - set-exclude-dirs: - name: Set exclude directories + get-exclude-dirs: + name: Get exclude directories runs-on: ubuntu-latest outputs: - exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} + exclude-dirs: ${{ steps.get-exclude-dirs.outputs.exclude-dirs }} steps: - uses: actions/checkout@v4 - - id: set-conditions - uses: ./.github/actions/set_run_conditions - - - id: set-exclude-dirs - run: | - RELEASE_BENCHMARKS="${{ format(' - tests/end_to_end/candid_rpc/class_syntax/new - tests/end_to_end/http_server/new - tests/end_to_end/candid_rpc/class_syntax/audio_recorder - tests/end_to_end/candid_rpc/class_syntax/complex_init - ') }}" - - UNSTABLE_BENCHMARKS="${{ 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 - tests/property/ic_api/performance_counter - tests/property/ic_api/instruction_counter - ') }}" - - SLOW_BENCHMARKS="${{ format(' - tests/end_to_end/candid_rpc/functional_syntax/ckbtc - tests/end_to_end/candid_rpc/class_syntax/bitcoin - tests/end_to_end/http_server/large_files - tests/end_to_end/http_server/open_value_sharing - tests/end_to_end/candid_rpc/class_syntax/stable_structures - tests/end_to_end/candid_rpc/functional_syntax/bitcoin - tests/end_to_end/candid_rpc/functional_syntax/composite_queries - tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls - tests/end_to_end/candid_rpc/functional_syntax/management_canister - tests/end_to_end/candid_rpc/functional_syntax/stable_structures - tests/end_to_end/http_server/autoreload - ') }}" - - AZLE_IS_MAIN_BRANCH_PUSH="${{ steps.set-conditions.outputs.is_main_branch_push }}" - AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE="${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" - AZLE_IS_RELEASE_BRANCH_PR="${{ steps.set-conditions.outputs.is_release_branch_pr }}" - AZLE_IS_FEATURE_BRANCH_PR="${{ steps.set-conditions.outputs.is_feature_branch_pr }}" - AZLE_IS_FEATURE_BRANCH_DRAFT_PR="${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" - - EXCLUDE_DIRS="" - - if [[ "$AZLE_IS_MAIN_BRANCH_PUSH" == "true" ]]; then - EXCLUDE_DIRS="" - fi - - if [[ "$AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" == "true" ]]; then - EXCLUDE_DIRS="" - fi - - if [[ "$AZLE_IS_RELEASE_BRANCH_PR" == "true" ]]; then - EXCLUDE_DIRS="" - fi - - if [[ "$AZLE_IS_FEATURE_BRANCH_PR" == "true" ]]; then - EXCLUDE_DIRS="$RELEASE_BENCHMARKS $UNSTABLE_BENCHMARKS" - fi - - if [[ "$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then - EXCLUDE_DIRS="$RELEASE_BENCHMARKS $UNSTABLE_BENCHMARKS $SLOW_BENCHMARKS" - fi - - # Trim leading or trailing spaces and save the exclude-dirs in the environment - EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) - echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT + - id: get-exclude-dirs + uses: ./.github/actions/get_exclude_dirs + with: + exclude-slow: ${{ github.event.inputs.exclude-slow-benchmarks == true }} + exclude-unstable: ${{ github.event.inputs.exclude-unstable-benchmarks == true }} + exclude-release-only: ${{ github.event.inputs.exclude-release-benchmarks == true }} create-branch-prefix: name: Create Branch Prefix @@ -114,10 +50,8 @@ jobs: run-benchmarks: name: ${{ matrix.benchmark_group.name }} needs: - - determine-should-run-benchmarks - - set-exclude-dirs + - get-exclude-dirs - create-branch-prefix - if: ${{ needs.determine-should-run-benchmarks.outputs.should-run-benchmarks == 'true' }} strategy: fail-fast: false matrix: @@ -154,7 +88,7 @@ jobs: LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} with: directories: ${{ matrix.benchmark_group.directories }} - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + exclude-dirs: ${{ needs.get-exclude-dirs.outputs.exclude-dirs }} branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }} finalize-benchmark: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 897a33b66c..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Release -on: - push: - branches: - - main - pull_request: - -jobs: - determine-should-release: - if: ${{ startsWith(github.head_ref, 'release--') }} - name: Determine if this branch should release - runs-on: ubuntu-latest - outputs: - should-release: ${{ steps.determine-should-release.outputs.should-release }} - steps: - - uses: actions/checkout@v4 - - - id: determine-should-release - uses: ./.github/actions/should_release - - 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 == 'true' }} - - needs: - - determine-should-release - - uses: ./.github/workflows/release_parallel.yml - secrets: - GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 0fdd3a05bc..7b0706aab1 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -1,14 +1,8 @@ name: Parallel Release on: - workflow_call: - secrets: - GPG_SIGNING_KEY: - required: true - GH_TOKEN: - required: true - NPM_TOKEN: - required: true - LASTMJS_GITHUB_TOKEN: + workflow_dispatch: + inputs: + release-version: required: true jobs: @@ -19,20 +13,17 @@ jobs: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: - release-version: ${{ steps.get-version.outputs.release-version }} + release-version: ${{ inputs.release-version }} test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: + - name: Print branch name + run: echo "${{ github.ref }}" + - uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} + ref: ${{ github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - - id: get-version - run: | - BRANCH_NAME="${{ github.event.pull_request.head.ref || github.ref_name }}" - RELEASE_VERSION="${BRANCH_NAME:9}" - echo "release-version=$RELEASE_VERSION" >> $GITHUB_OUTPUT - - uses: ./.github/actions/setup_node with: registry-url: https://registry.npmjs.org @@ -48,7 +39,7 @@ jobs: - name: Update version and build templates run: | - VERSION=${{ steps.get-version.outputs.release-version }} + VERSION=${{ inputs.release-version }} sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" package.json sed -E -i "s/(\"version\": \")(.*)(\")/\1$VERSION\3/" dfx_extension/extension.json npm install @@ -57,7 +48,7 @@ jobs: - name: Publish to npm run: | - if [[ "${{ steps.get-version.outputs.release-version }}" == *"-rc."* ]]; then + if [[ "${{ inputs.release-version }}" == *"-rc."* ]]; then npm publish --tag next else npm publish @@ -84,7 +75,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} + ref: ${{ github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - uses: ./.github/actions/setup_node @@ -128,7 +119,7 @@ jobs: commit-message: 'Update test files for all tests and examples ${{ needs.prepare-release.outputs.release-version }}' secrets: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} create-release: @@ -138,12 +129,12 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} + ref: ${{ github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN }} - name: Create release env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | VERSION=${{ needs.prepare-release.outputs.release-version }} git tag $VERSION diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f8c43d106..4c524aed0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,101 +12,28 @@ on: pull_request: jobs: - determine-should-run-tests: - name: Determine if tests should run + get-exclude-dirs: + name: Get exclude directories runs-on: ubuntu-latest outputs: - # If the branch should release then it shouldn't run tests. - should-run-tests: ${{ steps.determine-should-run-tests.outputs.should-release == 'false' }} - steps: - - uses: actions/checkout@v4 - - - id: determine-should-run-tests - uses: ./.github/actions/should_release - - set-exclude-dirs: - name: Set exclude directories - runs-on: ubuntu-latest - outputs: - exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} + exclude-dirs: ${{ steps.get-exclude-dirs.outputs.exclude-dirs }} steps: - uses: actions/checkout@v4 - id: set-conditions uses: ./.github/actions/set_run_conditions - - id: set-exclude-dirs - run: | - RELEASE_TESTS="${{ format(' - tests/end_to_end/candid_rpc/class_syntax/new - tests/end_to_end/http_server/new - ') }}" - - UNSTABLE_TESTS="${{ 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 - tests/property/ic_api/performance_counter - tests/property/ic_api/instruction_counter - ') }}" - - SLOW_TESTS="${{ format(' - tests/end_to_end/candid_rpc/functional_syntax/ckbtc - tests/end_to_end/candid_rpc/class_syntax/bitcoin - tests/end_to_end/http_server/large_files - tests/end_to_end/http_server/open_value_sharing - tests/end_to_end/candid_rpc/class_syntax/stable_structures - tests/end_to_end/candid_rpc/functional_syntax/bitcoin - tests/end_to_end/candid_rpc/functional_syntax/composite_queries - tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls - tests/end_to_end/candid_rpc/functional_syntax/management_canister - tests/end_to_end/candid_rpc/functional_syntax/stable_structures - tests/end_to_end/http_server/autoreload - ') }}" - - AZLE_IS_MAIN_BRANCH_PUSH="${{ steps.set-conditions.outputs.is_main_branch_push }}" - AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE="${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" - AZLE_IS_RELEASE_BRANCH_PR="${{ steps.set-conditions.outputs.is_release_branch_pr }}" - AZLE_IS_FEATURE_BRANCH_PR="${{ steps.set-conditions.outputs.is_feature_branch_pr }}" - AZLE_IS_FEATURE_BRANCH_DRAFT_PR="${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" - - EXCLUDE_DIRS="" - - if [[ "$AZLE_IS_MAIN_BRANCH_PUSH" == "true" ]]; then - EXCLUDE_DIRS="" - fi - - if [[ "$AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" == "true" ]]; then - EXCLUDE_DIRS="" - fi - - if [[ "$AZLE_IS_RELEASE_BRANCH_PR" == "true" ]]; then - EXCLUDE_DIRS="" - fi - - if [[ "$AZLE_IS_FEATURE_BRANCH_PR" == "true" ]]; then - EXCLUDE_DIRS="$RELEASE_TESTS $UNSTABLE_TESTS" - fi - - if [[ "$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then - EXCLUDE_DIRS="$RELEASE_TESTS $UNSTABLE_TESTS $SLOW_TESTS" - fi - - # Trim leading or trailing spaces and save the exclude-dirs in the environment - EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) - echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT + - id: get-exclude-dirs + uses: ./.github/actions/get_exclude_dirs + with: + exclude-slow: ${{ steps.set-conditions.outputs.is_feature_branch_draft_pr == 'true' }} + exclude-unstable: ${{ steps.set-conditions.outputs.is_feature_branch_pr == 'true' || steps.set-conditions.outputs.is_feature_branch_draft_pr == 'true' }} + exclude-release-only: ${{ steps.set-conditions.outputs.is_feature_branch_pr == 'true' || steps.set-conditions.outputs.is_feature_branch_draft_pr == 'true' }} run-tests: name: ${{ matrix.test_group.name }} needs: - - determine-should-run-tests - - set-exclude-dirs - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + - get-exclude-dirs strategy: fail-fast: false matrix: @@ -139,7 +66,7 @@ jobs: uses: ./.github/workflows/get_and_run_tests.yml with: directories: ${{ matrix.test_group.directories }} - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + exclude-dirs: ${{ needs.get-exclude-dirs.outputs.exclude-dirs }} check-test-success: name: Check Azle tests succeeded From f578172faea57abdc24fa2c852a0eb457f60b905 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 17:03:49 -0600 Subject: [PATCH 14/20] auto create pr at end of benchmarks and release --- .github/workflows/benchmark.yml | 33 +++++++++++++++++++++++++- .github/workflows/release_parallel.yml | 20 +++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index c2f622b84b..a01f057865 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -35,17 +35,30 @@ jobs: exclude-release-only: ${{ github.event.inputs.exclude-release-benchmarks == true }} create-branch-prefix: - name: Create Branch Prefix + name: Create Branch and Branch Prefix runs-on: ubuntu-latest outputs: branch-prefix: ${{ steps.create-prefix.outputs.branch-prefix }} + base-branch: ${{ steps.create-prefix.outputs.base-branch }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} - id: create-prefix run: | VERSION=$(jq -r '.version' package.json) echo "branch-prefix=benchmark--$VERSION-" >> $GITHUB_OUTPUT + echo "base-branch=benchmark--$VERSION" >> $GITHUB_OUTPUT + + - uses: ./.github/actions/configure_git + with: + gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} + + - name: Create base branch + run: | + git checkout -b ${{ steps.create-prefix.outputs.base-branch }} + git push origin ${{ steps.create-prefix.outputs.base-branch }} run-benchmarks: name: ${{ matrix.benchmark_group.name }} @@ -101,3 +114,21 @@ jobs: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} + + create-pr: + needs: [finalize-benchmark, create-branch-prefix] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base ${{ github.ref_name }} \ + --head ${{ needs.create-branch-prefix.outputs.base-branch }} \ + --title "Benchmark Results for ${{ needs.create-branch-prefix.outputs.base-branch }}" \ + --body "Automated PR for benchmark results" diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 7b0706aab1..972054bb72 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -107,7 +107,7 @@ jobs: - uses: ./.github/actions/commit_and_push with: - branch-name: ${{ steps.create-branch-name.outputs.branch-name }} + branch-name: release--${{ needs.prepare-release.outputs.release-version }} commit-message: 'Update dependencies for ${{ matrix.test.displayPath }}' gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} @@ -145,3 +145,21 @@ jobs: else gh release create "$VERSION" -t "$VERSION" fi + + create-pr: + needs: [prepare-release, finalize-release] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base ${{ github.ref_name }} \ + --head release--${{ needs.prepare-release.outputs.release-version }} \ + --title "Release ${{ needs.prepare-release.outputs.release-version }}" \ + --body "Automated PR for release ${{ needs.prepare-release.outputs.release-version }}" From 2c73b2f654d37035f29957765b12c927e543bbfa Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 29 Oct 2024 17:11:15 -0600 Subject: [PATCH 15/20] rename finalize to squash --- .github/actions/commit_and_push/action.yml | 6 ------ .github/workflows/benchmark.yml | 2 +- .github/workflows/release_parallel.yml | 2 +- .../workflows/{finalize_changes.yml => squash_branches.yml} | 6 +++--- 4 files changed, 5 insertions(+), 11 deletions(-) rename .github/workflows/{finalize_changes.yml => squash_branches.yml} (97%) diff --git a/.github/actions/commit_and_push/action.yml b/.github/actions/commit_and_push/action.yml index ea2fbca71c..b160cde5b1 100644 --- a/.github/actions/commit_and_push/action.yml +++ b/.github/actions/commit_and_push/action.yml @@ -23,9 +23,6 @@ runs: # Create and switch to new branch git switch -c "${{ inputs.branch-name }}" - echo "Current git log:" - git log --oneline -n 20 - # Show status of working directory echo "Current git status:" git status @@ -38,6 +35,3 @@ runs: else echo "No changes to commit. Skipping commit and push." fi - - echo "Current git log after commit and push:" - git log --oneline -n 20 diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index a01f057865..0a112de23b 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -106,7 +106,7 @@ jobs: finalize-benchmark: needs: [run-benchmarks, create-branch-prefix] - uses: ./.github/workflows/finalize_changes.yml + uses: ./.github/workflows/squash_branches.yml with: branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }} commit-message: 'run benchmarks' diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 972054bb72..3921ca8729 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -113,7 +113,7 @@ jobs: finalize-release: needs: [prepare-release, update-test-files-for-release-commit] - uses: ./.github/workflows/finalize_changes.yml + uses: ./.github/workflows/squash_branches.yml with: branch-prefix: 'update--${{ needs.prepare-release.outputs.release-version }}-' commit-message: 'Update test files for all tests and examples ${{ needs.prepare-release.outputs.release-version }}' diff --git a/.github/workflows/finalize_changes.yml b/.github/workflows/squash_branches.yml similarity index 97% rename from .github/workflows/finalize_changes.yml rename to .github/workflows/squash_branches.yml index 738dcaf67d..35653748fe 100644 --- a/.github/workflows/finalize_changes.yml +++ b/.github/workflows/squash_branches.yml @@ -1,4 +1,4 @@ -name: Finalize Changes +name: Squash Branches on: workflow_call: inputs: @@ -17,8 +17,8 @@ on: required: true jobs: - finalize: - name: Finalize Changes + squash: + name: Squash Branches runs-on: ubuntu-latest env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} From 135f30681bd13ea0d10650556a305c74ceb24546 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 30 Oct 2024 09:25:38 -0600 Subject: [PATCH 16/20] pr fixes --- .github/actions/commit_and_push/action.yml | 10 +++------- .github/actions/get_exclude_dirs/action.yml | 2 +- .github/workflows/benchmark.yml | 12 +++++------ .github/workflows/benchmark_parallel.yml | 22 +-------------------- .github/workflows/release_parallel.yml | 10 +++++----- .github/workflows/squash_branches.yml | 2 +- 6 files changed, 17 insertions(+), 41 deletions(-) diff --git a/.github/actions/commit_and_push/action.yml b/.github/actions/commit_and_push/action.yml index b160cde5b1..3225a29d68 100644 --- a/.github/actions/commit_and_push/action.yml +++ b/.github/actions/commit_and_push/action.yml @@ -1,5 +1,5 @@ name: Commit and Push Changes -description: 'Configures git, commits changes and pushes to a new branch' +description: 'Configures git, commits changes, and pushes to a new branch' inputs: branch-name: description: 'Name of the branch to create' @@ -29,9 +29,5 @@ runs: # Add and commit changes if there are any git add --all - if ! git diff --cached --quiet; then - git commit -m "${{ inputs.commit-message }}" - git push origin "${{ inputs.branch-name }}" - else - echo "No changes to commit. Skipping commit and push." - fi + git commit -m "${{ inputs.commit-message }}" + git push origin "${{ inputs.branch-name }}" diff --git a/.github/actions/get_exclude_dirs/action.yml b/.github/actions/get_exclude_dirs/action.yml index 0635483625..abc5234560 100644 --- a/.github/actions/get_exclude_dirs/action.yml +++ b/.github/actions/get_exclude_dirs/action.yml @@ -8,7 +8,7 @@ inputs: description: 'Whether to exclude unstable benchmarks' required: true exclude-release-only: - description: 'Whether to exclude release benchmarks only' + description: 'Whether to exclude release only benchmarks' required: true outputs: exclude-dirs: diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0a112de23b..256ced2b83 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -12,7 +12,7 @@ on: required: true type: boolean default: false - exclude-release-benchmarks: + exclude-release-only-benchmarks: description: 'Exclude release benchmarks' required: true type: boolean @@ -30,9 +30,9 @@ jobs: - id: get-exclude-dirs uses: ./.github/actions/get_exclude_dirs with: - exclude-slow: ${{ github.event.inputs.exclude-slow-benchmarks == true }} - exclude-unstable: ${{ github.event.inputs.exclude-unstable-benchmarks == true }} - exclude-release-only: ${{ github.event.inputs.exclude-release-benchmarks == true }} + exclude-slow: ${{ github.event.inputs.exclude-slow-benchmarks }} + exclude-unstable: ${{ github.event.inputs.exclude-unstable-benchmarks }} + exclude-release-only: ${{ github.event.inputs.exclude-release-only-benchmarks }} create-branch-prefix: name: Create Branch and Branch Prefix @@ -104,7 +104,7 @@ jobs: exclude-dirs: ${{ needs.get-exclude-dirs.outputs.exclude-dirs }} branch-prefix: ${{ needs.create-branch-prefix.outputs.branch-prefix }} - finalize-benchmark: + squash-branches: needs: [run-benchmarks, create-branch-prefix] uses: ./.github/workflows/squash_branches.yml with: @@ -116,7 +116,7 @@ jobs: LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} create-pr: - needs: [finalize-benchmark, create-branch-prefix] + needs: [squash-branches, create-branch-prefix] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 5465f87468..0798f12d52 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -50,7 +50,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} + ref: ${{ github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }} - uses: ./.github/actions/setup_node @@ -69,31 +69,11 @@ jobs: working-directory: ${{ matrix.test.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - - name: Print benchmark.md contents (before test) - working-directory: ${{ matrix.test.path }} - run: | - if [ -f benchmark.md ]; then - echo "Contents of benchmark.md before test:" - cat benchmark.md - else - echo "benchmark.md does not exist before test" - fi - - name: Run npm test (continue on error) working-directory: ${{ matrix.test.path }} continue-on-error: true run: AZLE_RECORD_BENCHMARKS=true npm test - - name: Print benchmark.md contents (after test) - working-directory: ${{ matrix.test.path }} - run: | - if [ -f benchmark.md ]; then - echo "Contents of benchmark.md after test:" - cat benchmark.md - else - echo "benchmark.md does not exist after test" - fi - - name: Create branch name id: create-branch-name run: | diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 3921ca8729..68c002e0f5 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -107,11 +107,11 @@ jobs: - uses: ./.github/actions/commit_and_push with: - branch-name: release--${{ needs.prepare-release.outputs.release-version }} - commit-message: 'Update dependencies for ${{ matrix.test.displayPath }}' + branch-name: ${{ steps.create-branch-name.outputs.branch-name }} + commit-message: 'Update test files for ${{ matrix.test.displayPath }}' gpg_signing_key: ${{ secrets.GPG_SIGNING_KEY }} - finalize-release: + squash-branches: needs: [prepare-release, update-test-files-for-release-commit] uses: ./.github/workflows/squash_branches.yml with: @@ -123,7 +123,7 @@ jobs: LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }} create-release: - needs: [prepare-release, finalize-release] + needs: [prepare-release, squash-branches] name: Create Release runs-on: ubuntu-latest steps: @@ -147,7 +147,7 @@ jobs: fi create-pr: - needs: [prepare-release, finalize-release] + needs: [prepare-release, squash-branches] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/squash_branches.yml b/.github/workflows/squash_branches.yml index 35653748fe..8264f87fb8 100644 --- a/.github/workflows/squash_branches.yml +++ b/.github/workflows/squash_branches.yml @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} + ref: ${{ github.ref }} token: ${{ secrets.LASTMJS_GITHUB_TOKEN }} fetch-depth: 0 From 7323f5bbee1322e125413b493a0b80190803352f Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 30 Oct 2024 09:32:37 -0600 Subject: [PATCH 17/20] pull out create branch name into action --- .github/actions/README.md | 10 +++++++++ .github/actions/commit_and_push/README.md | 11 ---------- .github/actions/configure_git/README.md | 11 ---------- .github/actions/create_branch_name/README.md | 13 ++++++++++++ .github/actions/create_branch_name/action.yml | 21 +++++++++++++++++++ .github/actions/get_test_infos/README.md | 13 ------------ .github/actions/set_run_conditions/README.md | 13 ------------ .github/actions/setup_dfx/README.md | 13 ------------ .github/actions/setup_node/README.md | 13 ------------ .github/workflows/benchmark_parallel.yml | 8 +++---- .github/workflows/release_parallel.yml | 8 +++---- 11 files changed, 52 insertions(+), 82 deletions(-) create mode 100644 .github/actions/README.md create mode 100644 .github/actions/create_branch_name/README.md create mode 100644 .github/actions/create_branch_name/action.yml diff --git a/.github/actions/README.md b/.github/actions/README.md new file mode 100644 index 0000000000..26e3fec4df --- /dev/null +++ b/.github/actions/README.md @@ -0,0 +1,10 @@ +## Prerequisite + +These actions assume that the repository has already been checked out before +calling the action, typically using `actions/checkout@v4`. If you have not +checked out the code in a previous step, make sure to do so to avoid errors. + +Unless otherwise specified, these actions do **not** perform a checkout action +themselves because it would be redundant. These actions are part of the +repository's codebase, so if the code hasn't already been checked out, the +actions themselves wouldn't even be available to call. diff --git a/.github/actions/commit_and_push/README.md b/.github/actions/commit_and_push/README.md index 96338cdb57..36391926e8 100644 --- a/.github/actions/commit_and_push/README.md +++ b/.github/actions/commit_and_push/README.md @@ -1,14 +1,3 @@ -## Prerequisite - -This action assumes that the repository has already been checked out before -calling the action, typically using `actions/checkout@v4`. If you have not -checked out the code in a previous step, make sure to do so to avoid errors. - -This action does **not** perform a checkout action itself because it would be -redundant. This action is part of the repository's codebase, so if the code -hasn't already been checked out, the action itself wouldn't even be available to -call. - ## Example Usage ```yaml diff --git a/.github/actions/configure_git/README.md b/.github/actions/configure_git/README.md index 19d3e8aea9..856aa89d7a 100644 --- a/.github/actions/configure_git/README.md +++ b/.github/actions/configure_git/README.md @@ -1,14 +1,3 @@ -## Prerequisite - -This action assumes that the repository has already been checked out before -calling the action, typically using `actions/checkout@v4`. If you have not -checked out the code in a previous step, make sure to do so to avoid errors. - -This action does **not** perform a checkout action itself because it would be -redundant. This action is part of the repository's codebase, so if the code -hasn't already been checked out, the action itself wouldn't even be available to -call. - ## Example Usage ```yaml diff --git a/.github/actions/create_branch_name/README.md b/.github/actions/create_branch_name/README.md new file mode 100644 index 0000000000..052f42ad60 --- /dev/null +++ b/.github/actions/create_branch_name/README.md @@ -0,0 +1,13 @@ +## Example Usage + +```yaml +steps: + - id: create-branch-name + uses: ./.github/actions/create_branch_name + with: + prefix: 'update--' + path: 'examples/hello_world' +``` + +The action will convert the path to use hyphens instead of slashes and combine it with the prefix. +For example, with the inputs above, it would output: `update--examples-hello_world` diff --git a/.github/actions/create_branch_name/action.yml b/.github/actions/create_branch_name/action.yml new file mode 100644 index 0000000000..39322117f3 --- /dev/null +++ b/.github/actions/create_branch_name/action.yml @@ -0,0 +1,21 @@ +name: Create Branch Name +description: 'Creates a branch name by combining a prefix with a path, converting slashes to hyphens' +inputs: + prefix: + description: 'Prefix for the branch name' + required: true + path: + description: 'Path to convert into branch name' + required: true +outputs: + branch-name: + description: 'The generated branch name' + value: ${{ steps.create-branch-name.outputs.branch-name }} +runs: + using: composite + steps: + - id: create-branch-name + shell: bash + run: | + SAFE_PATH=$(echo '${{ inputs.path }}' | sed 's/\//-/g') + echo "branch-name=${{ inputs.prefix }}${SAFE_PATH}" >> $GITHUB_OUTPUT diff --git a/.github/actions/get_test_infos/README.md b/.github/actions/get_test_infos/README.md index 7b753ec736..0413d9be94 100644 --- a/.github/actions/get_test_infos/README.md +++ b/.github/actions/get_test_infos/README.md @@ -1,16 +1,3 @@ -## Prerequisite - -This action assumes that the repository has already been checked out before -calling the action, typically using `actions/checkout@v4`. If you have not -checked out the code in a previous step, make sure to do so to avoid errors. - -This action does **not** perform a checkout action itself because it would be -redundant. This action is part of the repository’s codebase, so if the code -hasn’t already been checked out, the action itself wouldn't even be available to -call. Additionally, rerunning a checkout at this stage could potentially -overwrite any earlier `actions/checkout` step with different parameters, such as -checking out a specific branch. - ## Example Usage ```yaml diff --git a/.github/actions/set_run_conditions/README.md b/.github/actions/set_run_conditions/README.md index e33311a3ea..b75f8160f7 100644 --- a/.github/actions/set_run_conditions/README.md +++ b/.github/actions/set_run_conditions/README.md @@ -1,16 +1,3 @@ -## Prerequisite - -This action assumes that the repository has already been checked out before -calling the action, typically using `actions/checkout@v4`. If you have not -checked out the code in a previous step, make sure to do so to avoid errors. - -This action does **not** perform a checkout action itself because it would be -redundant. This action is part of the repository's codebase, so if the code -hasn't already been checked out, the action itself wouldn't even be available to -call. Additionally, rerunning a checkout at this stage could potentially -overwrite any earlier `actions/checkout` step with different parameters, such as -checking out a specific branch. - ## Example Usage ```yaml diff --git a/.github/actions/setup_dfx/README.md b/.github/actions/setup_dfx/README.md index 293d76f9e3..efd52b9fda 100644 --- a/.github/actions/setup_dfx/README.md +++ b/.github/actions/setup_dfx/README.md @@ -1,16 +1,3 @@ -## Prerequisite - -This action assumes that the repository has already been checked out before -calling the action, typically using `actions/checkout@v4`. If you have not -checked out the code in a previous step, make sure to do so to avoid errors. - -This action does **not** perform a checkout action itself because it would be -redundant. This action is part of the repository’s codebase, so if the code -hasn’t already been checked out, the action itself wouldn't even be available to -call. Additionally, rerunning a checkout at this stage could potentially -overwrite any earlier `actions/checkout` step with different parameters, such as -checking out a specific branch. - ## Example Usage ```yaml diff --git a/.github/actions/setup_node/README.md b/.github/actions/setup_node/README.md index 0de04bd24e..637f96e405 100644 --- a/.github/actions/setup_node/README.md +++ b/.github/actions/setup_node/README.md @@ -1,16 +1,3 @@ -## Prerequisite - -This action assumes that the repository has already been checked out before -calling the action, typically using `actions/checkout@v4`. If you have not -checked out the code in a previous step, make sure to do so to avoid errors. - -This action does **not** perform a checkout action itself because it would be -redundant. This action is part of the repository’s codebase, so if the code -hasn’t already been checked out, the action itself wouldn't even be available to -call. Additionally, rerunning a checkout at this stage could potentially -overwrite any earlier `actions/checkout` step with different parameters, such as -checking out a specific branch. - ## Example Usage ```yaml diff --git a/.github/workflows/benchmark_parallel.yml b/.github/workflows/benchmark_parallel.yml index 0798f12d52..0b68edfec0 100644 --- a/.github/workflows/benchmark_parallel.yml +++ b/.github/workflows/benchmark_parallel.yml @@ -76,10 +76,10 @@ jobs: - name: Create branch name id: create-branch-name - run: | - SAFE_PATH=$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g') - echo "branch-name=${{ inputs.branch-prefix }}${SAFE_PATH}" >> $GITHUB_OUTPUT - shell: bash + uses: ./.github/actions/create_branch_name + with: + prefix: ${{ inputs.branch-prefix }} + path: ${{ matrix.test.displayPath }} - uses: ./.github/actions/commit_and_push with: diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 68c002e0f5..ac6307d528 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -100,10 +100,10 @@ jobs: - name: Create branch name id: create-branch-name - run: | - SAFE_PATH=$(echo '${{ matrix.test.displayPath }}' | sed 's/\//-/g') - echo "branch-name=update--${{ needs.prepare-release.outputs.release-version }}-${SAFE_PATH}" >> $GITHUB_OUTPUT - shell: bash + uses: ./.github/actions/create_branch_name + with: + prefix: 'update--${{ needs.prepare-release.outputs.release-version }}-' + path: ${{ matrix.test.displayPath }} - uses: ./.github/actions/commit_and_push with: From 77fd3dede56d52d830c437f48209cf314ba0b559 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 30 Oct 2024 09:38:14 -0600 Subject: [PATCH 18/20] update prefix example --- .github/actions/create_branch_name/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/create_branch_name/README.md b/.github/actions/create_branch_name/README.md index 052f42ad60..a8779f1445 100644 --- a/.github/actions/create_branch_name/README.md +++ b/.github/actions/create_branch_name/README.md @@ -5,7 +5,7 @@ steps: - id: create-branch-name uses: ./.github/actions/create_branch_name with: - prefix: 'update--' + prefix: 'update--0.24.2-rc.89-' path: 'examples/hello_world' ``` From f0591b3b865e4a1fe9026dc721476dbd8b6d5a68 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 30 Oct 2024 10:08:24 -0600 Subject: [PATCH 19/20] fix problem with sqlite imports --- tests/end_to_end/http_server/sqlite_drizzle/test/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts b/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts index f9772ada08..44877d0fe6 100644 --- a/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts +++ b/tests/end_to_end/http_server/sqlite_drizzle/test/test.ts @@ -1,6 +1,6 @@ import { getCanisterId } from 'azle/dfx'; import { runTests } from 'azle/test'; -import { getTests } from 'sqlite_drizzle/test/tests'; +import { getTests } from 'sqlite_example/test/tests'; const canisterName = 'sqlite_drizzle'; const canisterId = getCanisterId(canisterName); From 350c8dd59aea872956715daa495ff2b5fee4c9cd Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 30 Oct 2024 10:21:49 -0600 Subject: [PATCH 20/20] fix open value sharing --- tests/end_to_end/http_server/open_value_sharing/test/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end_to_end/http_server/open_value_sharing/test/test.ts b/tests/end_to_end/http_server/open_value_sharing/test/test.ts index bd7a3c9de1..6901929991 100644 --- a/tests/end_to_end/http_server/open_value_sharing/test/test.ts +++ b/tests/end_to_end/http_server/open_value_sharing/test/test.ts @@ -5,7 +5,7 @@ import { agent, consumerActor } from './consumer_actor'; import { createActor as createWalletActor } from './dfx_generated/wallet'; import { getTests } from './tests'; -const canisterName = 'backend'; +const canisterName = 'wallet'; const canisterId = getCanisterId(canisterName); const walletActor = createWalletActor(canisterId, { agentOptions: {