-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into responses_prop_test
- Loading branch information
Showing
7 changed files
with
322 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: 'Set run conditions' | ||
description: 'Sets the run conditions 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 }} | ||
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 }} | ||
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: | ||
- id: set-conditions | ||
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--') }} | ||
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=$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_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Prepare and Run Tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
directories: | ||
required: true | ||
type: string | ||
exclude-dirs: | ||
required: false | ||
type: string | ||
default: '' | ||
|
||
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 }}" == "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 | ||
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' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
name: Run Test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
test_infos: | ||
required: true | ||
type: string | ||
include_npm: | ||
required: true | ||
type: boolean | ||
|
||
jobs: | ||
run-test: | ||
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' }} | ||
AZLE_IS_MAIN_BRANCH_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: '' | ||
|
||
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, ubuntu-latest] | ||
os: [ubuntu-latest] | ||
azle_source: | ||
- ${{ inputs.include_npm == 'true' && 'npm' || 'repo' }} | ||
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: | | ||
echo "AZLE_IS_MAIN_BRANCH_PUSH=${{ steps.set-conditions.outputs.is_main_branch_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 | ||
- id: check-conditions | ||
run: | | ||
echo "AZLE_IS_MAIN_BRANCH_PUSH: $AZLE_IS_MAIN_BRANCH_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" | ||
- 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}} | ||
|
||
- 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: ${{ 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: ${{ 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 | ||
|
||
- name: Run test | ||
run: | | ||
RUNS=1 | ||
if [[ "${{ steps.set-conditions.outputs.is_main_branch_push }}" == "true" ]]; then | ||
RUNS=100 | ||
fi | ||
if [[ "${{ steps.set-conditions.outputs.is_main_branch_push_from_release_merge }}" == "true" ]]; then | ||
RUNS=100 | ||
fi | ||
if [[ "${{ steps.set-conditions.outputs.is_release_branch_pr }}" == "true" ]]; then | ||
RUNS=10 | ||
fi | ||
if [[ "${{ steps.set-conditions.outputs.is_feature_branch_pr }}" == "true" ]]; then | ||
RUNS=5 | ||
fi | ||
if [[ "${{ steps.set-conditions.outputs.is_feature_branch_draft_pr }}" == "true" ]]; then | ||
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 }} |
Oops, something went wrong.