Run a node with selected configuration #464
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: '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 | |
- archiveSync.json | |
- fastSync.json | |
- fullSync.json | |
- fuzzer.json | |
non_validator_mode: | |
description: "If checked, node will be started in NonValidator mode (OldBodies and oldReceipts will not be synced)" | |
default: true | |
type: boolean | |
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 | |
additional_options: | |
description: "A Json property which allows to customize node even more" | |
default: '{"timeout":"24", "default_dockerfile":"Dockerfile", "default_dockerfile_build_type":"release", "ssh_keys":"", "allowed_ips":""}' | |
jobs: | |
create_docker_image: | |
runs-on: ubuntu-latest | |
outputs: | |
base_tag: ${{ steps.set-base-tag.outputs.base_tag }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- 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: Set BASE_TAG | |
id: set-base-tag | |
env: | |
GITHUB_USERNAME: ${{ github.actor }} | |
run: | | |
BASE_TAG="${GITHUB_USERNAME:0:1}$(shuf -i 1000-9999 -n 1)" | |
echo "BASE_TAG=$BASE_TAG" >> $GITHUB_ENV | |
echo "base_tag=$BASE_TAG" >> $GITHUB_OUTPUT | |
- name: Creating a node with NodeName="DevNode-${{ github.actor }}-${{ env.BASE_TAG }}-${{ env.CLEAN_REF }}-${{ inputs.network }}-${{ inputs.cl_client }}" | |
run: echo "NodeName='DevNode-${{ github.actor }}-${{ env.BASE_TAG }}-${{ env.CLEAN_REF }}-${{ inputs.network }}-${{ inputs.cl_client }}'" | |
- name: Extract dockerfile from additional_options | |
id: extract_dockerfile | |
run: | | |
echo "dockerfile=$(echo '${{ inputs.additional_options }}' | jq -r .default_dockerfile)" >> $GITHUB_OUTPUT | |
echo "build-config=$(echo '${{ inputs.additional_options }}' | jq -r .default_dockerfile_build_type | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
- name: Set Repo and Org Variables | |
run: | | |
echo "ORG_NAME=${{ github.repository_owner }}" >> $GITHUB_ENV | |
echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV | |
- name: Check if master branch and default additional_options | |
id: check_conditions | |
run: | | |
if | |
[[ "${{ github.ref }}" == "refs/heads/master" ]] && | |
[[ "${{ steps.extract_dockerfile.outputs.dockerfile }}" == "Dockerfile" ]] && | |
[[ "${{ steps.extract_dockerfile.outputs.build-config }}" == "release" ]]; then | |
echo "skip_docker_build=true" >> $GITHUB_OUTPUT | |
else | |
echo "skip_docker_build=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Trigger Docker Build Action with Cleaned Ref | |
if: steps.check_conditions.outputs.skip_docker_build != 'true' | |
uses: benc-uk/workflow-dispatch@v1 | |
env: | |
ADDITIONAL_OPTIONS: ${{ inputs.additional_options }} | |
with: | |
workflow: publish-docker.yml | |
ref: "${{ github.ref }}" | |
token: "${{ secrets.REPOSITORY_DISPATCH_TOKEN }}" | |
inputs: '{ | |
"tag": "${{ env.CLEAN_REF }}", | |
"dockerfile": "${{ steps.extract_dockerfile.outputs.dockerfile }}", | |
"build-config": "${{ steps.extract_dockerfile.outputs.build-config }}" | |
}' | |
- name: Wait for Docker Build Action to complete | |
if: steps.check_conditions.outputs.skip_docker_build != 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPOSITORY_DISPATCH_TOKEN }} | |
WORKFLOW_ID: 'publish-docker.yml' | |
MAX_WAIT_MINUTES: '5' | |
INTERVAL: '5' | |
TIMEOUT: '10' | |
ORG_NAME: ${{ env.ORG_NAME }} | |
REPO_NAME: ${{ env.REPO_NAME }} | |
REF: ${{ github.ref }} | |
run: | | |
chmod +x scripts/wait-for-workflow-completed.sh | |
./scripts/wait-for-workflow-completed.sh | |
working-directory: ${{ github.workspace }} | |
trigger_node_and_vm_creation: | |
needs: create_docker_image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- 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: Extract Variables | |
id: extract_variables | |
run: | | |
echo "BASE_TAG=${{ needs.create_docker_image.outputs.base_tag }}" >> $GITHUB_ENV | |
echo "timeout=$(echo ${{ inputs.additional_options }} | jq -r .timeout)" >> $GITHUB_OUTPUT | |
echo "ssh_keys=$(echo ${{ inputs.additional_options }} | jq -r .ssh_keys)" >> $GITHUB_OUTPUT | |
echo "allowed_ips=$(echo ${{ inputs.additional_options }} | jq -r .allowed_ips)" >> $GITHUB_OUTPUT | |
- 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 }}", | |
"base_tag": "${{ env.BASE_TAG }}", | |
"config_file": "${{ inputs.config }}", | |
"nethermind_branch": "${{ env.CLEAN_REF }}", | |
"network": "${{ inputs.network }}", | |
"cl_client": "${{ inputs.cl_client }}", | |
"additional_options": "{\"cl_custom_image\":\"${{ inputs.cl_custom_image }}\", \"timeout\":\"${{ steps.extract_variables.outputs.timeout }}\", \"non_validator_mode\":${{ inputs.non_validator_mode }}, \"additional_nethermind_flags\":\"${{ inputs.additional_nethermind_flags }}\", \"additional_cl_flags\":\"${{ inputs.additional_cl_flags }}\", \"ssh_keys\":\"${{ steps.extract_variables.outputs.ssh_keys }}\", \"allowed_ips\":\"${{ steps.extract_variables.outputs.allowed_ips }}\"}" | |
}' | |
- name: Wait for creation of node | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPOSITORY_DISPATCH_TOKEN }} | |
WORKFLOW_ID: 'run-single-node.yml' | |
MAX_WAIT_MINUTES: '5' | |
INTERVAL: '5' | |
TIMEOUT: '20' | |
ORG_NAME: 'NethermindEth' | |
REPO_NAME: 'post-merge-smoke-tests' | |
REF: 'main' | |
run: | | |
chmod +x scripts/wait-for-workflow-completed.sh | |
./scripts/wait-for-workflow-completed.sh | tee script-output.txt | |
run_id=$(grep -oP 'Run ID: \K\d+' script-output.txt) | |
echo "Run ID extracted is: $run_id" | |
echo "RUN_ID=$run_id" >> $GITHUB_ENV | |
working-directory: ${{ github.workspace }} | |
- name: Download machine specs artifact | |
run: | | |
ARTIFACT_ID=$(curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.REPOSITORY_DISPATCH_TOKEN }}" https://api.github.com/repos/NethermindEth/post-merge-smoke-tests/actions/runs/${{ env.RUN_ID }}/artifacts | jq '.artifacts[0].id') | |
curl -L -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.REPOSITORY_DISPATCH_TOKEN }}" -o artifact.zip https://api.github.com/repos/NethermindEth/post-merge-smoke-tests/actions/artifacts/$ARTIFACT_ID/zip | |
unzip artifact.zip -d ./downloaded-artifacts/ | |
- name: Display machine specs content | |
run: | | |
FILE=$(ls downloaded-artifacts/machine-details | head -n 1) | |
cat "downloaded-artifacts/machine-details/$FILE" |