From 3ed8bd394cc6f5e0dfc69ff955ef1fa390d61304 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Thu, 22 Feb 2024 12:58:58 +0100 Subject: [PATCH] added test solana programs --- .github/workflows/deploy.py | 9 ++++++--- .github/workflows/github_api_client.py | 9 +++++++++ .github/workflows/pipeline.yml | 5 +++-- Dockerfile | 6 +++--- ci/solana-run-neon.sh | 12 ++++++++---- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.py b/.github/workflows/deploy.py index 1c5eecfb6..20d7ef6a1 100644 --- a/.github/workflows/deploy.py +++ b/.github/workflows/deploy.py @@ -105,16 +105,19 @@ def run_subprocess(command): @cli.command(name="run_tests") @click.option('--github_sha') @click.option('--neon_test_branch') -def run_tests(github_sha, neon_test_branch): +@click.option('--base_ref_branch') +def run_tests(github_sha, neon_test_branch, base_ref_branch): os.environ["EVM_LOADER_IMAGE"] = f"{IMAGE_NAME}:{github_sha}" - if neon_test_branch in GithubClient.get_branches_list(NEON_TESTS_ENDPOINT) \ + if GithubClient.is_branch_exist(NEON_TESTS_ENDPOINT, neon_test_branch) \ and neon_test_branch not in ('master', 'develop'): neon_test_image_tag = neon_test_branch + elif re.match(VERSION_BRANCH_TEMPLATE, base_ref_branch): # PR to version branch + neon_test_image_tag = base_ref_branch else: neon_test_image_tag = 'latest' os.environ["NEON_TESTS_IMAGE"] = f"{NEON_TEST_IMAGE_NAME}:{neon_test_image_tag}" - + click.echo(f"NEON_TESTS_IMAGE: {os.environ['NEON_TESTS_IMAGE']}") project_name = f"neon-evm-{github_sha}" stop_containers(project_name) diff --git a/.github/workflows/github_api_client.py b/.github/workflows/github_api_client.py index 198a4892a..3aa3fd850 100644 --- a/.github/workflows/github_api_client.py +++ b/.github/workflows/github_api_client.py @@ -42,6 +42,15 @@ def get_branches_list(endpoint): proxy_branches_obj = requests.get( f"{endpoint}/branches?per_page=100").json() return [item["name"] for item in proxy_branches_obj] + @staticmethod + def is_branch_exist(endpoint, branch): + if branch: + response = requests.get(f"{endpoint}/branches/{branch}") + if response.status_code == 200: + click.echo(f"The branch {branch} exist in the {endpoint} repository") + return True + else: + return False def get_proxy_run_info(self, id): response = requests.get( diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 0418a9cf7..e1e58d6e3 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -64,7 +64,7 @@ jobs: elif [[ "${{ steps.tag_creation.outputs.base_branch }}" != "" ]]; then # tag creation tag=${{ steps.tag_creation.outputs.base_branch }} - elif [[ "${{ github.head_ref }}" != "" ]]; then # pr to feature or version branch + elif [[ "${{ github.head_ref }}" != "" ]]; then # pr to feature or version branch or develop tag=${{ github.head_ref }} else tag='develop' @@ -75,7 +75,8 @@ jobs: run: | python3 ./.github/workflows/deploy.py run_tests \ --github_sha=${GITHUB_SHA} \ - --neon_test_branch=${{ steps.neon_test_branch.outputs.value }} + --neon_test_branch=${{ steps.neon_test_branch.outputs.value }} \ + --base_ref_branch=${{ github.base_ref }} trigger-proxy-tests: runs-on: trigger-runner needs: diff --git a/Dockerfile b/Dockerfile index 04bf9c5c8..75f4656c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN cargo fmt --check && \ # Add neon_test_invoke_program to the genesis -FROM neonlabsorg/neon_test_invoke_program:develop AS neon_test_invoke_program +FROM neonlabsorg/neon_test_programs:latest AS neon_test_programs # Define solana-image that contains utility FROM builder AS base @@ -40,8 +40,8 @@ COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/deploy/evm_loader COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/deploy/evm_loader-dump.txt /opt/ COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/release/neon-cli /opt/ COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/release/neon-api /opt/ -COPY --from=neon_test_invoke_program /opt/neon_test_invoke_program.so /opt/ -COPY --from=neon_test_invoke_program /opt/neon_test_invoke_program-keypair.json /opt/ + +COPY --from=neon_test_programs /opt/deploy/ /opt/deploy/ COPY ci/wait-for-solana.sh \ ci/wait-for-neon.sh \ diff --git a/ci/solana-run-neon.sh b/ci/solana-run-neon.sh index 8f58a1122..0deda3f77 100755 --- a/ci/solana-run-neon.sh +++ b/ci/solana-run-neon.sh @@ -12,9 +12,6 @@ EVM_LOADER_PATH=${NEON_BIN}/evm_loader.so METAPLEX=metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s METAPLEX_PATH=${NEON_BIN}/metaplex.so -TEST_INVOKE_PROGRAM_ID_KEYPAIR=${NEON_BIN}/neon_test_invoke_program-keypair.json -TEST_INVOKE=$(solana address -k ${TEST_INVOKE_PROGRAM_ID_KEYPAIR}) -TEST_INVOKE_PATH=${NEON_BIN}/neon_test_invoke_program.so VALIDATOR_ARGS=( --reset @@ -23,9 +20,16 @@ VALIDATOR_ARGS=( --ticks-per-slot 16 --upgradeable-program ${EVM_LOADER} ${EVM_LOADER_PATH} ${EVM_LOADER_AUTHORITY_KEYPAIR} --bpf-program ${METAPLEX} ${METAPLEX_PATH} - --bpf-program ${TEST_INVOKE} ${TEST_INVOKE_PATH} ) +LIST_OF_TEST_PROGRAMS=("test_invoke_program" "counter" "cross_program_invocation" "transfer_sol" "transfer_tokens") + +for program in "${LIST_OF_TEST_PROGRAMS[@]}"; do + keypair="${NEON_BIN}/deploy/${program}/${program}-keypair.json" + address=$(solana address -k $keypair) + VALIDATOR_ARGS+=(--bpf-program $address ${NEON_BIN}/deploy/$program/$program.so) +done + if [[ -n $GEYSER_PLUGIN_CONFIG ]]; then echo "Using geyser plugin with config: $GEYSER_PLUGIN_CONFIG" VALIDATOR_ARGS+=(--geyser-plugin-config $GEYSER_PLUGIN_CONFIG)