Skip to content

Release 0.24.1 rc.0 #5021

Release 0.24.1 rc.0

Release 0.24.1 rc.0 #5021

Workflow file for this run

# This GitHub Action flow works as follows:
# Each directory in the examples and tests directory represents an example project and is intended to have tests that ensure the canisters contained in that example function properly.
# 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
on:
push:
branches:
- main
pull_request: # Runs on pull requests to any branch
env:
DFX_VERSION: 0.22.0
NODE_VERSION: 20
IS_MAIN_BRANCH: ${{ github.ref == 'refs/heads/main' }}
IS_RELEASE_BRANCH_PR: ${{ contains(github.head_ref, 'release--') }}
IS_FEATURE_BRANCH_PR: ${{ !contains(github.head_ref, 'release--') }}
jobs:
see-vars:
name: See vars
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
echo "CI: $CI"
echo "ACTION: $GITHUB_ACTION"
echo "ACTION_PATH: $GITHUB_ACTION_PATH"
echo "ACTION_REPOSITORY: $GITHUB_ACTION_REPOSITORY"
echo "ACTIONS: $GITHUB_ACTIONS"
echo "ACTOR: $GITHUB_ACTOR"
echo "ACTOR_ID: $GITHUB_ACTOR_ID"
echo "API_URL: $GITHUB_API_URL"
echo "BASE_REF: $GITHUB_BASE_REF"
echo "ENV: $GITHUB_ENV"
echo "EVENT_NAME: $GITHUB_EVENT_NAME"
echo "EVENT_PATH: $GITHUB_EVENT_PATH"
echo "GRAPHQL_URL: $GITHUB_GRAPHQL_URL"
echo "HEAD_REF: $GITHUB_HEAD_REF"
echo "JOB: $GITHUB_JOB"
echo "OUTPUT: $GITHUB_OUTPUT"
echo "PATH: $GITHUB_PATH"
echo "REF: $GITHUB_REF"
echo "REF_NAME: $GITHUB_REF_NAME"
echo "REF_PROTECTED: $GITHUB_REF_PROTECTED"
echo "REF_TYPE: $GITHUB_REF_TYPE"
echo "REPOSITORY: $GITHUB_REPOSITORY"
echo "REPSOITORY ID: $GITHUB_REPOSITORY_ID"
echo "REPOSITORY_OWNER: $GITHUB_REPOSITORY_OWNER"
echo "REPSOSITRY_OWNDER_ID: $GITHUB_REPOSITORY_OWNER_ID"
echo "RETENTION_DAYS: $GITHUB_RETENTION_DAYS"
echo "RUN_ATTEMPT: $GITHUB_RUN_ATTEMPT"
echo "RUN_ID: $GITHUB_RUN_ID"
echo "RUN_NUMBER: $GITHUB_RUN_NUMBER"
echo "SERVER_URL: $GITHUB_SERVER_URL"
echo "SHA: $GITHUB_SHA"
echo "STEP_SUMMARY: $GITHUB_STEP_SUMMARY"
echo "TRIGGERING_ACTOR: $GITHUB_TRIGGERING_ACTOR"
echo "WORKFLOW: $GITHUB_WORKFLOW"
echo "WORKFLOW_REF: $GITHUB_WORKFLOW_REF"
echo "WORKFLOW_SHA: $GITHUB_WORKFLOW_SHA"
echo "WORKSPACE: $GITHUB_WORKSPACE"
echo "ARCH: $RUNNER_ARCH"
echo "DEBUG: $RUNNER_DEBUG"
echo "ENVIRONMENT: $RUNNER_ENVIRONMENT"
echo "NAME: $RUNNER_NAME"
echo "OS: $RUNNER_OS"
echo "TEMP: $RUNNER_TEMP"
echo "TOOL_CACHE: $RUNNER_TOOL_CACHE"
# Show the repository's remote URL
echo "Repository URL:"
git remote get-url origin
# Show the current branch name
echo -e "\nCurrent Branch:"
git branch --show-current
# Show the latest commit hash and message
echo -e "\nLatest Commit:"
git log -1 --pretty=format:"%h - %s"
# Show the date and author of the latest commit
echo -e "\nCommit Details:"
git log -1 --pretty=format:"Author: %an, Date: %ad"
# Show the last few commits
echo -e "\nLast 20 Commits:"
git log --oneline --graph -n 20
# Show the repository's status
echo -e "\nRepository Status:"
git status -s
# Show unpushed commits (if any)
echo -e "\nUnpushed Commits:"
git log @{u}..HEAD --oneline || echo "No unpushed commits"
# Show stashes (if any)
echo -e "\nGit Stashes:"
git stash list || echo "No stashes"
echo -e "\nDone!"
get-tests:
name: Get tests
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.get_tests.outputs.tests }}
steps:
- uses: actions/checkout@v4
- name: Get tests
id: get_tests
uses: ./.github/actions/get_tests
with:
directories: |
./examples
./tests
exclude_dirs: |
${{ env.IS_FEATURE_BRANCH_PR == 'true' && format('
./examples/basic_bitcoin
./examples/bitcoin_psbt
./examples/ckbtc
./tests/end_to_end/http_server/ethers_base
./tests/end_to_end/http_server/http_outcall_fetch
./tests/end_to_end/http_server/ic_evm_rpc
./tests/property/candid_rpc/class_api/stable_b_tree_map
./tests/property/candid_rpc/functional_api/stable_b_tree_map
') || '' }}
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
- name: Cool
run: echo $(git log -1 --pretty=format:"%s")
- name: Boy
run: echo ${{ github.event.head_commit.message }}
- name: Town
run: echo $(git log -1 --no-merges --pretty=format:"%s")
- name: List recent commits
run: git log --oneline -5
- id: determine_should_run_tests
uses: ./.github/actions/should_release
run-test:
name: '${{matrix.tests.name}} | ${{matrix.tests.type}} | ${{matrix.tests.syntax}} | ${{matrix.tests.api}} | ${{matrix.azle_source}}'
needs:
- determine-should-run-tests
- get-tests
if: ${{ needs.determine-should-run-tests.outputs.should_run_tests == 'true' }}
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_TEST_RUN_ON_RELEASE: ${{ contains(github.head_ref, 'release--') }}
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-tests.outputs.tests) }}
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
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Run pre-test Azle setup
run: |
# Install dfx
DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
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
if: ${{ env.IS_FEATURE_BRANCH_PR == 'true' }}
working-directory: ${{ matrix.tests.path }}
run: dfx start --clean --background --host 127.0.0.1:8000 --artificial-delay 0
- name: Start dfx with artifcial delay
if: ${{ env.IS_RELEASE_BRANCH_PR == 'true' }}
working-directory: ${{ matrix.tests.path }}
run: dfx start --clean --background --host 127.0.0.1:8000
- name: Run test
run: |
IS_MERGE_TO_MAIN_FROM_RELEASE=${{ env.IS_MAIN_BRANCH == 'true' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--') }}
if $IS_MERGE_TO_MAIN_FROM_RELEASE; then
RUNS=100
elif ${{ env.IS_RELEASE_BRANCH_PR == 'true' && env.IS_MAIN_BRANCH == 'false' }}; then
RUNS=10
else
RUNS=5
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:
name: Check Azle tests succeeded
needs: run-test
runs-on: ubuntu-latest
if: success()
steps:
- run: exit 0
check-test-failure:
name: Check Azle tests didn't fail
needs: run-test
runs-on: ubuntu-latest
if: failure()
steps:
- run: exit 1