From c8820829a0b10ad8ab47378213ce955ba53ec948 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 4 Oct 2024 12:37:40 -0600 Subject: [PATCH 01/30] use reusable workflows for running tests --- .github/workflows/run-test.yml | 129 ++++++++++++++++++++++++ .github/workflows/test.yml | 174 +++++++++------------------------ 2 files changed, 175 insertions(+), 128 deletions(-) create mode 100644 .github/workflows/run-test.yml diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml new file mode 100644 index 0000000000..eec0700fd1 --- /dev/null +++ b/.github/workflows/run-test.yml @@ -0,0 +1,129 @@ +name: Run Test + +on: + workflow_call: + inputs: + test_infos: + required: true + type: string + include_npm: + required: true + type: boolean + os: + required: true + type: string + conditions: + required: true + type: string + secrets: + ETHEREUM_URL: + required: true + +jobs: + run-test: + name: '${{matrix.tests.name}} | ${{matrix.tests.displayPath}} | ${{matrix.azle_source}} | ${{matrix.os}}' + runs-on: ${{ matrix.os }} + env: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} + AZLE_IDENTITY_STORAGE_MODE: 'plaintext' + AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }} + strategy: + fail-fast: false + matrix: + os: ${{ fromJSON(inputs.os) }} + include_npm: + - ${{ inputs.include_npm }} + azle_source: + - npm + - repo + exclude: + - include_npm: false + azle_source: npm + - include_npm: true + azle_source: repo + tests: ${{ fromJSON(inputs.test_infos) }} + steps: + - name: Set condition variables + run: | + echo "AZLE_IS_MAIN_BRANCH_PUSH=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_main_branch_push)" >> $GITHUB_ENV + echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_main_branch_merge_from_release_push)" >> $GITHUB_ENV + echo "AZLE_IS_RELEASE_BRANCH_PR=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_release_branch_pr)" >> $GITHUB_ENV + echo "AZLE_IS_FEATURE_BRANCH_PR=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_feature_branch_pr)" >> $GITHUB_ENV + echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_feature_branch_draft_pr)" >> $GITHUB_ENV + + - name: Report full path of test + run: echo ${{matrix.tests.path}} + + - uses: actions/checkout@v4 + + - id: get-node-version + uses: ./.github/actions/get_node_version + + - uses: actions/setup-node@v4 + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + + - id: get-dfx-version + uses: ./.github/actions/get_dfx_version + + - name: Run pre-test Azle setup + run: | + src/build/stable/commands/install_global_dependencies/install_dfx.sh ${{ steps.get-dfx-version.outputs.dfx-version }} + echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH + + if [[ "${{ matrix.os }}" == "macos-latest" ]]; then + sudo networksetup -setdnsservers Ethernet 9.9.9.9 + fi + + npm install + + if [[ "${{ matrix.azle_source }}" == "repo" ]]; then + npm link + fi + + npm run lint + shell: bash -l {0} + + - name: Run pre-test setup for ${{ matrix.tests.name }} + run: | + npm install + + if [[ "${{ matrix.azle_source }}" == "repo" ]]; then + npm link azle + fi + + npx azle install-dfx-extension + working-directory: ${{ matrix.tests.path }} + shell: bash -l {0} + + - name: Start dfx with artificial delay 0 + working-directory: ${{ matrix.tests.path }} + run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 + + - name: Run test + run: | + RUNS=1 + + if [[ "$AZLE_IS_MAIN_BRANCH_PUSH" == "true" ]]; then + RUNS=100 + fi + + if [[ "$AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH" == "true" ]]; then + RUNS=100 + fi + + if [[ "$AZLE_IS_RELEASE_BRANCH_PR" == "true" ]]; then + RUNS=10 + fi + + if [[ "$AZLE_IS_FEATURE_BRANCH_PR" == "true" ]]; then + RUNS=5 + fi + + if [[ "$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then + RUNS=1 + fi + + AZLE_PROPTEST_NUM_RUNS=$RUNS AZLE_PROPTEST_VERBOSE=true npm test + shell: bash -l {0} + working-directory: ${{ matrix.tests.path }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 711f5e6e59..55adea265c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,44 +9,65 @@ on: branches: - main pull_request: # Runs on pull requests to any branch -env: - AZLE_IS_MAIN_BRANCH_PUSH: ${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }} - AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: ${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }} - AZLE_IS_RELEASE_BRANCH_PR: ${{ startsWith(github.head_ref, 'release--') }} - AZLE_IS_FEATURE_BRANCH_PR: ${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }} - AZLE_IS_FEATURE_BRANCH_DRAFT_PR: ${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }} + jobs: + set-run-conditions: + name: Set run conditions + runs-on: ubuntu-latest + outputs: + conditions: ${{ steps.set-conditions.outputs.conditions }} + steps: + - id: set-conditions + run: | + CONDITIONS=$(jq -n \ + --arg is_main_branch_push "${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ + --arg is_main_branch_merge_from_release_push "${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ + --arg is_release_branch_pr "${{ startsWith(github.head_ref, 'release--') }}" \ + --arg is_feature_branch_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }}" \ + --arg is_feature_branch_draft_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }}" \ + '{ + is_main_branch_push: $is_main_branch_push, + is_main_branch_merge_from_release_push: $is_main_branch_merge_from_release_push, + is_release_branch_pr: $is_release_branch_pr, + is_feature_branch_pr: $is_feature_branch_pr, + is_feature_branch_draft_pr: $is_feature_branch_draft_pr + }') + echo "conditions=$(echo $CONDITIONS | base64 -w 0)" >> $GITHUB_OUTPUT + - run: echo ${{ steps.set-conditions.outputs.conditions }} + determine-should-run-tests: name: Determine if tests should run 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 get-test-infos: name: Get test infos - needs: determine-should-run-tests + needs: + - determine-should-run-tests + - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} runs-on: ubuntu-latest outputs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version uses: ./.github/actions/get_node_version - name: Set exclude dirs id: set-exclude-dirs run: | + # Decode the base64 encoded conditions + CONDITIONS=$(echo "${{ needs.set-run-conditions.outputs.conditions }}" | base64 -d) + RELEASE_TESTS="${{ 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/new + tests/end_to_end/http_server/new ') }}" UNSTABLE_TESTS="${{ format(' @@ -78,27 +99,26 @@ jobs: EXCLUDE_DIRS="" - if [[ "${{ env.AZLE_IS_MAIN_BRANCH_PUSH }}" == "true" ]]; then + if [[ "$(echo $CONDITIONS | jq -r .is_main_branch_push)" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "${{ env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH }}" == "true" ]]; then + if [[ "$(echo $CONDITIONS | jq -r .is_main_branch_merge_from_release_push)" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "${{ env.AZLE_IS_RELEASE_BRANCH_PR }}" == "true" ]]; then + if [[ "$(echo $CONDITIONS | jq -r .is_release_branch_pr)" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "${{ env.AZLE_IS_FEATURE_BRANCH_PR }}" == "true" ]]; then + if [[ "$(echo $CONDITIONS | jq -r .is_feature_branch_pr)" == "true" ]]; then EXCLUDE_DIRS="$RELEASE_TESTS $UNSTABLE_TESTS" fi - if [[ "${{ env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR }}" == "true" ]]; then + if [[ "$(echo $CONDITIONS | jq -r .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 @@ -113,121 +133,19 @@ jobs: exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} run-test: - name: '${{matrix.tests.name}} | ${{matrix.tests.displayPath}} | ${{matrix.azle_source}}' needs: - determine-should-run-tests - get-test-infos + - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ${{ matrix.os }} - env: + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-test-infos.outputs.test-infos }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + conditions: ${{ needs.set-run-conditions.outputs.conditions }} + secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - AZLE_IDENTITY_STORAGE_MODE: 'plaintext' - AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }} - strategy: - fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest - matrix: # spins up one job per combination of test and code source (repo or npm). - # os: [macos-latest] - os: [ubuntu-latest] - include_npm: - # Only include npm in the matrix if you've pushed to main and the last commit was a merge of a release branch, or the base branch of the pull request is a release branch - - ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - azle_source: - - npm - - repo - exclude: - - include_npm: false - azle_source: npm - - include_npm: true - azle_source: repo - # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element - tests: ${{ fromJSON(needs.get-test-infos.outputs.test-infos) }} - steps: - - name: Report full path of test - # Just in case the path isn't obvious from the name, this will remove ambiguity - run: echo ${{matrix.tests.path}} - - - uses: actions/checkout@v4 - - - id: get-node-version - uses: ./.github/actions/get_node_version - - - uses: actions/setup-node@v4 - with: - node-version: ${{ steps.get-node-version.outputs.node-version }} - - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version - - - name: Run pre-test Azle setup - run: | - - # Install dfx (Note: DFX must be installed before `npm install` because the azle installation process requires dfx) - src/build/stable/commands/install_global_dependencies/install_dfx.sh ${{ steps.get-dfx-version.outputs.dfx-version }} - echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH - - # MacOS-specific DNS configuration - if [[ "${{ matrix.os }}" == "macos-latest" ]]; then - sudo networksetup -setdnsservers Ethernet 9.9.9.9 - fi - - npm install - - if [[ "${{ matrix.azle_source }}" == "repo" ]]; then - npm link - fi - - npm run lint - shell: bash -l {0} - - - name: Run pre-test setup for ${{ matrix.tests.name }} - run: | - npm install - - if [[ "${{ matrix.azle_source }}" == "repo" ]]; then - npm link azle - fi - - npx azle install-dfx-extension - working-directory: ${{ matrix.tests.path }} - shell: bash -l {0} - - - name: Start dfx with artificial delay 0 - if: ${{ env.AZLE_IS_FEATURE_BRANCH_PR == 'true' || env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR == 'true' }} - working-directory: ${{ matrix.tests.path }} - run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - - - name: Start dfx - if: ${{ env.AZLE_IS_RELEASE_BRANCH_PR == 'true' || env.AZLE_IS_MAIN_BRANCH_PUSH == 'true' || env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH == 'true' }} - working-directory: ${{ matrix.tests.path }} - run: dfx start --clean --background --host 127.0.0.1:8000 - - - name: Run test - run: | - RUNS=1 - - if [[ "${{ env.AZLE_IS_MAIN_BRANCH_PUSH }}" == "true" ]]; then - RUNS=100 - fi - - if [[ "${{ env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH }}" == "true" ]]; then - RUNS=100 - fi - - if [[ "${{ env.AZLE_IS_RELEASE_BRANCH_PR }}" == "true" ]]; then - RUNS=10 - fi - - if [[ "${{ env.AZLE_IS_FEATURE_BRANCH_PR }}" == "true" ]]; then - RUNS=5 - fi - - if [[ "${{ env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR }}" == "true" ]]; then - RUNS=1 - fi - - AZLE_PROPTEST_NUM_RUNS=$RUNS AZLE_PROPTEST_VERBOSE=true npm test - shell: bash -l {0} - working-directory: ${{ matrix.tests.path }} # These final jobs are designed to ensure that all jobs spun up from the matrix in the run-test have succeeded check-test-success: From ee4fc0879c9182e69b6352fd3295b2fc11266a76 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 4 Oct 2024 16:51:26 -0600 Subject: [PATCH 02/30] try splitting it up into two things --- .github/workflows/test.yml | 77 +++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55adea265c..e2e64da0ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,20 +45,14 @@ jobs: - id: determine-should-run-tests uses: ./.github/actions/should_release - get-test-infos: - name: Get test infos + set-exclude-dirs: + name: Set exclude directories needs: - - determine-should-run-tests - set-run-conditions - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} runs-on: ubuntu-latest outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} steps: - - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - - name: Set exclude dirs id: set-exclude-dirs run: | @@ -122,25 +116,72 @@ jobs: EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT + get-example-test-infos: + name: Get example test infos + needs: + - determine-should-run-tests + - set-exclude-dirs + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-node-version + uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: node-version: ${{ steps.get-node-version.outputs.node-version }} - directories: | - ./examples - ./tests - exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} + directories: ./examples + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + get-test-test-infos: + name: Get test test infos + needs: + - determine-should-run-tests + - set-exclude-dirs + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-node-version + uses: ./.github/actions/get_node_version + - name: Get test infos + id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + directories: ./tests + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + run-example-tests: + needs: + - determine-should-run-tests + - get-example-test-infos + - set-run-conditions + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-example-test-infos.outputs.test-infos }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + conditions: ${{ needs.set-run-conditions.outputs.conditions }} + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - run-test: + run-test-tests: needs: - determine-should-run-tests - - get-test-infos + - get-test-test-infos - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: - test_infos: ${{ needs.get-test-infos.outputs.test-infos }} + test_infos: ${{ needs.get-test-test-infos.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' conditions: ${{ needs.set-run-conditions.outputs.conditions }} @@ -150,7 +191,7 @@ jobs: # These final jobs are designed to ensure that all jobs spun up from the matrix in the run-test have succeeded check-test-success: name: Check Azle tests succeeded - needs: run-test + needs: [run-example-tests, run-test-tests] runs-on: ubuntu-latest if: success() steps: @@ -158,7 +199,7 @@ jobs: check-test-failure: name: Check Azle tests didn't fail - needs: run-test + needs: [run-example-tests, run-test-tests] runs-on: ubuntu-latest if: failure() steps: From 45542b55030adfa5b1ad06332c226fe394105d0d Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 4 Oct 2024 17:03:17 -0600 Subject: [PATCH 03/30] this would be crazy --- .github/workflows/test.yml | 215 +++++++++++++++++++++++++++++++++++-- 1 file changed, 206 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2e64da0ce..6a082f0d75 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -137,8 +137,8 @@ jobs: directories: ./examples exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - get-test-test-infos: - name: Get test test infos + get-test-infos-class-syntax: + name: Get test infos for class syntax needs: - determine-should-run-tests - set-exclude-dirs @@ -155,7 +155,112 @@ jobs: uses: ./.github/actions/get_test_infos with: node-version: ${{ steps.get-node-version.outputs.node-version }} - directories: ./tests + directories: ./tests/end_to_end/candid_rpc/class_syntax + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + get-test-infos-functional-syntax: + name: Get test infos for functional syntax + needs: + - determine-should-run-tests + - set-exclude-dirs + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-node-version + uses: ./.github/actions/get_node_version + - name: Get test infos + id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + directories: ./tests/end_to_end/candid_rpc/functional_syntax + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + get-test-infos-http-server: + name: Get test infos for http server + needs: + - determine-should-run-tests + - set-exclude-dirs + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-node-version + uses: ./.github/actions/get_node_version + - name: Get test infos + id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + directories: ./tests/end_to_end/http_server + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + get-test-infos-class-api: + name: Get test infos for class API + needs: + - determine-should-run-tests + - set-exclude-dirs + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-node-version + uses: ./.github/actions/get_node_version + - name: Get test infos + id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + directories: ./tests/property/candid_rpc/class_api + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + get-test-infos-functional-api: + name: Get test infos for functional API + needs: + - determine-should-run-tests + - set-exclude-dirs + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-node-version + uses: ./.github/actions/get_node_version + - name: Get test infos + id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + directories: ./tests/property/candid_rpc/functional_api + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + get-test-infos-ic-api: + name: Get test infos for IC API + needs: + - determine-should-run-tests + - set-exclude-dirs + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-node-version + uses: ./.github/actions/get_node_version + - name: Get test infos + id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + node-version: ${{ steps.get-node-version.outputs.node-version }} + directories: ./tests/property/ic_api exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} run-example-tests: @@ -173,25 +278,108 @@ jobs: secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - run-test-tests: + run-class-syntax-tests: + needs: + - determine-should-run-tests + - get-test-infos-class-syntax + - set-run-conditions + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-test-infos-class-syntax.outputs.test-infos }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + conditions: ${{ needs.set-run-conditions.outputs.conditions }} + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} + + run-functional-syntax-tests: + needs: + - determine-should-run-tests + - get-test-infos-functional-syntax + - set-run-conditions + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-test-infos-functional-syntax.outputs.test-infos }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + conditions: ${{ needs.set-run-conditions.outputs.conditions }} + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} + + run-http-server-tests: needs: - determine-should-run-tests - - get-test-test-infos + - get-test-infos-http-server - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: - test_infos: ${{ needs.get-test-test-infos.outputs.test-infos }} + test_infos: ${{ needs.get-test-infos-http-server.outputs.test-infos }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + conditions: ${{ needs.set-run-conditions.outputs.conditions }} + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} + + run-class-api-tests: + needs: + - determine-should-run-tests + - get-test-infos-class-api + - set-run-conditions + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-test-infos-class-api.outputs.test-infos }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + conditions: ${{ needs.set-run-conditions.outputs.conditions }} + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} + + run-functional-api-tests: + needs: + - determine-should-run-tests + - get-test-infos-functional-api + - set-run-conditions + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-test-infos-functional-api.outputs.test-infos }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + conditions: ${{ needs.set-run-conditions.outputs.conditions }} + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} + + run-ic-api-tests: + needs: + - determine-should-run-tests + - get-test-infos-ic-api + - set-run-conditions + if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-test-infos-ic-api.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - # These final jobs are designed to ensure that all jobs spun up from the matrix in the run-test have succeeded check-test-success: name: Check Azle tests succeeded - needs: [run-example-tests, run-test-tests] + needs: + [ + run-example-tests, + run-class-syntax-tests, + run-functional-syntax-tests, + run-http-server-tests, + run-class-api-tests, + run-functional-api-tests, + run-ic-api-tests + ] runs-on: ubuntu-latest if: success() steps: @@ -199,7 +387,16 @@ jobs: check-test-failure: name: Check Azle tests didn't fail - needs: [run-example-tests, run-test-tests] + needs: + [ + run-example-tests, + run-class-syntax-tests, + run-functional-syntax-tests, + run-http-server-tests, + run-class-api-tests, + run-functional-api-tests, + run-ic-api-tests + ] runs-on: ubuntu-latest if: failure() steps: From 86ffe52b787f8ed7d8fc0ca9b74f211b538379dd Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 11:00:02 -0600 Subject: [PATCH 04/30] move run conditions into action --- .github/actions/set_run_conditions/action.yml | 26 +++++++++++ .github/workflows/run-test.yml | 17 +++---- .github/workflows/test.yml | 45 ++----------------- 3 files changed, 39 insertions(+), 49 deletions(-) create mode 100644 .github/actions/set_run_conditions/action.yml diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml new file mode 100644 index 0000000000..f411dc0a5b --- /dev/null +++ b/.github/actions/set_run_conditions/action.yml @@ -0,0 +1,26 @@ +name: 'Set Run Conditions' +description: 'Sets the run conditions based on the current GitHub context' +outputs: + conditions: + description: 'JSON string of run conditions' + value: ${{ steps.set-conditions.outputs.conditions }} +runs: + using: 'composite' + steps: + - id: set-conditions + run: | + CONDITIONS=$(jq -n \ + --arg is_main_branch_push "${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ + --arg is_main_branch_merge_from_release_push "${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ + --arg is_release_branch_pr "${{ startsWith(github.head_ref, 'release--') }}" \ + --arg is_feature_branch_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }}" \ + --arg is_feature_branch_draft_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }}" \ + '{ + is_main_branch_push: $is_main_branch_push, + is_main_branch_merge_from_release_push: $is_main_branch_merge_from_release_push, + is_release_branch_pr: $is_release_branch_pr, + is_feature_branch_pr: $is_feature_branch_pr, + is_feature_branch_draft_pr: $is_feature_branch_draft_pr + }') + echo "conditions=$(echo $CONDITIONS | base64 -w 0)" >> $GITHUB_OUTPUT + shell: bash diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index eec0700fd1..46630c1053 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -12,9 +12,6 @@ on: os: required: true type: string - conditions: - required: true - type: string secrets: ETHEREUM_URL: required: true @@ -43,13 +40,17 @@ jobs: azle_source: repo tests: ${{ fromJSON(inputs.test_infos) }} steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/set_run_conditions + id: set-conditions - name: Set condition variables run: | - echo "AZLE_IS_MAIN_BRANCH_PUSH=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_main_branch_push)" >> $GITHUB_ENV - echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_main_branch_merge_from_release_push)" >> $GITHUB_ENV - echo "AZLE_IS_RELEASE_BRANCH_PR=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_release_branch_pr)" >> $GITHUB_ENV - echo "AZLE_IS_FEATURE_BRANCH_PR=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_feature_branch_pr)" >> $GITHUB_ENV - echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=$(echo "${{ inputs.conditions }}" | base64 -d | jq -r .is_feature_branch_draft_pr)" >> $GITHUB_ENV + CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) + echo "AZLE_IS_MAIN_BRANCH_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_push)" >> $GITHUB_ENV + echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_merge_from_release_push)" >> $GITHUB_ENV + echo "AZLE_IS_RELEASE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_release_branch_pr)" >> $GITHUB_ENV + echo "AZLE_IS_FEATURE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_pr)" >> $GITHUB_ENV + echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_draft_pr)" >> $GITHUB_ENV - name: Report full path of test run: echo ${{matrix.tests.path}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6a082f0d75..cbc5108230 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,30 +11,6 @@ on: pull_request: # Runs on pull requests to any branch jobs: - set-run-conditions: - name: Set run conditions - runs-on: ubuntu-latest - outputs: - conditions: ${{ steps.set-conditions.outputs.conditions }} - steps: - - id: set-conditions - run: | - CONDITIONS=$(jq -n \ - --arg is_main_branch_push "${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ - --arg is_main_branch_merge_from_release_push "${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ - --arg is_release_branch_pr "${{ startsWith(github.head_ref, 'release--') }}" \ - --arg is_feature_branch_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }}" \ - --arg is_feature_branch_draft_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }}" \ - '{ - is_main_branch_push: $is_main_branch_push, - is_main_branch_merge_from_release_push: $is_main_branch_merge_from_release_push, - is_release_branch_pr: $is_release_branch_pr, - is_feature_branch_pr: $is_feature_branch_pr, - is_feature_branch_draft_pr: $is_feature_branch_draft_pr - }') - echo "conditions=$(echo $CONDITIONS | base64 -w 0)" >> $GITHUB_OUTPUT - - run: echo ${{ steps.set-conditions.outputs.conditions }} - determine-should-run-tests: name: Determine if tests should run runs-on: ubuntu-latest @@ -47,17 +23,18 @@ jobs: set-exclude-dirs: name: Set exclude directories - needs: - - set-run-conditions runs-on: ubuntu-latest outputs: exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/set_run_conditions + id: set-conditions - name: Set exclude dirs id: set-exclude-dirs run: | # Decode the base64 encoded conditions - CONDITIONS=$(echo "${{ needs.set-run-conditions.outputs.conditions }}" | base64 -d) + CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) RELEASE_TESTS="${{ format(' tests/end_to_end/candid_rpc/class_syntax/new @@ -267,14 +244,12 @@ jobs: needs: - determine-should-run-tests - get-example-test-infos - - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-example-test-infos.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' - conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -282,14 +257,12 @@ jobs: needs: - determine-should-run-tests - get-test-infos-class-syntax - - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-test-infos-class-syntax.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' - conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -297,14 +270,12 @@ jobs: needs: - determine-should-run-tests - get-test-infos-functional-syntax - - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-test-infos-functional-syntax.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' - conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -312,14 +283,12 @@ jobs: needs: - determine-should-run-tests - get-test-infos-http-server - - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-test-infos-http-server.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' - conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -327,14 +296,12 @@ jobs: needs: - determine-should-run-tests - get-test-infos-class-api - - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-test-infos-class-api.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' - conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -342,14 +309,12 @@ jobs: needs: - determine-should-run-tests - get-test-infos-functional-api - - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-test-infos-functional-api.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' - conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -357,14 +322,12 @@ jobs: needs: - determine-should-run-tests - get-test-infos-ic-api - - set-run-conditions if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-test-infos-ic-api.outputs.test-infos }} include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} os: '["ubuntu-latest"]' - conditions: ${{ needs.set-run-conditions.outputs.conditions }} secrets: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} From abbb9dfe24f1ca3eab9fa96855e5c477482dd318 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 11:14:33 -0600 Subject: [PATCH 05/30] move node version inside get test infos action --- .github/actions/get_test_infos/README.md | 1 - .github/actions/get_test_infos/action.yml | 26 ++++++++--------------- .github/workflows/test.yml | 21 ------------------ 3 files changed, 9 insertions(+), 39 deletions(-) diff --git a/.github/actions/get_test_infos/README.md b/.github/actions/get_test_infos/README.md index 092f765a2a..7b753ec736 100644 --- a/.github/actions/get_test_infos/README.md +++ b/.github/actions/get_test_infos/README.md @@ -20,7 +20,6 @@ steps: - id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: '20.x' directories: './tests ./examples' exclude-dirs: 'tests/exclude_this_directory examples/exclude_this exclude_all_with_this_dir_in_path' diff --git a/.github/actions/get_test_infos/action.yml b/.github/actions/get_test_infos/action.yml index 9cb22a9737..c1651f5ac8 100644 --- a/.github/actions/get_test_infos/action.yml +++ b/.github/actions/get_test_infos/action.yml @@ -1,34 +1,26 @@ -name: Get test infos -description: - 'Gets a list of test info objects for each npm project with an npm test script - The shape of the object is - { - path: string, // The path to the test - name: string, // The name of the test - type: string, // The type of test (e.g. ex (example), prop (property test), e2e, (end to end test) etc) - displayPath: string // An abbreviated version of the path for display purposes only - }' +name: 'Get Test Infos' +description: 'Gets a list of test info objects for each npm project with an npm test script' inputs: - node-version: - description: The version of Node.js to use - required: true directories: - description: List of directories to search for npm projects with an npm test script + description: 'List of directories to search for npm projects with an npm test script' required: true exclude-dirs: - description: List of directories to exclude from the search + description: 'List of directories to exclude from the search' required: false default: '' outputs: test-infos: - description: All of the test info objects found by this action + description: 'All of the test info objects found by this action' value: ${{ steps.get-test-infos.outputs.test-infos }} runs: using: composite steps: + - id: get-node-version + uses: ./.github/actions/get_node_version + - uses: actions/setup-node@v4 with: - node-version: ${{ inputs.node-version }} + node-version: ${{ steps.get-node-version.outputs.node-version }} - name: Get test infos id: get-test-infos diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cbc5108230..d98c019dba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,13 +104,10 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: ${{ steps.get-node-version.outputs.node-version }} directories: ./examples exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} @@ -125,13 +122,10 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: ${{ steps.get-node-version.outputs.node-version }} directories: ./tests/end_to_end/candid_rpc/class_syntax exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} @@ -146,13 +140,10 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: ${{ steps.get-node-version.outputs.node-version }} directories: ./tests/end_to_end/candid_rpc/functional_syntax exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} @@ -167,13 +158,10 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: ${{ steps.get-node-version.outputs.node-version }} directories: ./tests/end_to_end/http_server exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} @@ -188,13 +176,10 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: ${{ steps.get-node-version.outputs.node-version }} directories: ./tests/property/candid_rpc/class_api exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} @@ -209,13 +194,10 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: ${{ steps.get-node-version.outputs.node-version }} directories: ./tests/property/candid_rpc/functional_api exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} @@ -230,13 +212,10 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-node-version - uses: ./.github/actions/get_node_version - name: Get test infos id: get-test-infos uses: ./.github/actions/get_test_infos with: - node-version: ${{ steps.get-node-version.outputs.node-version }} directories: ./tests/property/ic_api exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} From eb31aec8d05f35e921b418cd25165fcc2f7ef475 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 11:18:42 -0600 Subject: [PATCH 06/30] remove name to prefer just id --- .github/workflows/test.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d98c019dba..a9df9a49c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,8 +104,7 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - name: Get test infos - id: get-test-infos + - id: get-test-infos uses: ./.github/actions/get_test_infos with: directories: ./examples @@ -122,8 +121,7 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - name: Get test infos - id: get-test-infos + - id: get-test-infos uses: ./.github/actions/get_test_infos with: directories: ./tests/end_to_end/candid_rpc/class_syntax @@ -140,8 +138,7 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - name: Get test infos - id: get-test-infos + - id: get-test-infos uses: ./.github/actions/get_test_infos with: directories: ./tests/end_to_end/candid_rpc/functional_syntax @@ -158,8 +155,7 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - name: Get test infos - id: get-test-infos + - id: get-test-infos uses: ./.github/actions/get_test_infos with: directories: ./tests/end_to_end/http_server @@ -176,8 +172,7 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - name: Get test infos - id: get-test-infos + - id: get-test-infos uses: ./.github/actions/get_test_infos with: directories: ./tests/property/candid_rpc/class_api @@ -194,8 +189,7 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - name: Get test infos - id: get-test-infos + - id: get-test-infos uses: ./.github/actions/get_test_infos with: directories: ./tests/property/candid_rpc/functional_api @@ -212,8 +206,7 @@ jobs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - name: Get test infos - id: get-test-infos + - id: get-test-infos uses: ./.github/actions/get_test_infos with: directories: ./tests/property/ic_api From 5afdaabb087fd2e7f1150292376799250863363c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 12:08:58 -0600 Subject: [PATCH 07/30] try using variables instead of jq --- .github/actions/set_run_conditions/action.yml | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml index f411dc0a5b..3e7067e205 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/set_run_conditions/action.yml @@ -9,18 +9,25 @@ runs: steps: - id: set-conditions run: | - CONDITIONS=$(jq -n \ - --arg is_main_branch_push "${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ - --arg is_main_branch_merge_from_release_push "${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }}" \ - --arg is_release_branch_pr "${{ startsWith(github.head_ref, 'release--') }}" \ - --arg is_feature_branch_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }}" \ - --arg is_feature_branch_draft_pr "${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }}" \ - '{ - is_main_branch_push: $is_main_branch_push, - is_main_branch_merge_from_release_push: $is_main_branch_merge_from_release_push, - is_release_branch_pr: $is_release_branch_pr, - is_feature_branch_pr: $is_feature_branch_pr, - is_feature_branch_draft_pr: $is_feature_branch_draft_pr - }') + # Define conditions using shell variables + IS_MAIN_PUSH=${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }} + IS_MAIN_MERGE_RELEASE=${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }} + IS_RELEASE_PR=${{ startsWith(github.head_ref, 'release--') }} + IS_FEATURE_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }} + IS_DRAFT_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }} + + # Create JSON object + CONDITIONS=$(cat <> $GITHUB_OUTPUT shell: bash From bcedb3bfc9c4b11756706a5faa27ebbfdfca2f7a Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 13:38:44 -0600 Subject: [PATCH 08/30] fold into one action --- .github/actions/get_and_run_tests/action.yml | 35 +++ .github/workflows/test.yml | 254 +++---------------- 2 files changed, 69 insertions(+), 220 deletions(-) create mode 100644 .github/actions/get_and_run_tests/action.yml diff --git a/.github/actions/get_and_run_tests/action.yml b/.github/actions/get_and_run_tests/action.yml new file mode 100644 index 0000000000..7844e947ae --- /dev/null +++ b/.github/actions/get_and_run_tests/action.yml @@ -0,0 +1,35 @@ +name: 'Get and Run Tests' +description: 'Gets test infos for a specific directory and runs the tests' +inputs: + directories: + description: 'Directories to search for tests' + required: true + exclude-dirs: + description: 'Directories to exclude from the search' + required: false + default: '' + include_npm: + description: 'Whether to include npm tests' + required: true + os: + description: 'Operating systems to run tests on' + required: true + ethereum_url: + description: 'Ethereum URL for tests' + required: true +runs: + using: 'composite' + steps: + - id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + directories: ${{ inputs.directories }} + exclude-dirs: ${{ inputs.exclude-dirs }} + + - name: Run tests + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ steps.get-test-infos.outputs.test-infos }} + include_npm: ${{ inputs.include_npm }} + os: ${{ inputs.os }} + ethereum_url: ${{ inputs.ethereum_url }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9df9a49c0..0799139d0a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,228 +93,51 @@ jobs: EXCLUDE_DIRS=$(echo $EXCLUDE_DIRS | xargs) echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT - get-example-test-infos: - name: Get example test infos + run-tests: needs: - determine-should-run-tests - set-exclude-dirs if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + strategy: + fail-fast: false + matrix: + test_group: + - { name: 'Examples', directories: './examples' } + - { + name: 'Class Syntax', + directories: './tests/end_to_end/candid_rpc/class_syntax' + } + - { + name: 'Functional Syntax', + directories: './tests/end_to_end/candid_rpc/functional_syntax' + } + - { + name: 'HTTP Server', + directories: './tests/end_to_end/http_server' + } + - { + name: 'Class API', + directories: './tests/property/candid_rpc/class_api' + } + - { + name: 'Functional API', + directories: './tests/property/candid_rpc/functional_api' + } + - { name: 'IC API', directories: './tests/property/ic_api' } runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} steps: - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos + - uses: ./.github/actions/get_and_run_tests with: - directories: ./examples + directories: ${{ matrix.test_group.directories }} exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - get-test-infos-class-syntax: - name: Get test infos for class syntax - needs: - - determine-should-run-tests - - set-exclude-dirs - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} - steps: - - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ./tests/end_to_end/candid_rpc/class_syntax - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - get-test-infos-functional-syntax: - name: Get test infos for functional syntax - needs: - - determine-should-run-tests - - set-exclude-dirs - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} - steps: - - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ./tests/end_to_end/candid_rpc/functional_syntax - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - get-test-infos-http-server: - name: Get test infos for http server - needs: - - determine-should-run-tests - - set-exclude-dirs - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} - steps: - - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ./tests/end_to_end/http_server - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - get-test-infos-class-api: - name: Get test infos for class API - needs: - - determine-should-run-tests - - set-exclude-dirs - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} - steps: - - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ./tests/property/candid_rpc/class_api - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - get-test-infos-functional-api: - name: Get test infos for functional API - needs: - - determine-should-run-tests - - set-exclude-dirs - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} - steps: - - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ./tests/property/candid_rpc/functional_api - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - get-test-infos-ic-api: - name: Get test infos for IC API - needs: - - determine-should-run-tests - - set-exclude-dirs - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} - steps: - - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ./tests/property/ic_api - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - run-example-tests: - needs: - - determine-should-run-tests - - get-example-test-infos - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ needs.get-example-test-infos.outputs.test-infos }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - - run-class-syntax-tests: - needs: - - determine-should-run-tests - - get-test-infos-class-syntax - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ needs.get-test-infos-class-syntax.outputs.test-infos }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - - run-functional-syntax-tests: - needs: - - determine-should-run-tests - - get-test-infos-functional-syntax - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ needs.get-test-infos-functional-syntax.outputs.test-infos }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - - run-http-server-tests: - needs: - - determine-should-run-tests - - get-test-infos-http-server - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ needs.get-test-infos-http-server.outputs.test-infos }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - - run-class-api-tests: - needs: - - determine-should-run-tests - - get-test-infos-class-api - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ needs.get-test-infos-class-api.outputs.test-infos }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - - run-functional-api-tests: - needs: - - determine-should-run-tests - - get-test-infos-functional-api - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ needs.get-test-infos-functional-api.outputs.test-infos }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} - - run-ic-api-tests: - needs: - - determine-should-run-tests - - get-test-infos-ic-api - if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ needs.get-test-infos-ic-api.outputs.test-infos }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + ethereum_url: ${{ secrets.ETHEREUM_URL }} check-test-success: name: Check Azle tests succeeded - needs: - [ - run-example-tests, - run-class-syntax-tests, - run-functional-syntax-tests, - run-http-server-tests, - run-class-api-tests, - run-functional-api-tests, - run-ic-api-tests - ] + needs: [run-tests] runs-on: ubuntu-latest if: success() steps: @@ -322,16 +145,7 @@ jobs: check-test-failure: name: Check Azle tests didn't fail - needs: - [ - run-example-tests, - run-class-syntax-tests, - run-functional-syntax-tests, - run-http-server-tests, - run-class-api-tests, - run-functional-api-tests, - run-ic-api-tests - ] + needs: [run-tests] runs-on: ubuntu-latest if: failure() steps: From 6f135d8a3bf55f23fa3ab8b20550170a72cc9716 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 13:45:50 -0600 Subject: [PATCH 09/30] move get and run tests to a workflow --- .github/actions/get_and_run_tests/action.yml | 35 ---------------- .github/workflows/get_and_run_tests.yml | 44 ++++++++++++++++++++ .github/workflows/test.yml | 18 ++++---- 3 files changed, 52 insertions(+), 45 deletions(-) delete mode 100644 .github/actions/get_and_run_tests/action.yml create mode 100644 .github/workflows/get_and_run_tests.yml diff --git a/.github/actions/get_and_run_tests/action.yml b/.github/actions/get_and_run_tests/action.yml deleted file mode 100644 index 7844e947ae..0000000000 --- a/.github/actions/get_and_run_tests/action.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: 'Get and Run Tests' -description: 'Gets test infos for a specific directory and runs the tests' -inputs: - directories: - description: 'Directories to search for tests' - required: true - exclude-dirs: - description: 'Directories to exclude from the search' - required: false - default: '' - include_npm: - description: 'Whether to include npm tests' - required: true - os: - description: 'Operating systems to run tests on' - required: true - ethereum_url: - description: 'Ethereum URL for tests' - required: true -runs: - using: 'composite' - steps: - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ${{ inputs.directories }} - exclude-dirs: ${{ inputs.exclude-dirs }} - - - name: Run tests - uses: ./.github/workflows/run-test.yml - with: - test_infos: ${{ steps.get-test-infos.outputs.test-infos }} - include_npm: ${{ inputs.include_npm }} - os: ${{ inputs.os }} - ethereum_url: ${{ inputs.ethereum_url }} diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml new file mode 100644 index 0000000000..e5a603256c --- /dev/null +++ b/.github/workflows/get_and_run_tests.yml @@ -0,0 +1,44 @@ +name: Get and Run Tests + +on: + workflow_call: + inputs: + directories: + required: true + type: string + exclude-dirs: + required: false + type: string + default: '' + include_npm: + required: true + type: boolean + os: + required: true + type: string + secrets: + ETHEREUM_URL: + required: true + +jobs: + get-test-infos: + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + directories: ${{ inputs.directories }} + exclude-dirs: ${{ inputs.exclude-dirs }} + + run-tests: + needs: get-test-infos + uses: ./.github/workflows/run-test.yml + with: + test_infos: ${{ needs.get-test-infos.outputs.test-infos }} + include_npm: ${{ inputs.include_npm }} + os: ${{ inputs.os }} + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0799139d0a..1190d8a9f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -124,16 +124,14 @@ jobs: directories: './tests/property/candid_rpc/functional_api' } - { name: 'IC API', directories: './tests/property/ic_api' } - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/get_and_run_tests - with: - directories: ${{ matrix.test_group.directories }} - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - ethereum_url: ${{ secrets.ETHEREUM_URL }} + uses: ./.github/workflows/get_and_run_tests.yml + with: + directories: ${{ matrix.test_group.directories }} + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} + os: '["ubuntu-latest"]' + secrets: + ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} check-test-success: name: Check Azle tests succeeded From 9001e670f726398553a9a7057e40de9654a8478c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 13:59:46 -0600 Subject: [PATCH 10/30] update names --- .github/workflows/get_and_run_tests.yml | 2 ++ .github/workflows/test.yml | 26 ++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml index e5a603256c..6f287818a7 100644 --- a/.github/workflows/get_and_run_tests.yml +++ b/.github/workflows/get_and_run_tests.yml @@ -22,6 +22,7 @@ on: jobs: get-test-infos: + name: 'Get Test Infos' runs-on: ubuntu-latest outputs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} @@ -34,6 +35,7 @@ jobs: exclude-dirs: ${{ inputs.exclude-dirs }} run-tests: + name: 'Run' needs: get-test-infos uses: ./.github/workflows/run-test.yml with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1190d8a9f2..8d4deb31e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,12 +28,12 @@ jobs: exclude-dirs: ${{ steps.set-exclude-dirs.outputs.exclude-dirs }} steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/set_run_conditions - id: set-conditions - - name: Set exclude dirs - id: set-exclude-dirs + + - id: set-conditions + uses: ./.github/actions/set_run_conditions + + - id: set-exclude-dirs run: | - # Decode the base64 encoded conditions CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) RELEASE_TESTS="${{ format(' @@ -94,6 +94,7 @@ jobs: echo "exclude-dirs=$EXCLUDE_DIRS" >> $GITHUB_OUTPUT run-tests: + name: ${{ matrix.test_group.name }} needs: - determine-should-run-tests - set-exclude-dirs @@ -104,26 +105,29 @@ jobs: test_group: - { name: 'Examples', directories: './examples' } - { - name: 'Class Syntax', + name: 'E2E Class', directories: './tests/end_to_end/candid_rpc/class_syntax' } - { - name: 'Functional Syntax', + name: 'E2E Functional', directories: './tests/end_to_end/candid_rpc/functional_syntax' } - { - name: 'HTTP Server', + name: 'E2E HTTP Server', directories: './tests/end_to_end/http_server' } - { - name: 'Class API', + name: 'Property Class', directories: './tests/property/candid_rpc/class_api' } - { - name: 'Functional API', + name: 'Property Functional', directories: './tests/property/candid_rpc/functional_api' } - - { name: 'IC API', directories: './tests/property/ic_api' } + - { + name: 'Property IC API', + directories: './tests/property/ic_api' + } uses: ./.github/workflows/get_and_run_tests.yml with: directories: ${{ matrix.test_group.directories }} From 36df50ffc5bed7229a4d253e421417196fad20a9 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 15:34:24 -0600 Subject: [PATCH 11/30] improve readability --- .github/workflows/get_and_run_tests.yml | 2 +- .github/workflows/run-test.yml | 4 +++- .github/workflows/test.yml | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml index 6f287818a7..4590f9d32e 100644 --- a/.github/workflows/get_and_run_tests.yml +++ b/.github/workflows/get_and_run_tests.yml @@ -22,7 +22,7 @@ on: jobs: get-test-infos: - name: 'Get Test Infos' + name: 'Get test infos' runs-on: ubuntu-latest outputs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 46630c1053..66bbe1cac4 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -43,7 +43,7 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/set_run_conditions id: set-conditions - - name: Set condition variables + - name: Set condition environment variables run: | CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) echo "AZLE_IS_MAIN_BRANCH_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_push)" >> $GITHUB_ENV @@ -125,6 +125,8 @@ jobs: RUNS=1 fi + echo "Running tests $RUNS times" + AZLE_PROPTEST_NUM_RUNS=$RUNS AZLE_PROPTEST_VERBOSE=true npm test shell: bash -l {0} working-directory: ${{ matrix.tests.path }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d4deb31e2..8d9d48cba3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,6 +35,11 @@ jobs: - id: set-exclude-dirs run: | CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) + IS_MAIN_BRANCH_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_push) + IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_merge_from_release_push) + IS_RELEASE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_release_branch_pr) + IS_FEATURE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_pr) + IS_FEATURE_BRANCH_DRAFT_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_draft_pr) RELEASE_TESTS="${{ format(' tests/end_to_end/candid_rpc/class_syntax/new @@ -70,23 +75,23 @@ jobs: EXCLUDE_DIRS="" - if [[ "$(echo $CONDITIONS | jq -r .is_main_branch_push)" == "true" ]]; then + if [[ "$IS_MAIN_BRANCH_PUSH" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "$(echo $CONDITIONS | jq -r .is_main_branch_merge_from_release_push)" == "true" ]]; then + if [[ "$IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "$(echo $CONDITIONS | jq -r .is_release_branch_pr)" == "true" ]]; then + if [[ "$IS_RELEASE_BRANCH_PR" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "$(echo $CONDITIONS | jq -r .is_feature_branch_pr)" == "true" ]]; then + if [[ "$IS_FEATURE_BRANCH_PR" == "true" ]]; then EXCLUDE_DIRS="$RELEASE_TESTS $UNSTABLE_TESTS" fi - if [[ "$(echo $CONDITIONS | jq -r .is_feature_branch_draft_pr)" == "true" ]]; then + if [[ "$IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then EXCLUDE_DIRS="$RELEASE_TESTS $UNSTABLE_TESTS $SLOW_TESTS" fi From 34957040fd3eb5262707529fc5068e7da70e0948 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 15:37:22 -0600 Subject: [PATCH 12/30] move os and include npm into the run tests workflow --- .github/workflows/get_and_run_tests.yml | 13 ------------- .github/workflows/run-test.yml | 15 ++++----------- .github/workflows/test.yml | 4 ---- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml index 4590f9d32e..f2ff6e78f0 100644 --- a/.github/workflows/get_and_run_tests.yml +++ b/.github/workflows/get_and_run_tests.yml @@ -10,15 +10,6 @@ on: required: false type: string default: '' - include_npm: - required: true - type: boolean - os: - required: true - type: string - secrets: - ETHEREUM_URL: - required: true jobs: get-test-infos: @@ -40,7 +31,3 @@ jobs: uses: ./.github/workflows/run-test.yml with: test_infos: ${{ needs.get-test-infos.outputs.test-infos }} - include_npm: ${{ inputs.include_npm }} - os: ${{ inputs.os }} - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 66bbe1cac4..92f036d557 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -6,15 +6,6 @@ on: test_infos: required: true type: string - include_npm: - required: true - type: boolean - os: - required: true - type: string - secrets: - ETHEREUM_URL: - required: true jobs: run-test: @@ -27,9 +18,11 @@ jobs: strategy: fail-fast: false matrix: - os: ${{ fromJSON(inputs.os) }} + # os: [macos-latest] + os: [ubuntu-latest] include_npm: - - ${{ inputs.include_npm }} + # Only include npm in the matrix if you've pushed to main and the last commit was a merge of a release branch, or the base branch of the pull request is a release branch + - ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} azle_source: - npm - repo diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8d9d48cba3..931415d501 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -137,10 +137,6 @@ jobs: with: directories: ${{ matrix.test_group.directories }} exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - include_npm: ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} - os: '["ubuntu-latest"]' - secrets: - ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} check-test-success: name: Check Azle tests succeeded From 65250e6f4d9b4d767be81cbea1a13fef700951ab Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 16:05:49 -0600 Subject: [PATCH 13/30] bring back comments --- .github/actions/get_test_infos/action.yml | 10 +++++++++- .github/actions/set_run_conditions/action.yml | 2 +- .github/workflows/test.yml | 7 +++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/actions/get_test_infos/action.yml b/.github/actions/get_test_infos/action.yml index c1651f5ac8..6d288cf68e 100644 --- a/.github/actions/get_test_infos/action.yml +++ b/.github/actions/get_test_infos/action.yml @@ -1,5 +1,13 @@ name: 'Get Test Infos' -description: 'Gets a list of test info objects for each npm project with an npm test script' +description: + 'Gets a list of test info objects for each npm project with an npm test script + The shape of the object is + { + path: string, // The path to the test + name: string, // The name of the test + type: string, // The type of test (e.g. ex (example), prop (property test), e2e, (end to end test) etc) + displayPath: string // An abbreviated version of the path for display purposes only + }' inputs: directories: description: 'List of directories to search for npm projects with an npm test script' diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml index 3e7067e205..139491e70d 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/set_run_conditions/action.yml @@ -1,4 +1,4 @@ -name: 'Set Run Conditions' +name: 'Set run conditions' description: 'Sets the run conditions based on the current GitHub context' outputs: conditions: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 931415d501..9a958115b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,9 +15,11 @@ jobs: name: Determine if tests should run 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 @@ -95,6 +97,7 @@ jobs: 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 @@ -140,7 +143,7 @@ jobs: check-test-success: name: Check Azle tests succeeded - needs: [run-tests] + needs: run-tests runs-on: ubuntu-latest if: success() steps: @@ -148,7 +151,7 @@ jobs: check-test-failure: name: Check Azle tests didn't fail - needs: [run-tests] + needs: run-tests runs-on: ubuntu-latest if: failure() steps: From 7e1fa2b8dc618e3806cd040156151ea782b5f458 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 16:11:47 -0600 Subject: [PATCH 14/30] bring back dfx without artificial delay and comments --- .github/workflows/run-test.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 92f036d557..2a21ee4660 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -9,15 +9,15 @@ on: jobs: run-test: - name: '${{matrix.tests.name}} | ${{matrix.tests.displayPath}} | ${{matrix.azle_source}} | ${{matrix.os}}' + name: '${{matrix.tests.name}} | ${{matrix.tests.displayPath}} | ${{matrix.azle_source}}' runs-on: ${{ matrix.os }} env: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} AZLE_IDENTITY_STORAGE_MODE: 'plaintext' AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }} strategy: - fail-fast: false - matrix: + fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest + matrix: # spins up one job per combination of test and code source (repo or npm). # os: [macos-latest] os: [ubuntu-latest] include_npm: @@ -31,6 +31,7 @@ jobs: azle_source: npm - include_npm: true azle_source: repo + # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element tests: ${{ fromJSON(inputs.test_infos) }} steps: - uses: actions/checkout@v4 @@ -46,6 +47,7 @@ jobs: echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_draft_pr)" >> $GITHUB_ENV - name: Report full path of test + # Just in case the path isn't obvious from the name, this will remove ambiguity run: echo ${{matrix.tests.path}} - uses: actions/checkout@v4 @@ -62,9 +64,12 @@ jobs: - name: Run pre-test Azle setup run: | + + # Install dfx (Note: DFX must be installed before `npm install` because the azle installation process requires dfx) src/build/stable/commands/install_global_dependencies/install_dfx.sh ${{ steps.get-dfx-version.outputs.dfx-version }} echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH + # MacOS-specific DNS configuration if [[ "${{ matrix.os }}" == "macos-latest" ]]; then sudo networksetup -setdnsservers Ethernet 9.9.9.9 fi @@ -91,9 +96,15 @@ jobs: shell: bash -l {0} - name: Start dfx with artificial delay 0 + if: ${{ env.AZLE_IS_FEATURE_BRANCH_PR == 'true' || env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR == 'true' }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 + - name: Start dfx + if: ${{ env.AZLE_IS_RELEASE_BRANCH_PR == 'true' || env.AZLE_IS_MAIN_BRANCH_PUSH == 'true' || env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH == 'true' }} + working-directory: ${{ matrix.tests.path }} + run: dfx start --clean --background --host 127.0.0.1:8000 + - name: Run test run: | RUNS=1 From e0cf9b174763d09a284a09789701518988176ab9 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 16:17:15 -0600 Subject: [PATCH 15/30] check conditions --- .github/workflows/run-test.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 2a21ee4660..a9eaa64f56 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -46,6 +46,19 @@ jobs: echo "AZLE_IS_FEATURE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_pr)" >> $GITHUB_ENV echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_draft_pr)" >> $GITHUB_ENV + - id: check-conditions + run: | + echo "AZLE_IS_MAIN_BRANCH_PUSH: ${{ env.AZLE_IS_MAIN_BRANCH_PUSH }}" + echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: ${{ env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH }}" + echo "AZLE_IS_RELEASE_BRANCH_PR: ${{ env.AZLE_IS_RELEASE_BRANCH_PR }}" + echo "AZLE_IS_FEATURE_BRANCH_PR: ${{ env.AZLE_IS_FEATURE_BRANCH_PR }}" + echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR: ${{ env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR }}" + echo "AZLE_IS_MAIN_BRANCH_PUSH: $AZLE_IS_MAIN_BRANCH_PUSH" + echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: $AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH" + echo "AZLE_IS_RELEASE_BRANCH_PR: $AZLE_IS_RELEASE_BRANCH_PR" + echo "AZLE_IS_FEATURE_BRANCH_PR: $AZLE_IS_FEATURE_BRANCH_PR" + echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR: $AZLE_IS_FEATURE_BRANCH_DRAFT_PR" + - name: Report full path of test # Just in case the path isn't obvious from the name, this will remove ambiguity run: echo ${{matrix.tests.path}} From 85bd45dbab702adcca358e9c27a102f38ec3a7e1 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 8 Oct 2024 16:25:44 -0600 Subject: [PATCH 16/30] restore lower case --- .github/actions/get_test_infos/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/get_test_infos/action.yml b/.github/actions/get_test_infos/action.yml index 6d288cf68e..5c421bb733 100644 --- a/.github/actions/get_test_infos/action.yml +++ b/.github/actions/get_test_infos/action.yml @@ -1,4 +1,4 @@ -name: 'Get Test Infos' +name: 'Get test infos' description: 'Gets a list of test info objects for each npm project with an npm test script The shape of the object is From 8c31c998d22b289fb0bd0cdc2d34c022c4e3b1b7 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 9 Oct 2024 12:09:32 -0600 Subject: [PATCH 17/30] set env variables to be '' by default --- .github/workflows/run-test.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index a9eaa64f56..227e024a95 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -15,6 +15,12 @@ jobs: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} AZLE_IDENTITY_STORAGE_MODE: 'plaintext' AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }} + AZLE_IS_MAIN_BRANCH_PUSH: '' + AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: '' + AZLE_IS_RELEASE_BRANCH_PR: '' + AZLE_IS_FEATURE_BRANCH_PR: '' + AZLE_IS_FEATURE_BRANCH_DRAFT_PR: '' + strategy: fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest matrix: # spins up one job per combination of test and code source (repo or npm). @@ -48,11 +54,6 @@ jobs: - id: check-conditions run: | - echo "AZLE_IS_MAIN_BRANCH_PUSH: ${{ env.AZLE_IS_MAIN_BRANCH_PUSH }}" - echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: ${{ env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH }}" - echo "AZLE_IS_RELEASE_BRANCH_PR: ${{ env.AZLE_IS_RELEASE_BRANCH_PR }}" - echo "AZLE_IS_FEATURE_BRANCH_PR: ${{ env.AZLE_IS_FEATURE_BRANCH_PR }}" - echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR: ${{ env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR }}" echo "AZLE_IS_MAIN_BRANCH_PUSH: $AZLE_IS_MAIN_BRANCH_PUSH" echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: $AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH" echo "AZLE_IS_RELEASE_BRANCH_PR: $AZLE_IS_RELEASE_BRANCH_PR" From 9d08830374a17020ac24e4366e1447a50ba59042 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 9 Oct 2024 12:20:11 -0600 Subject: [PATCH 18/30] fix spacing --- .github/workflows/run-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 227e024a95..c9f0e3a3ce 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -41,8 +41,10 @@ jobs: tests: ${{ fromJSON(inputs.test_infos) }} steps: - uses: actions/checkout@v4 + - uses: ./.github/actions/set_run_conditions id: set-conditions + - name: Set condition environment variables run: | CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) @@ -64,8 +66,6 @@ jobs: # Just in case the path isn't obvious from the name, this will remove ambiguity run: echo ${{matrix.tests.path}} - - uses: actions/checkout@v4 - - id: get-node-version uses: ./.github/actions/get_node_version From 8ba60a132842d20a80af02da69337f5cf088de17 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 9 Oct 2024 12:28:12 -0600 Subject: [PATCH 19/30] use underscore instead of dash --- .github/workflows/get_and_run_tests.yml | 2 +- .github/workflows/{run-test.yml => run_test.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{run-test.yml => run_test.yml} (100%) diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml index f2ff6e78f0..68f4e9a75e 100644 --- a/.github/workflows/get_and_run_tests.yml +++ b/.github/workflows/get_and_run_tests.yml @@ -28,6 +28,6 @@ jobs: run-tests: name: 'Run' needs: get-test-infos - uses: ./.github/workflows/run-test.yml + uses: ./.github/workflows/run_test.yml with: test_infos: ${{ needs.get-test-infos.outputs.test-infos }} diff --git a/.github/workflows/run-test.yml b/.github/workflows/run_test.yml similarity index 100% rename from .github/workflows/run-test.yml rename to .github/workflows/run_test.yml From 6c793efe150797d0a32d6470d3f5430c4cc65e4f Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 18 Oct 2024 16:10:57 -0600 Subject: [PATCH 20/30] pr fixes --- .github/actions/set_run_conditions/README.md | 30 +++++++++++++++ .github/actions/set_run_conditions/action.yml | 38 ++++++++++--------- .github/workflows/test.yml | 16 ++++---- 3 files changed, 59 insertions(+), 25 deletions(-) create mode 100644 .github/actions/set_run_conditions/README.md diff --git a/.github/actions/set_run_conditions/README.md b/.github/actions/set_run_conditions/README.md new file mode 100644 index 0000000000..e33311a3ea --- /dev/null +++ b/.github/actions/set_run_conditions/README.md @@ -0,0 +1,30 @@ +## 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 +steps: + - uses: actions/checkout@v4 + + - id: set-run-conditions + uses: ./.github/actions/set_run_conditions + + - name: Use run conditions + run: | + echo "Is main branch push: ${{ steps.set-run-conditions.outputs.is_main_branch_push }}" + echo "Is main branch merge from release: ${{ steps.set-run-conditions.outputs.is_main_branch_merge_from_release_push }}" + echo "Is release branch PR: ${{ steps.set-run-conditions.outputs.is_release_branch_pr }}" + echo "Is feature branch PR: ${{ steps.set-run-conditions.outputs.is_feature_branch_pr }}" + echo "Is feature branch draft PR: ${{ steps.set-run-conditions.outputs.is_feature_branch_draft_pr }}" +``` diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml index 139491e70d..cc031810e8 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/set_run_conditions/action.yml @@ -1,9 +1,21 @@ name: 'Set run conditions' description: 'Sets the run conditions based on the current GitHub context' outputs: - conditions: - description: 'JSON string of run conditions' - value: ${{ steps.set-conditions.outputs.conditions }} + is_main_branch_push: + description: 'True if this is a push to the main branch (excluding merges from release branches)' + value: ${{ steps.set-conditions.outputs.is_main_branch_push }} + is_main_branch_merge_from_release_push: + description: 'True if this is a push to the main branch from a release branch merge' + value: ${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }} + is_release_branch_pr: + description: 'True if this is a pull request from a release branch' + value: ${{ steps.set-conditions.outputs.is_release_branch_pr }} + is_feature_branch_pr: + description: 'True if this is a pull request from a feature branch (non-draft)' + value: ${{ steps.set-conditions.outputs.is_feature_branch_pr }} + is_feature_branch_draft_pr: + description: 'True if this is a draft pull request from a feature branch' + value: ${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }} runs: using: 'composite' steps: @@ -16,18 +28,10 @@ runs: IS_FEATURE_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }} IS_DRAFT_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }} - # Create JSON object - CONDITIONS=$(cat <> $GITHUB_OUTPUT + # Set individual outputs + echo "is_main_branch_push=$IS_MAIN_PUSH" >> $GITHUB_OUTPUT + echo "is_main_branch_merge_from_release_push=$IS_MAIN_MERGE_RELEASE" >> $GITHUB_OUTPUT + echo "is_release_branch_pr=$IS_RELEASE_PR" >> $GITHUB_OUTPUT + echo "is_feature_branch_pr=$IS_FEATURE_PR" >> $GITHUB_OUTPUT + echo "is_feature_branch_draft_pr=$IS_DRAFT_PR" >> $GITHUB_OUTPUT shell: bash diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a958115b6..4e8529eb22 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,8 @@ # These tests are currently written in TypeScript and are intended to be run in a Node.js environment. # This GitHub Action takes care of deploying to npm and GitHub. -name: Tests +name: Test + on: push: branches: @@ -36,13 +37,6 @@ jobs: - id: set-exclude-dirs run: | - CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) - IS_MAIN_BRANCH_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_push) - IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_merge_from_release_push) - IS_RELEASE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_release_branch_pr) - IS_FEATURE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_pr) - IS_FEATURE_BRANCH_DRAFT_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_draft_pr) - RELEASE_TESTS="${{ format(' tests/end_to_end/candid_rpc/class_syntax/new tests/end_to_end/http_server/new @@ -75,6 +69,12 @@ jobs: tests/end_to_end/http_server/autoreload ') }}" + IS_MAIN_BRANCH_PUSH="${{ steps.set-conditions.outputs.is_main_branch_push }}" + IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH="${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" + IS_RELEASE_BRANCH_PR="${{ steps.set-conditions.outputs.is_release_branch_pr }}" + IS_FEATURE_BRANCH_PR="${{ steps.set-conditions.outputs.is_feature_branch_pr }}" + IS_FEATURE_BRANCH_DRAFT_PR="${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" + EXCLUDE_DIRS="" if [[ "$IS_MAIN_BRANCH_PUSH" == "true" ]]; then From 9ea228cfa5c5ab8bc89b8da2ee1bec928f342c4c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 18 Oct 2024 16:16:16 -0600 Subject: [PATCH 21/30] fixup --- .github/workflows/run_test.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index c9f0e3a3ce..fc3996e352 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -47,12 +47,11 @@ jobs: - name: Set condition environment variables run: | - CONDITIONS=$(echo "${{ steps.set-conditions.outputs.conditions }}" | base64 -d) - echo "AZLE_IS_MAIN_BRANCH_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_push)" >> $GITHUB_ENV - echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=$(echo $CONDITIONS | jq -r .is_main_branch_merge_from_release_push)" >> $GITHUB_ENV - echo "AZLE_IS_RELEASE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_release_branch_pr)" >> $GITHUB_ENV - echo "AZLE_IS_FEATURE_BRANCH_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_pr)" >> $GITHUB_ENV - echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=$(echo $CONDITIONS | jq -r .is_feature_branch_draft_pr)" >> $GITHUB_ENV + echo "AZLE_IS_MAIN_BRANCH_PUSH=${{ steps.set-conditions.outputs.is_main_branch_push }}" >> $GITHUB_ENV + echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" >> $GITHUB_ENV + echo "AZLE_IS_RELEASE_BRANCH_PR=${{ steps.set-conditions.outputs.is_release_branch_pr }}" >> $GITHUB_ENV + echo "AZLE_IS_FEATURE_BRANCH_PR=${{ steps.set-conditions.outputs.is_feature_branch_pr }}" >> $GITHUB_ENV + echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" >> $GITHUB_ENV - id: check-conditions run: | @@ -110,12 +109,12 @@ jobs: shell: bash -l {0} - name: Start dfx with artificial delay 0 - if: ${{ env.AZLE_IS_FEATURE_BRANCH_PR == 'true' || env.AZLE_IS_FEATURE_BRANCH_DRAFT_PR == 'true' }} + if: ${{ steps.set-conditions.outputs.is_feature_branch_pr == 'true' || steps.set-conditions.outputs.is_feature_branch_draft_pr == 'true' }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - name: Start dfx - if: ${{ env.AZLE_IS_RELEASE_BRANCH_PR == 'true' || env.AZLE_IS_MAIN_BRANCH_PUSH == 'true' || env.AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH == 'true' }} + if: ${{ steps.set-conditions.outputs.is_release_branch_pr == 'true' || steps.set-conditions.outputs.is_main_branch_push == 'true' || steps.set-conditions.outputs.is_main_branch_merge_from_release_push == 'true' }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 @@ -123,23 +122,23 @@ jobs: run: | RUNS=1 - if [[ "$AZLE_IS_MAIN_BRANCH_PUSH" == "true" ]]; then + if [[ "${{ steps.set-conditions.outputs.is_main_branch_push }}" == "true" ]]; then RUNS=100 fi - if [[ "$AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH" == "true" ]]; then + if [[ "${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" == "true" ]]; then RUNS=100 fi - if [[ "$AZLE_IS_RELEASE_BRANCH_PR" == "true" ]]; then + if [[ "${{ steps.set-conditions.outputs.is_release_branch_pr }}" == "true" ]]; then RUNS=10 fi - if [[ "$AZLE_IS_FEATURE_BRANCH_PR" == "true" ]]; then + if [[ "${{ steps.set-conditions.outputs.is_feature_branch_pr }}" == "true" ]]; then RUNS=5 fi - if [[ "$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then + if [[ "${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" == "true" ]]; then RUNS=1 fi From 3cb7eb756c2cda1f939f4d1863faa7ae052f9e30 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 21 Oct 2024 07:59:05 -0600 Subject: [PATCH 22/30] remove intermediary step --- .github/workflows/get_and_run_tests.yml | 33 ------------------------- .github/workflows/test.yml | 19 +++++++++++--- 2 files changed, 15 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/get_and_run_tests.yml diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml deleted file mode 100644 index 68f4e9a75e..0000000000 --- a/.github/workflows/get_and_run_tests.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Get and Run Tests - -on: - workflow_call: - inputs: - directories: - required: true - type: string - exclude-dirs: - required: false - type: string - default: '' - -jobs: - get-test-infos: - name: 'Get test infos' - runs-on: ubuntu-latest - outputs: - test-infos: ${{ steps.get-test-infos.outputs.test-infos }} - steps: - - uses: actions/checkout@v4 - - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ${{ inputs.directories }} - exclude-dirs: ${{ inputs.exclude-dirs }} - - run-tests: - name: 'Run' - needs: get-test-infos - uses: ./.github/workflows/run_test.yml - with: - test_infos: ${{ needs.get-test-infos.outputs.test-infos }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e8529eb22..4afa14c82c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -107,6 +107,7 @@ jobs: - determine-should-run-tests - set-exclude-dirs if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -136,10 +137,20 @@ jobs: name: 'Property IC API', directories: './tests/property/ic_api' } - uses: ./.github/workflows/get_and_run_tests.yml - with: - directories: ${{ matrix.test_group.directories }} - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + steps: + - uses: actions/checkout@v4 + + - name: Get test infos + id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + directories: ${{ matrix.test_group.directories }} + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} + + - name: Run tests + uses: ./.github/workflows/run_test.yml + with: + test_infos: ${{ steps.get-test-infos.outputs.test-infos }} check-test-success: name: Check Azle tests succeeded From d3b22a88b86cc36fc5e52d40099465f81146c928 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 21 Oct 2024 09:43:45 -0600 Subject: [PATCH 23/30] revert --- .github/workflows/get_and_run_tests.yml | 33 +++++++++++++++++++++++++ .github/workflows/test.yml | 19 +++----------- 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/get_and_run_tests.yml diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml new file mode 100644 index 0000000000..68f4e9a75e --- /dev/null +++ b/.github/workflows/get_and_run_tests.yml @@ -0,0 +1,33 @@ +name: Get and Run Tests + +on: + workflow_call: + inputs: + directories: + required: true + type: string + exclude-dirs: + required: false + type: string + default: '' + +jobs: + get-test-infos: + name: 'Get test infos' + runs-on: ubuntu-latest + outputs: + test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + steps: + - uses: actions/checkout@v4 + - id: get-test-infos + uses: ./.github/actions/get_test_infos + with: + directories: ${{ inputs.directories }} + exclude-dirs: ${{ inputs.exclude-dirs }} + + run-tests: + name: 'Run' + needs: get-test-infos + uses: ./.github/workflows/run_test.yml + with: + test_infos: ${{ needs.get-test-infos.outputs.test-infos }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4afa14c82c..4e8529eb22 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -107,7 +107,6 @@ jobs: - determine-should-run-tests - set-exclude-dirs if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }} - runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -137,20 +136,10 @@ jobs: name: 'Property IC API', directories: './tests/property/ic_api' } - steps: - - uses: actions/checkout@v4 - - - name: Get test infos - id: get-test-infos - uses: ./.github/actions/get_test_infos - with: - directories: ${{ matrix.test_group.directories }} - exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} - - - name: Run tests - uses: ./.github/workflows/run_test.yml - with: - test_infos: ${{ steps.get-test-infos.outputs.test-infos }} + uses: ./.github/workflows/get_and_run_tests.yml + with: + directories: ${{ matrix.test_group.directories }} + exclude-dirs: ${{ needs.set-exclude-dirs.outputs.exclude-dirs }} check-test-success: name: Check Azle tests succeeded From 2d5c855294ac7c031a4f16cec41c2c498b5cecb4 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Mon, 21 Oct 2024 09:55:18 -0600 Subject: [PATCH 24/30] move include npm into get_and_run_tests --- .github/workflows/get_and_run_tests.yml | 23 ++++++++++++++++++----- .github/workflows/run_test.yml | 17 +++++------------ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml index 68f4e9a75e..e9f296d228 100644 --- a/.github/workflows/get_and_run_tests.yml +++ b/.github/workflows/get_and_run_tests.yml @@ -1,4 +1,4 @@ -name: Get and Run Tests +name: Prepare and Run Tests on: workflow_call: @@ -12,11 +12,12 @@ on: default: '' jobs: - get-test-infos: - name: 'Get test infos' + prepare-test-environment: + name: 'Prepare Test Environment' runs-on: ubuntu-latest outputs: test-infos: ${{ steps.get-test-infos.outputs.test-infos }} + include_npm: ${{ steps.set-include-npm.outputs.include_npm }} steps: - uses: actions/checkout@v4 - id: get-test-infos @@ -24,10 +25,22 @@ jobs: with: directories: ${{ inputs.directories }} exclude-dirs: ${{ inputs.exclude-dirs }} + - uses: ./.github/actions/set_run_conditions + id: set-conditions + - id: set-include-npm + run: | + if [[ "${{ steps.set-conditions.outputs.is_main_branch_push }}" == "true" || \ + "${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" == "true" || \ + "${{ steps.set-conditions.outputs.is_release_branch_pr }}" == "true" ]]; then + echo "include_npm=true" >> $GITHUB_OUTPUT + else + echo "include_npm=false" >> $GITHUB_OUTPUT + fi run-tests: name: 'Run' - needs: get-test-infos + needs: prepare-test-environment uses: ./.github/workflows/run_test.yml with: - test_infos: ${{ needs.get-test-infos.outputs.test-infos }} + test_infos: ${{ needs.prepare-test-environment.outputs.test-infos }} + include_npm: ${{ needs.prepare-test-environment.outputs.include_npm }} diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index fc3996e352..9101b66b44 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -6,6 +6,9 @@ on: test_infos: required: true type: string + include_npm: + required: true + type: boolean jobs: run-test: @@ -24,20 +27,10 @@ jobs: strategy: fail-fast: false # We want to see which example tests succeed and which ones fail, we don't want one example test to cancel the rest matrix: # spins up one job per combination of test and code source (repo or npm). - # os: [macos-latest] + # os: [macos-latest, ubuntu-latest] os: [ubuntu-latest] - include_npm: - # Only include npm in the matrix if you've pushed to main and the last commit was a merge of a release branch, or the base branch of the pull request is a release branch - - ${{ (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) || contains(github.head_ref, 'release--') }} azle_source: - - npm - - repo - exclude: - - include_npm: false - azle_source: npm - - include_npm: true - azle_source: repo - # If should_run_tests is false, we still want the steps of this job to execute so that check-run-test-success will run. We do this by creating an array with one dummy element + - ${{ inputs.include_npm == 'true' && 'npm' || 'repo' }} tests: ${{ fromJSON(inputs.test_infos) }} steps: - uses: actions/checkout@v4 From d2768e4c44448393ef274ba4b053ceb48d21c192 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 22 Oct 2024 09:07:58 -0600 Subject: [PATCH 25/30] make value boolean --- .github/workflows/get_and_run_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml index e9f296d228..c17af279a4 100644 --- a/.github/workflows/get_and_run_tests.yml +++ b/.github/workflows/get_and_run_tests.yml @@ -43,4 +43,4 @@ jobs: uses: ./.github/workflows/run_test.yml with: test_infos: ${{ needs.prepare-test-environment.outputs.test-infos }} - include_npm: ${{ needs.prepare-test-environment.outputs.include_npm }} + include_npm: ${{ needs.prepare-test-environment.outputs.include_npm == 'true' }} From 293baa1bface9e524abe28f27abca3935eda20f2 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 22 Oct 2024 09:24:00 -0600 Subject: [PATCH 26/30] rename is_main_branch_push_from_release_merge --- .github/actions/set_run_conditions/action.yml | 8 ++++---- .github/workflows/get_and_run_tests.yml | 2 +- .github/workflows/run_test.yml | 10 +++++----- .github/workflows/test.yml | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml index cc031810e8..9aa64cd607 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/set_run_conditions/action.yml @@ -4,9 +4,9 @@ outputs: is_main_branch_push: description: 'True if this is a push to the main branch (excluding merges from release branches)' value: ${{ steps.set-conditions.outputs.is_main_branch_push }} - is_main_branch_merge_from_release_push: + is_main_branch_push_from_release_merge: description: 'True if this is a push to the main branch from a release branch merge' - value: ${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }} + value: ${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }} is_release_branch_pr: description: 'True if this is a pull request from a release branch' value: ${{ steps.set-conditions.outputs.is_release_branch_pr }} @@ -23,14 +23,14 @@ runs: run: | # Define conditions using shell variables IS_MAIN_PUSH=${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }} - IS_MAIN_MERGE_RELEASE=${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }} + IS_MAIN_PUSH_RELEASE=${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }} IS_RELEASE_PR=${{ startsWith(github.head_ref, 'release--') }} IS_FEATURE_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }} IS_DRAFT_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }} # Set individual outputs echo "is_main_branch_push=$IS_MAIN_PUSH" >> $GITHUB_OUTPUT - echo "is_main_branch_merge_from_release_push=$IS_MAIN_MERGE_RELEASE" >> $GITHUB_OUTPUT + echo "is_main_branch_push_from_release_merge=$IS_MAIN_PUSH_RELEASE" >> $GITHUB_OUTPUT echo "is_release_branch_pr=$IS_RELEASE_PR" >> $GITHUB_OUTPUT echo "is_feature_branch_pr=$IS_FEATURE_PR" >> $GITHUB_OUTPUT echo "is_feature_branch_draft_pr=$IS_DRAFT_PR" >> $GITHUB_OUTPUT diff --git a/.github/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml index c17af279a4..fe5213baf3 100644 --- a/.github/workflows/get_and_run_tests.yml +++ b/.github/workflows/get_and_run_tests.yml @@ -30,7 +30,7 @@ jobs: - id: set-include-npm run: | if [[ "${{ steps.set-conditions.outputs.is_main_branch_push }}" == "true" || \ - "${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" == "true" || \ + "${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" == "true" || \ "${{ steps.set-conditions.outputs.is_release_branch_pr }}" == "true" ]]; then echo "include_npm=true" >> $GITHUB_OUTPUT else diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index 9101b66b44..3b9b060337 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -19,7 +19,7 @@ jobs: AZLE_IDENTITY_STORAGE_MODE: 'plaintext' AZLE_END_TO_END_TEST_LINK_AZLE: ${{ matrix.azle_source == 'repo' }} AZLE_IS_MAIN_BRANCH_PUSH: '' - AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: '' + AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE: '' AZLE_IS_RELEASE_BRANCH_PR: '' AZLE_IS_FEATURE_BRANCH_PR: '' AZLE_IS_FEATURE_BRANCH_DRAFT_PR: '' @@ -41,7 +41,7 @@ jobs: - name: Set condition environment variables run: | echo "AZLE_IS_MAIN_BRANCH_PUSH=${{ steps.set-conditions.outputs.is_main_branch_push }}" >> $GITHUB_ENV - echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH=${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" >> $GITHUB_ENV + echo "AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE=${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" >> $GITHUB_ENV echo "AZLE_IS_RELEASE_BRANCH_PR=${{ steps.set-conditions.outputs.is_release_branch_pr }}" >> $GITHUB_ENV echo "AZLE_IS_FEATURE_BRANCH_PR=${{ steps.set-conditions.outputs.is_feature_branch_pr }}" >> $GITHUB_ENV echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR=${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" >> $GITHUB_ENV @@ -49,7 +49,7 @@ jobs: - id: check-conditions run: | echo "AZLE_IS_MAIN_BRANCH_PUSH: $AZLE_IS_MAIN_BRANCH_PUSH" - echo "AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH: $AZLE_IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH" + echo "AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE: $AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" echo "AZLE_IS_RELEASE_BRANCH_PR: $AZLE_IS_RELEASE_BRANCH_PR" echo "AZLE_IS_FEATURE_BRANCH_PR: $AZLE_IS_FEATURE_BRANCH_PR" echo "AZLE_IS_FEATURE_BRANCH_DRAFT_PR: $AZLE_IS_FEATURE_BRANCH_DRAFT_PR" @@ -107,7 +107,7 @@ jobs: run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0 - name: Start dfx - if: ${{ steps.set-conditions.outputs.is_release_branch_pr == 'true' || steps.set-conditions.outputs.is_main_branch_push == 'true' || steps.set-conditions.outputs.is_main_branch_merge_from_release_push == 'true' }} + if: ${{ steps.set-conditions.outputs.is_release_branch_pr == 'true' || steps.set-conditions.outputs.is_main_branch_push == 'true' || steps.set-conditions.outputs.is_main_branch_push_from_release_merge == 'true' }} working-directory: ${{ matrix.tests.path }} run: dfx start --clean --background --host 127.0.0.1:8000 @@ -119,7 +119,7 @@ jobs: RUNS=100 fi - if [[ "${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" == "true" ]]; then + if [[ "${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" == "true" ]]; then RUNS=100 fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e8529eb22..fedfd13225 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -70,7 +70,7 @@ jobs: ') }}" IS_MAIN_BRANCH_PUSH="${{ steps.set-conditions.outputs.is_main_branch_push }}" - IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH="${{ steps.set-conditions.outputs.is_main_branch_merge_from_release_push }}" + IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE="${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" IS_RELEASE_BRANCH_PR="${{ steps.set-conditions.outputs.is_release_branch_pr }}" IS_FEATURE_BRANCH_PR="${{ steps.set-conditions.outputs.is_feature_branch_pr }}" IS_FEATURE_BRANCH_DRAFT_PR="${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" @@ -81,7 +81,7 @@ jobs: EXCLUDE_DIRS="" fi - if [[ "$IS_MAIN_BRANCH_MERGE_FROM_RELEASE_PUSH" == "true" ]]; then + if [[ "$IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" == "true" ]]; then EXCLUDE_DIRS="" fi From 0254818df81d4248052afab5605099acb43807f4 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 22 Oct 2024 16:13:22 -0600 Subject: [PATCH 27/30] update variable names for maximum verbosity --- .github/actions/set_run_conditions/action.yml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml index 9aa64cd607..169ac0b807 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/set_run_conditions/action.yml @@ -22,16 +22,16 @@ runs: - id: set-conditions run: | # Define conditions using shell variables - IS_MAIN_PUSH=${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }} - IS_MAIN_PUSH_RELEASE=${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }} - IS_RELEASE_PR=${{ startsWith(github.head_ref, 'release--') }} - IS_FEATURE_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }} - IS_DRAFT_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }} + AZLE_IS_MAIN_BRANCH_PUSH=${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }} + AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE=${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'demergent-labs/release--') }} + AZLE_IS_RELEASE_PR=${{ startsWith(github.head_ref, 'release--') }} + AZLE_IS_FEATURE_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false }} + AZLE_IS_DRAFT_PR=${{ !startsWith(github.head_ref, 'release--') && github.ref != 'refs/heads/main' && github.event.pull_request.draft == true }} # Set individual outputs - echo "is_main_branch_push=$IS_MAIN_PUSH" >> $GITHUB_OUTPUT - echo "is_main_branch_push_from_release_merge=$IS_MAIN_PUSH_RELEASE" >> $GITHUB_OUTPUT - echo "is_release_branch_pr=$IS_RELEASE_PR" >> $GITHUB_OUTPUT - echo "is_feature_branch_pr=$IS_FEATURE_PR" >> $GITHUB_OUTPUT - echo "is_feature_branch_draft_pr=$IS_DRAFT_PR" >> $GITHUB_OUTPUT + echo "is_main_branch_push=$AZLE_IS_MAIN_BRANCH_PUSH" >> $GITHUB_OUTPUT + echo "is_main_branch_push_from_release_merge=$AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" >> $GITHUB_OUTPUT + echo "is_release_branch_pr=$AZLE_IS_RELEASE_PR" >> $GITHUB_OUTPUT + echo "is_feature_branch_pr=$AZLE_IS_FEATURE_PR" >> $GITHUB_OUTPUT + echo "is_feature_branch_draft_pr=$AZLE_IS_DRAFT_PR" >> $GITHUB_OUTPUT shell: bash From 591c8318f3a907ac332972374cc3a1d69a2eb098 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 22 Oct 2024 16:21:28 -0600 Subject: [PATCH 28/30] fixup --- .github/actions/set_run_conditions/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml index 169ac0b807..77c1c0e915 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/set_run_conditions/action.yml @@ -33,5 +33,5 @@ runs: echo "is_main_branch_push_from_release_merge=$AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" >> $GITHUB_OUTPUT echo "is_release_branch_pr=$AZLE_IS_RELEASE_PR" >> $GITHUB_OUTPUT echo "is_feature_branch_pr=$AZLE_IS_FEATURE_PR" >> $GITHUB_OUTPUT - echo "is_feature_branch_draft_pr=$AZLE_IS_DRAFT_PR" >> $GITHUB_OUTPUT + echo "is_feature_branch_draft_pr=$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" >> $GITHUB_OUTPUT shell: bash From 53ecbf668f6bb79d1300aa70024bf8c259ac2bf9 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 22 Oct 2024 16:22:37 -0600 Subject: [PATCH 29/30] fixup --- .github/actions/set_run_conditions/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/set_run_conditions/action.yml index 77c1c0e915..5da7d76365 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/set_run_conditions/action.yml @@ -31,7 +31,7 @@ runs: # Set individual outputs echo "is_main_branch_push=$AZLE_IS_MAIN_BRANCH_PUSH" >> $GITHUB_OUTPUT echo "is_main_branch_push_from_release_merge=$AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" >> $GITHUB_OUTPUT - echo "is_release_branch_pr=$AZLE_IS_RELEASE_PR" >> $GITHUB_OUTPUT - echo "is_feature_branch_pr=$AZLE_IS_FEATURE_PR" >> $GITHUB_OUTPUT + echo "is_release_branch_pr=$AZLE_IS_RELEASE_BRANCH_PR" >> $GITHUB_OUTPUT + echo "is_feature_branch_pr=$AZLE_IS_FEATURE_BRANCH_PR" >> $GITHUB_OUTPUT echo "is_feature_branch_draft_pr=$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" >> $GITHUB_OUTPUT shell: bash From 8021478a4c72f6d9421da5e4b137fc5bcdcf7d2c Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Tue, 22 Oct 2024 16:24:42 -0600 Subject: [PATCH 30/30] fixup --- .github/workflows/test.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fedfd13225..61bb09a8be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,31 +69,31 @@ jobs: tests/end_to_end/http_server/autoreload ') }}" - IS_MAIN_BRANCH_PUSH="${{ steps.set-conditions.outputs.is_main_branch_push }}" - IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE="${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" - IS_RELEASE_BRANCH_PR="${{ steps.set-conditions.outputs.is_release_branch_pr }}" - IS_FEATURE_BRANCH_PR="${{ steps.set-conditions.outputs.is_feature_branch_pr }}" - IS_FEATURE_BRANCH_DRAFT_PR="${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" + 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 [[ "$IS_MAIN_BRANCH_PUSH" == "true" ]]; then + if [[ "$AZLE_IS_MAIN_BRANCH_PUSH" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "$IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" == "true" ]]; then + if [[ "$AZLE_IS_MAIN_BRANCH_PUSH_FROM_RELEASE_MERGE" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "$IS_RELEASE_BRANCH_PR" == "true" ]]; then + if [[ "$AZLE_IS_RELEASE_BRANCH_PR" == "true" ]]; then EXCLUDE_DIRS="" fi - if [[ "$IS_FEATURE_BRANCH_PR" == "true" ]]; then + if [[ "$AZLE_IS_FEATURE_BRANCH_PR" == "true" ]]; then EXCLUDE_DIRS="$RELEASE_TESTS $UNSTABLE_TESTS" fi - if [[ "$IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then + if [[ "$AZLE_IS_FEATURE_BRANCH_DRAFT_PR" == "true" ]]; then EXCLUDE_DIRS="$RELEASE_TESTS $UNSTABLE_TESTS $SLOW_TESTS" fi