Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test workflow dispatch #2297

Merged
merged 21 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/actions/determine_exclusions/README.md

This file was deleted.

56 changes: 0 additions & 56 deletions .github/actions/determine_exclusions/action.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/actions/determine_workflow_config/README.md
Original file line number Diff line number Diff line change
@@ -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 }}"
```
82 changes: 82 additions & 0 deletions .github/actions/determine_workflow_config/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
17 changes: 17 additions & 0 deletions .github/actions/determine_workflow_context/README.md
Original file line number Diff line number Diff line change
@@ -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 }}"
```
Original file line number Diff line number Diff line change
@@ -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--') }}
Expand Down
17 changes: 0 additions & 17 deletions .github/actions/set_run_conditions/README.md

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/get_and_run_tests.yml

This file was deleted.

33 changes: 26 additions & 7 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Loading
Loading