From a576133b4b908f40888d28b30f5a75e2c1463a83 Mon Sep 17 00:00:00 2001 From: MarekM25 Date: Mon, 17 Apr 2023 16:35:39 +0200 Subject: [PATCH] add Kamil's workflow to 1.17.4 branch --- .../run-a-single-node-from-branch.yml | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 .github/workflows/run-a-single-node-from-branch.yml diff --git a/.github/workflows/run-a-single-node-from-branch.yml b/.github/workflows/run-a-single-node-from-branch.yml new file mode 100644 index 00000000000..da384a85b73 --- /dev/null +++ b/.github/workflows/run-a-single-node-from-branch.yml @@ -0,0 +1,162 @@ +name: 'Run a node with selected configuration' + +on: + workflow_dispatch: + inputs: + network: + description: "Select a network on which You want to run a node" + default: "mainnet" + required: true + type: choice + options: + - mainnet + - gnosis + - sepolia + - goerli + - chiado + cl_client: + description: "Select Consensus Layer Client to run node against" + default: "" + required: true + type: choice + options: + - lighthouse + - lodestar + #- nimbus + - prysm + - teku + cl_custom_image: + description: "In case of need to run non-default cl image (different than actually supported by Sedge) put it in there" + default: "" + required: false + config: + description: "Select a config file which will be selected for tests." + default: "default.json" + required: true + type: choice + options: + - default.json + - fastSync.json + - fullSync.json + - fuzzer.json + timeout: + description: "Timeout in hours before triggering the deletion of smoke test instances. Maximum time of node lifetime can be 72 hours." + default: "24" + required: true + additional_nethermind_flags: + description: "Provide any additional flags to the Nethermind in space-separated format. Example: \"JsonRpc.Enabled=false Sync.SnapSync=false\"." + default: "" + required: false + additional_cl_flags: + description: "Provide any additional flags to the CL client in space-separated format. Example: \"clflag1=1 clflag2=2\"." + default: "" + required: false + +jobs: + create_docker_image: + runs-on: ubuntu-latest + steps: + - name: Prepare docker tag + id: prepare_ref + run: | + REF_NAME=${{ github.ref }} + CLEAN_REF=$(echo "${REF_NAME/refs\/heads\//}" | sed 's/[^a-zA-Z0-9._-]/-/g') + echo "CLEAN_REF=$CLEAN_REF" >> $GITHUB_ENV + - name: Creating a node with NodeName="DevNode-${{ github.actor }}-${{ env.CLEAN_REF }}-${{ inputs.network }}-${{ inputs.cl_client }}" + run: echo "NodeName='DevNode-${{ github.actor }}-${{ env.CLEAN_REF }}-${{ inputs.network }}-${{ inputs.cl_client }}'" + + - name: Trigger Docker Build Action with Cleaned Ref + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: build-nethermind-docker-images.yml + ref: "${{ github.ref }}" + token: "${{ secrets.REPOSITORY_DISPATCH_TOKEN }}" + inputs: '{ + "repo": "nethermindeth/nethermind", + "tag": "${{ env.CLEAN_REF }}", + "dockerfile": "Dockerfile" + }' + + - name: Wait for Docker Build Action to complete + env: + GITHUB_TOKEN: ${{ secrets.REPOSITORY_DISPATCH_TOKEN }} + run: | + # Replace `workflow_id` with the ID of the workflow you want to wait for. + workflow_id="8166053" #Id of Docker build workflow + + # Set the maximum waiting time (in minutes) and initialize the counter + max_wait_minutes=3 + counter=0 + + # Get the current time in ISO 8601 format + current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + + # Wait for the workflow to be triggered + while true; do + run_id=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/NethermindEth/nethermind/actions/workflows/${workflow_id}/runs" | \ + jq -r --arg ref "$(echo '${{ github.ref }}' | sed 's/refs\/heads\///')" --arg current_time "$current_time" \ + '.workflow_runs[] | select(.head_branch == $ref and .created_at >= $current_time) | .id') + if [ -n "$run_id" ]; then + break + fi + + # Increment the counter and check if the maximum waiting time is reached + counter=$((counter + 1)) + if [ $((counter * 30)) -ge $((max_wait_minutes * 60)) ]; then + echo "Maximum waiting time for the workflow to be triggered has been reached. Exiting." + exit 1 + fi + + echo "Waiting for the workflow to be triggered..." + sleep 30 + done + + # Wait for the triggered workflow to complete and check its conclusion + while true; do + run_data=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/NethermindEth/nethermind/actions/runs/$run_id") + status=$(echo "$run_data" | jq -r '.status') + + if [ "$status" = "completed" ]; then + conclusion=$(echo "$run_data" | jq -r '.conclusion') + if [ "$conclusion" != "success" ]; then + echo "The workflow has not completed successfully. Exiting." + exit 1 + else + echo "The workflow completed successfully! Exiting." + break + fi + fi + echo "Waiting for the workflow to complete..." + sleep 30 + done + + trigger_node_and_vm_creation: + needs: create_docker_image + runs-on: ubuntu-latest + steps: + - name: Prepare docker tag + id: prepare_ref + run: | + REF_NAME=${{ github.ref }} + CLEAN_REF=$(echo "${REF_NAME/refs\/heads\//}" | sed 's/[^a-zA-Z0-9._-]/-/g') + echo "CLEAN_REF=$CLEAN_REF" >> $GITHUB_ENV + - name: Trigger Node creation Repo Action + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: run-single-node.yml + repo: NethermindEth/post-merge-smoke-tests + ref: "main" + token: "${{ secrets.REPOSITORY_DISPATCH_TOKEN }}" + inputs: '{ + "github_username": "${{ github.actor }}", + "config_file": "${{ inputs.config }}", + "nethermind_branch": "${{ env.CLEAN_REF }}", + "network": "${{ inputs.network }}", + "cl_client": "${{ inputs.cl_client }}", + "cl_custom_image": "${{ inputs.cl_custom_image }}", + "timeout": "${{ inputs.timeout }}", + "additional_nethermind_flags": "${{ inputs.additional_nethermind_flags }}", + "additional_cl_flags": "${{ inputs.additional_cl_flags }}" + }' \ No newline at end of file