Ndev 3382 #3945
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
name: Deploy image | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, labeled, unlabeled, ready_for_review] | |
repository_dispatch: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
- develop | |
- '[vt][0-9].[0-9]+.[0-9x]+*' | |
tags: | |
- "*" | |
env: | |
DHUBU: ${{secrets.DHUBU}} | |
DHUBP: ${{secrets.DHUBP}} | |
DEVNET_SOLANA_URL: ${{secrets.DEVNET_SOLANA_URL}} | |
MAINNET_SOLANA_URL: ${{secrets.MAINNET_SOLANA_URL}} | |
PROXY_ENDPOINT: "https://api.github.com/repos/${{ github.repository_owner }}/neon-proxy.py" | |
NEON_TESTS_ENDPOINT: ${{vars.NEON_TESTS_ENDPOINT}} | |
DOCKERHUB_ORG_NAME: ${{vars.DOCKERHUB_ORG_NAME}} | |
RUN_LINK_REPO: "${{ github.repository_owner }}/neon-proxy.py" | |
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} | |
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-image: | |
runs-on: ["self-hosted", "k8s-prod"] | |
outputs: | |
evm_tag: ${{ steps.tags.outputs.evm_tag }} | |
evm_sha_tag: ${{ steps.tags.outputs.evm_sha_tag }} | |
evm_pr_version_branch: ${{ steps.tags.outputs.evm_pr_version_branch }} | |
is_evm_release: ${{ steps.tags.outputs.is_evm_release }} | |
neon_test_tag: ${{ steps.tags.outputs.neon_test_tag }} | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: actions/setup-python@v5 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- run: pip install -r ./.github/workflows/requirements.txt | |
- name: Specify image tags | |
run: | | |
python3 ./.github/workflows/deploy.py specify_image_tags \ | |
--git_ref=${{ github.ref }} \ | |
--git_head_ref=${{ github.head_ref }} \ | |
--git_base_ref=${{ github.base_ref }} | |
- name: Set outputs | |
id: tags | |
run: | | |
echo "evm_tag=${{ env.EVM_TAG }}" >> "$GITHUB_OUTPUT" | |
echo "evm_sha_tag=${{ github.sha }}" >> "$GITHUB_OUTPUT" | |
echo "evm_pr_version_branch=${{ env.EVM_PR_VERSION_BRANCH }}" >> "$GITHUB_OUTPUT" | |
echo "is_evm_release=${{ env.IS_EVM_RELEASE }}" >> "$GITHUB_OUTPUT" | |
echo "neon_test_tag=${{ env.NEON_TEST_TAG }}" >> "$GITHUB_OUTPUT" | |
- name: build docker image | |
run: | | |
python3 ./.github/workflows/deploy.py build_docker_image \ | |
--evm_sha_tag=${{ steps.tags.outputs.evm_sha_tag }} | |
- name: publish image | |
run: | | |
python3 ./.github/workflows/deploy.py publish_image \ | |
--evm_sha_tag=${{ steps.tags.outputs.evm_sha_tag }} \ | |
--evm_tag=${{ steps.tags.outputs.evm_tag }} | |
run-evm-tests: | |
runs-on: ["self-hosted", "k8s-prod"] | |
needs: | |
- build-image | |
steps: | |
- name: Set environment variables | |
run: | | |
echo "EVM_LOADER_IMAGE=${{ env.DOCKERHUB_ORG_NAME }}/evm_loader:${{ needs.build-image.outputs.evm_sha_tag }}" >> $GITHUB_ENV | |
echo "NEON_TESTS_IMAGE=${{ env.DOCKERHUB_ORG_NAME }}/neon_tests:${{ needs.build-image.outputs.neon_test_tag }}" >> $GITHUB_ENV | |
echo "PROJECT_NAME=neon-evm-${{ needs.build-image.outputs.evm_sha_tag }}-${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV | |
echo "NETWORK=docker_net" >> $GITHUB_ENV | |
env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: actions/setup-python@v5 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Stop containers (cleanup from previous runs) | |
run: | | |
docker-compose -p "${{ env.PROJECT_NAME }}" -f ./ci/docker-compose-ci.yml down || true | |
- name: Docker compose pull | |
run: | | |
docker-compose -p "${{ env.PROJECT_NAME }}" -f ./ci/docker-compose-ci.yml pull | |
- name: Docker compose up | |
run: | | |
docker-compose -p "${{ env.PROJECT_NAME }}" -f ./ci/docker-compose-ci.yml up -d | |
- name: Get test container name | |
id: get_container_name | |
run: | | |
docker ps -a | |
TEST_CONTAINER_NAME=$(docker ps --format "{{.Names}}" | grep ${{ env.PROJECT_NAME }} | grep test) | |
echo "TEST_CONTAINER_NAME=$TEST_CONTAINER_NAME" | tee -a $GITHUB_ENV | |
- name: Run tests | |
run: | | |
docker exec ${{ env.TEST_CONTAINER_NAME }} python3 clickfile.py run evm --numprocesses 8 --network "${{ env.NETWORK }}" | |
- name: "Generate allure report" | |
if: always() | |
uses: neonlabsorg/neon-tests/.github/actions/generate-allure-report@develop | |
with: | |
container: ${{ env.TEST_CONTAINER_NAME }} | |
network: ${{ env.NETWORK }} | |
aws_access_key_id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
tests_name: evm | |
- name: Stop containers | |
if: always() | |
run: | | |
docker-compose -p "${{ env.PROJECT_NAME }}" -f ./ci/docker-compose-ci.yml down | |
trigger-proxy-tests: | |
runs-on: ["self-hosted", "k8s-prod"] | |
needs: | |
- build-image | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: actions/setup-python@v5 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- run: pip install -r ./.github/workflows/requirements.txt | |
- name: Trigger proxy build | |
run: | | |
python3 ./.github/workflows/deploy.py trigger_proxy_action \ | |
--evm_pr_version_branch=${{ needs.build-image.outputs.evm_pr_version_branch }} \ | |
--is_evm_release=${{ needs.build-image.outputs.is_evm_release }} \ | |
--evm_sha_tag=${{ needs.build-image.outputs.evm_sha_tag }} \ | |
--evm_tag=${{ needs.build-image.outputs.evm_tag }} \ | |
--token=${{secrets.GHTOKEN }} \ | |
--labels='${{ toJson(github.event.pull_request.labels.*.name) }}' \ | |
--pr_url="${{ github.api_url }}/repos/${{ github.repository }}/issues" \ | |
--pr_number="${{ github.event.pull_request.number }}" | |
- name: Cancel the build if job failed | |
if: "failure()" | |
uses: "andymckay/[email protected]" | |
finalize-image: | |
runs-on: ["self-hosted", "k8s-prod"] | |
needs: | |
- build-image | |
- trigger-proxy-tests | |
- run-evm-tests | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: actions/setup-python@v5 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- run: pip install -r ./.github/workflows/requirements.txt | |
- name: Finalize image | |
run: | | |
python3 ./.github/workflows/deploy.py finalize_image \ | |
--evm_sha_tag=${{ needs.build-image.outputs.evm_sha_tag }} \ | |
--evm_tag=${{ needs.build-image.outputs.evm_tag }} | |
- name: Send notification to slack | |
if: failure() | |
run: | | |
python3 ./.github/workflows/deploy.py send_notification \ | |
--evm_tag=${{ needs.build-image.outputs.evm_tag }} \ | |
--url=${{secrets.SLACK_EVM_CHANNEL_URL}} \ | |
--build_url=${BUILD_URL} |