diff --git a/.github/actions/determine_exclusions/README.md b/.github/actions/determine_exclusions/README.md deleted file mode 100644 index 94bd3935ab..0000000000 --- a/.github/actions/determine_exclusions/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## Example Usage - -```yaml -steps: - - uses: actions/checkout@v4 - - - id: determine-exclusions - uses: ./.github/actions/determine_exclusions - with: - is_workflow_dispatch: ${{ github.event_name == 'workflow_dispatch' }} - exclude_slow_input: ${{ inputs.exclude-slow-tests }} - exclude_unstable_input: ${{ inputs.exclude-unstable-tests }} - exclude_release_only_input: ${{ inputs.exclude-release-only-tests }} - is_feature_branch_draft_pr: ${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }} - is_feature_branch_pr: ${{ steps.set-conditions.outputs.is_feature_branch_pr }} - is_main_branch_push: ${{ steps.set-conditions.outputs.is_main_branch_push }} - - - name: Use exclusion outputs - run: | - echo "Exclude slow tests: ${{ steps.determine-exclusions.outputs.exclude_slow }}" - echo "Exclude unstable tests: ${{ steps.determine-exclusions.outputs.exclude_unstable }}" - echo "Exclude release only tests: ${{ steps.determine-exclusions.outputs.exclude_release_only }}" -``` diff --git a/.github/actions/determine_exclusions/action.yml b/.github/actions/determine_exclusions/action.yml deleted file mode 100644 index bb9835a64e..0000000000 --- a/.github/actions/determine_exclusions/action.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: 'Determine Test Exclusions' -description: 'Determines which tests should be excluded based on workflow trigger and conditions' - -inputs: - is_workflow_dispatch: - description: 'Whether this is a workflow dispatch run' - required: true - exclude_slow_input: - description: 'Workflow dispatch input for excluding slow tests' - required: true - exclude_unstable_input: - description: 'Workflow dispatch input for excluding unstable tests' - required: true - exclude_release_only_input: - description: 'Workflow dispatch input for excluding release only tests' - required: true - is_feature_branch_draft_pr: - description: 'Whether this is a draft PR' - required: true - is_feature_branch_pr: - description: 'Whether this is a feature branch PR' - required: true - is_main_branch_push: - description: 'Whether this is a push to main' - required: true - -outputs: - exclude_slow: - description: 'Whether to exclude slow tests' - value: ${{ steps.determine.outputs.exclude_slow }} - exclude_unstable: - description: 'Whether to exclude unstable tests' - value: ${{ steps.determine.outputs.exclude_unstable }} - exclude_release_only: - description: 'Whether to exclude release only tests' - value: ${{ steps.determine.outputs.exclude_release_only }} - -runs: - using: 'composite' - steps: - - id: determine - shell: bash - run: | - if [[ "${{ inputs.is_workflow_dispatch }}" == "true" ]]; then - echo "exclude_slow=${{ inputs.exclude_slow_input }}" >> $GITHUB_OUTPUT - echo "exclude_unstable=${{ inputs.exclude_unstable_input }}" >> $GITHUB_OUTPUT - echo "exclude_release_only=${{ inputs.exclude_release_only_input }}" >> $GITHUB_OUTPUT - else - exclude_slow=${{ inputs.is_feature_branch_draft_pr }} - exclude_unstable=${{ inputs.is_feature_branch_draft_pr == 'true' || inputs.is_feature_branch_pr == 'true' }} - exclude_release_only=${{ inputs.is_feature_branch_draft_pr == 'true' || inputs.is_feature_branch_pr == 'true' || inputs.is_main_branch_push == 'true' }} - - echo "exclude_slow=$exclude_slow" >> $GITHUB_OUTPUT - echo "exclude_unstable=$exclude_unstable" >> $GITHUB_OUTPUT - echo "exclude_release_only=$exclude_release_only" >> $GITHUB_OUTPUT - fi diff --git a/.github/actions/determine_workflow_config/README.md b/.github/actions/determine_workflow_config/README.md new file mode 100644 index 0000000000..c2a867d7c6 --- /dev/null +++ b/.github/actions/determine_workflow_config/README.md @@ -0,0 +1,24 @@ +## Example Usage + +```yaml +steps: + - uses: actions/checkout@v4 + + - id: determine-workflow-config + uses: ./.github/actions/determine_workflow_config + with: + is-workflow-dispatch: ${{ github.event_name == 'workflow_dispatch' }} + exclude-slow-dispatch-input-value: ${{ inputs.exclude-slow-tests }} + exclude-unstable-dispatch-input-value: ${{ inputs.exclude-unstable-tests }} + exclude-release-only-dispatch-input-value: ${{ inputs.exclude-release-only-tests }} + link-azle-dispatch-input-value: ${{ inputs.link-azle }} + fuzz-dispatch-input-value: ${{ inputs.fuzz-tests }} + + - name: Use determine-workflow-config outputs + run: | + echo "Exclude slow tests: ${{ steps.determine-workflow-config.outputs.exclude-slow }}" + echo "Exclude unstable tests: ${{ steps.determine-workflow-config.outputs.exclude-unstable }}" + echo "Exclude release only tests: ${{ steps.determine-workflow-config.outputs.exclude-release-only }}" + echo "Link to azle: ${{ steps.determine-workflow-config.outputs.link-azle }}" + echo "Fuzz tests: ${{ steps.determine-workflow-config.outputs.fuzz }}" +``` diff --git a/.github/actions/determine_workflow_config/action.yml b/.github/actions/determine_workflow_config/action.yml new file mode 100644 index 0000000000..aa4e8f1b42 --- /dev/null +++ b/.github/actions/determine_workflow_config/action.yml @@ -0,0 +1,82 @@ +name: 'Determine workflow config' +description: 'Determines the workflow configuration based on the current GitHub context' + +inputs: + is-workflow-dispatch: + description: 'Whether this is a workflow dispatch event' + required: true + exclude-slow-dispatch-input-value: + description: 'Workflow dispatch input for excluding slow tests' + required: true + exclude-unstable-dispatch-input-value: + description: 'Workflow dispatch input for excluding unstable tests' + required: true + exclude-release-only-dispatch-input-value: + description: 'Workflow dispatch input for excluding release-only tests' + required: true + fuzz-dispatch-input-value: + description: 'Workflow dispatch input for running fuzz tests' + required: false + default: 'false' + link-azle-dispatch-input-value: + description: 'Workflow dispatch input for linking to the development version of azle' + required: true + +outputs: + exclude-slow: + description: 'Whether to exclude slow tests' + value: ${{ steps.determine_workflow_config.outputs.exclude-slow }} + exclude-unstable: + description: 'Whether to exclude unstable tests' + value: ${{ steps.determine_workflow_config.outputs.exclude-unstable }} + exclude-release-only: + description: 'Whether to exclude release-only tests' + value: ${{ steps.determine_workflow_config.outputs.exclude-release-only }} + link-azle: + description: 'Whether to link to the development version of azle' + value: ${{ steps.determine_workflow_config.outputs.link-azle }} + fuzz: + description: 'Whether to run fuzz tests' + value: ${{ steps.determine_workflow_config.outputs.fuzz }} + +runs: + using: 'composite' + steps: + - id: workflow-context + uses: ./.github/actions/determine_workflow_context + + - id: determine_workflow_config + shell: bash + run: | + if [[ "${{ inputs.is-workflow-dispatch }}" == "true" ]]; then + echo "exclude-slow=${{ inputs.exclude-slow-dispatch-input-value }}" >> $GITHUB_OUTPUT + echo "exclude-unstable=${{ inputs.exclude-unstable-dispatch-input-value }}" >> $GITHUB_OUTPUT + echo "exclude-release-only=${{ inputs.exclude-release-only-dispatch-input-value }}" >> $GITHUB_OUTPUT + echo "link-azle=${{ inputs.link-azle-dispatch-input-value }}" >> $GITHUB_OUTPUT + echo "fuzz=${{ inputs.fuzz-dispatch-input-value }}" >> $GITHUB_OUTPUT + else + EXCLUDE_SLOW=${{ steps.workflow-context.outputs.is_feature_branch_draft_pr == 'true' }} + EXCLUDE_UNSTABLE=${{ steps.workflow-context.outputs.is_feature_branch_draft_pr == 'true' || steps.workflow-context.outputs.is_feature_branch_pr == 'true' }} + EXCLUDE_RELEASE_ONLY=${{ steps.workflow-context.outputs.is_feature_branch_draft_pr == 'true' || steps.workflow-context.outputs.is_feature_branch_pr == 'true' || steps.workflow-context.outputs.is_main_branch_push == 'true' }} + + echo "exclude-slow=$EXCLUDE_SLOW" >> $GITHUB_OUTPUT + echo "exclude-unstable=$EXCLUDE_UNSTABLE" >> $GITHUB_OUTPUT + echo "exclude-release-only=$EXCLUDE_RELEASE_ONLY" >> $GITHUB_OUTPUT + if [[ "${{ steps.workflow-context.outputs.is_main_branch_push_from_release_merge }}" == "true" || \ + "${{ steps.workflow-context.outputs.is_release_branch_pr }}" == "true" ]]; then + echo "link-azle=false" >> $GITHUB_OUTPUT + else + echo "link-azle=true" >> $GITHUB_OUTPUT + fi + echo "fuzz=false" >> $GITHUB_OUTPUT + fi + + - id: echo-outputs + shell: bash + run: | + echo "Test Conditions Outputs:" + echo "exclude-slow: ${{ steps.determine_workflow_config.outputs.exclude-slow }}" + echo "exclude-unstable: ${{ steps.determine_workflow_config.outputs.exclude-unstable }}" + echo "exclude-release-only: ${{ steps.determine_workflow_config.outputs.exclude-release-only }}" + echo "link-azle: ${{ steps.determine_workflow_config.outputs.link-azle }}" + echo "fuzz: ${{ steps.determine_workflow_config.outputs.fuzz }}" diff --git a/.github/actions/determine_workflow_context/README.md b/.github/actions/determine_workflow_context/README.md new file mode 100644 index 0000000000..6e3b90d485 --- /dev/null +++ b/.github/actions/determine_workflow_context/README.md @@ -0,0 +1,17 @@ +## Example Usage + +```yaml +steps: + - uses: actions/checkout@v4 + + - id: workflow-context + uses: ./.github/actions/determine_workflow_context + + - name: Use run conditions + run: | + echo "Is main branch push: ${{ steps.workflow-context.outputs.is_main_branch_push }}" + echo "Is main branch merge from release push: ${{ steps.workflow-context.outputs.is_main_branch_merge_from_release_push }}" + echo "Is release branch PR: ${{ steps.workflow-context.outputs.is_release_branch_pr }}" + echo "Is feature branch PR: ${{ steps.workflow-context.outputs.is_feature_branch_pr }}" + echo "Is feature branch draft PR: ${{ steps.workflow-context.outputs.is_feature_branch_draft_pr }}" +``` diff --git a/.github/actions/set_run_conditions/action.yml b/.github/actions/determine_workflow_context/action.yml similarity index 78% rename from .github/actions/set_run_conditions/action.yml rename to .github/actions/determine_workflow_context/action.yml index 2e63eab5fc..aceb05a6ad 100644 --- a/.github/actions/set_run_conditions/action.yml +++ b/.github/actions/determine_workflow_context/action.yml @@ -1,25 +1,25 @@ -name: 'Set run conditions' -description: 'Sets the run conditions based on the current GitHub context' +name: 'Determine workflow context' +description: 'Determines the workflow context based on the current GitHub context' 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 }} + value: ${{ steps.workflow-context.outputs.is_main_branch_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_push_from_release_merge }} + value: ${{ steps.workflow-context.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 }} + value: ${{ steps.workflow-context.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 }} + value: ${{ steps.workflow-context.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 }} + value: ${{ steps.workflow-context.outputs.is_feature_branch_draft_pr }} runs: using: 'composite' steps: - - id: set-conditions + - id: workflow-context run: | # Define conditions using shell variables AZLE_IS_MAIN_BRANCH_PUSH=${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'demergent-labs/release--') }} diff --git a/.github/actions/set_run_conditions/README.md b/.github/actions/set_run_conditions/README.md deleted file mode 100644 index b75f8160f7..0000000000 --- a/.github/actions/set_run_conditions/README.md +++ /dev/null @@ -1,17 +0,0 @@ -## 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/workflows/get_and_run_tests.yml b/.github/workflows/get_and_run_tests.yml deleted file mode 100644 index ca0dea9d45..0000000000 --- a/.github/workflows/get_and_run_tests.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Prepare and Run Tests - -on: - workflow_call: - inputs: - directories: - required: true - type: string - exclude-dirs: - required: false - type: string - default: '' - run_experimental: - required: false - type: boolean - default: false - fuzz: - required: false - type: boolean - default: false - -jobs: - 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 - uses: ./.github/actions/get_test_infos - 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_from_release_merge }}" == "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: prepare-test-environment - 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 == 'true' }} - run_experimental: ${{ inputs.run_experimental }} - fuzz: ${{ inputs.fuzz }} diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index 962ae0a009..ebdababf01 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -3,13 +3,17 @@ name: Run Test on: workflow_call: inputs: - test_infos: + directories: required: true type: string - include_npm: + exclude-dirs: + required: false + type: string + default: '' + link-azle: required: true type: boolean - run_experimental: + run-experimental: required: false type: boolean default: false @@ -27,8 +31,23 @@ on: default: 300 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-test: name: '${{matrix.test.name}} | ${{matrix.test.displayPath}} | ${{matrix.azle_source}}' + needs: get-test-infos runs-on: ${{ matrix.os }} env: ETHEREUM_URL: ${{ secrets.ETHEREUM_URL }} @@ -46,12 +65,12 @@ jobs: # os: [macos-latest, ubuntu-latest] os: [ubuntu-latest] azle_source: - - ${{ inputs.include_npm == true && 'npm' || 'repo' }} - test: ${{ fromJSON(inputs.test_infos) }} + - ${{ inputs.link-azle == true && 'repo' || 'npm' }} + test: ${{ fromJSON(needs.get-test-infos.outputs.test-infos) }} steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/set_run_conditions + - uses: ./.github/actions/determine_workflow_context id: set-conditions - name: Set condition environment variables @@ -151,6 +170,6 @@ jobs: env: AZLE_PROPTEST_NUM_RUNS: ${{ steps.calc-runs.outputs.runs }} AZLE_PROPTEST_VERBOSE: true - AZLE_EXPERIMENTAL: ${{ inputs.run_experimental }} + AZLE_EXPERIMENTAL: ${{ inputs.run-experimental }} AZLE_FUZZ: ${{ inputs.fuzz }} AZLE_FUZZ_CALL_DELAY: ${{ inputs.call-delay }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6bd013cf62..cf72dfb479 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,44 +33,59 @@ on: type: boolean default: true exclude-release-only-tests: - description: 'Exclude release only tests' + description: 'Exclude release-only tests' + required: true + type: boolean + default: true + link-azle: + description: 'Link to development version of azle' required: true type: boolean default: true jobs: + workflow-config: + name: Determine workflow config + runs-on: ubuntu-latest + outputs: + exclude-slow: ${{ steps.determine-workflow-config.outputs.exclude-slow }} + exclude-unstable: ${{ steps.determine-workflow-config.outputs.exclude-unstable }} + exclude-release-only: ${{ steps.determine-workflow-config.outputs.exclude-release-only }} + link-azle: ${{ steps.determine-workflow-config.outputs.link-azle }} + fuzz: ${{ steps.determine-workflow-config.outputs.fuzz }} + steps: + - uses: actions/checkout@v4 + + - id: determine-workflow-config + uses: ./.github/actions/determine_workflow_config + with: + is-workflow-dispatch: ${{ github.event_name == 'workflow_dispatch' }} + exclude-slow-dispatch-input-value: ${{ inputs.exclude-slow-tests }} + exclude-unstable-dispatch-input-value: ${{ inputs.exclude-unstable-tests }} + exclude-release-only-dispatch-input-value: ${{ inputs.exclude-release-only-tests }} + link-azle-dispatch-input-value: ${{ inputs.link-azle }} + fuzz-dispatch-input-value: ${{ inputs.fuzz }} + get-exclude-dirs: name: Get exclude directories + needs: workflow-config runs-on: ubuntu-latest outputs: exclude-dirs: ${{ steps.get-exclude-dirs.outputs.exclude-dirs }} steps: - uses: actions/checkout@v4 - - id: set-conditions - uses: ./.github/actions/set_run_conditions - - - id: determine-exclusions - uses: ./.github/actions/determine_exclusions - with: - is_workflow_dispatch: ${{ github.event_name == 'workflow_dispatch' }} - exclude_slow_input: ${{ inputs.exclude-slow-tests }} - exclude_unstable_input: ${{ inputs.exclude-unstable-tests }} - exclude_release_only_input: ${{ inputs.exclude-release-only-tests }} - is_feature_branch_draft_pr: ${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }} - is_feature_branch_pr: ${{ steps.set-conditions.outputs.is_feature_branch_pr }} - is_main_branch_push: ${{ steps.set-conditions.outputs.is_main_branch_push }} - - id: get-exclude-dirs uses: ./.github/actions/get_exclude_dirs with: - exclude-slow: ${{ steps.determine-exclusions.outputs.exclude_slow }} - exclude-unstable: ${{ steps.determine-exclusions.outputs.exclude_unstable }} - exclude-release-only: ${{ steps.determine-exclusions.outputs.exclude_release_only }} + exclude-slow: ${{ needs.workflow-config.outputs.exclude-slow }} + exclude-unstable: ${{ needs.workflow-config.outputs.exclude-unstable }} + exclude-release-only: ${{ needs.workflow-config.outputs.exclude-release-only }} run-tests: name: ${{ matrix.test_group.name }} needs: + - workflow-config - get-exclude-dirs strategy: fail-fast: false @@ -80,7 +95,7 @@ jobs: - { name: 'Examples (Experimental)', directories: './examples', - run_experimental: true + run-experimental: true } - { name: 'E2E Class', @@ -89,7 +104,7 @@ jobs: - { name: 'E2E Class (Experimental)', directories: './tests/end_to_end/candid_rpc/class_syntax', - run_experimental: true + run-experimental: true } - { name: 'E2E Functional', @@ -106,7 +121,7 @@ jobs: - { name: 'Property Class (Experimental)', directories: './tests/property/candid_rpc/class_api', - run_experimental: true + run-experimental: true } - { name: 'Property Functional', @@ -119,14 +134,15 @@ jobs: - { name: 'Property IC API (Experimental)', directories: './tests/property/ic_api', - run_experimental: true + run-experimental: true } - uses: ./.github/workflows/get_and_run_tests.yml + uses: ./.github/workflows/run_test.yml with: directories: ${{ matrix.test_group.directories }} exclude-dirs: ${{ needs.get-exclude-dirs.outputs.exclude-dirs }} - run_experimental: ${{ matrix.test_group.run_experimental || false }} - fuzz: ${{ inputs.fuzz || false }} + link-azle: ${{ needs.workflow-config.outputs.link-azle == 'true' }} + run-experimental: ${{ matrix.test_group.run-experimental || false }} + fuzz: ${{ needs.workflow-config.outputs.fuzz == 'true' }} check-test-success: name: Check Azle tests succeeded