diff --git a/.github/tests/00-cardano-node-integration-tests/Dockerfile b/.github/tests/00-cardano-node-integration-tests/Dockerfile new file mode 100644 index 0000000..be33dad --- /dev/null +++ b/.github/tests/00-cardano-node-integration-tests/Dockerfile @@ -0,0 +1,4 @@ +FROM 2ndlayer/centos-cardano-node:1.24.2 + +COPY srv/cardano/cardano-node/etc/config.yaml /srv/cardano/cardano-node/etc/ +COPY usr/local/lib /usr/local/lib \ No newline at end of file diff --git a/.github/tests/00-cardano-node-integration-tests/prepare-cardano-node-shelley-testnet-environment.sh b/.github/tests/00-cardano-node-integration-tests/prepare-cardano-node-shelley-testnet-environment.sh new file mode 100644 index 0000000..b3ba00b --- /dev/null +++ b/.github/tests/00-cardano-node-integration-tests/prepare-cardano-node-shelley-testnet-environment.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e + +# © 2020 PERLUR Group +# +# SPDX-License-Identifier: GPL-3.0-only OR LGPL-3.0-only + +if ! which jq >> /dev/null 2>&1; then + echo "ERROR: jq binary is missing!" + exit 0 +fi +if ! which docker >> /dev/null 2>&1; then + echo "ERROR: docker binary is missing!" + exit 0 +fi +if ! cd ${PWD}/.github/tests/00-cardano-node-integration-tests/; then + echo "ERROR: Failed to switch to cardano-node-integration-tests directory!" +fi + +GH_JSON=$(curl --proto '=https' --tlsv1.2 -sSf "https://api.github.com/repos/input-output-hk/cardano-node/releases/latest") +if [ $(jq -r .prerelease <<< ${GH_JSON}) == false ]; then + cardanoNodeVersionTag=$(jq -r .tag_name <<< ${GH_JSON}) + echo "Discovered Cardano Node ${cardanoNodeVersionTag}" + cardanoNodeVersion=${cardanoNodeVersionTag} +fi + +sed -i "s//${cardanoNodeVersionTag}/" \ + ${PWD}/Dockerfile + +echo "Pull Docker image from Docker Hub" +if ! docker pull 2ndlayer/centos-cardano-node:${cardanoNodeVersion} >> /dev/null 2>&1; then + echo "ERROR: Docker image pull failed!" + exit 0 +else TESTNET_MAGIC=${RANDOM} + docker build -t local/cardano-node-shelley-testnet:${cardanoNodeVersion} ./ + + if docker run local/cardano-node-shelley-testnet:${cardanoNodeVersion} \ + bash /usr/local/lib/cardano-node-integration-testing-create-testnet.sh; + then + CONTAINER_ID=$(docker ps -aq | head -n 1) + if docker commit ${CONTAINER_ID} local/cardano-node-shelley-testnet:${cardanoNodeVersion}; then + echo "INFO: Initial testing Shelley environment commited!" + fi + if docker run \ + local/cardano-node-shelley-testnet:${cardanoNodeVersion} \ + bash /usr/local/lib/cardano-node-integration-testing-update-genesis.sh; + then + echo "INFO: Testnet INIT scripts executed!" + if docker commit ${CONTAINER_ID} local/cardano-node-shelley-testnet:${cardanoNodeVersion}; then + echo "DEBUG: Image name: local/cardano-node-shelley-testnet:${cardanoNodeVersion}" + fi + else + echo "ERROR: Failed to execute testnet INIT scripts!" + exit 0 + fi + else + echo "ERROR: Failed to create Shelley testing environment!" + exit 0 + fi +fi \ No newline at end of file diff --git a/.github/tests/00-cardano-node-integration-tests/srv/cardano/cardano-node/etc/config.yaml b/.github/tests/00-cardano-node-integration-tests/srv/cardano/cardano-node/etc/config.yaml new file mode 100644 index 0000000..835f1f1 --- /dev/null +++ b/.github/tests/00-cardano-node-integration-tests/srv/cardano/cardano-node/etc/config.yaml @@ -0,0 +1,61 @@ +"TurnOnLogging": true, +"TurnOnLogMetrics": true, +"TracingVerbosity": "NormalVerbosity", +"minSeverity": "Debug", +"TraceBlockFetchClient": false, +"TraceBlockFetchDecisions": false, +"TraceBlockFetchProtocol": false, +"TraceBlockFetchProtocolSerialised": false, +"TraceBlockFetchServer": false, +"TraceBlockchainTime": false, +"TraceChainDb": true, +"TraceChainSyncBlockServer": false, +"TraceChainSyncClient": false, +"TraceChainSyncHeaderServer": false, +"TraceChainSyncProtocol": false, +"TraceDNSResolver": true, +"TraceDNSSubscription": true, +"TraceErrorPolicy": true, +"TraceForge": true, +"TraceHandshake": false, +"TraceIpSubscription": true, +"TraceLocalChainSyncProtocol": false, +"TraceLocalErrorPolicy": true, +"TraceLocalHandshake": false, +"TraceLocalTxSubmissionProtocol": false, +"TraceLocalTxSubmissionServer": false, +"TraceMempool": true, +"TraceMux": false, +"TraceTxInbound": false, +"TraceTxOutbound": false, +"TraceTxSubmissionProtocol": false, +"setupBackends": [ + "KatipBK" +], +"defaultBackends": [ + "KatipBK" +], +"hasEKG": 12788, +"hasPrometheus": [ + "127.0.0.1", + 12798 +], +"setupScribes": [ + { + "scFormat": "ScText", + "scKind": "StdoutSK", + "scName": "stdout", + "scRotation": null + } +], +"defaultScribes": [ + [ + "StdoutSK", + "stdout" + ] +], +"rotation": { + "rpKeepFilesNum": 10, + "rpLogLimitBytes": 5000000, + "rpMaxAgeHours": 24 + }, \ No newline at end of file diff --git a/.github/tests/00-cardano-node-integration-tests/usr/local/lib/cardano-node-integration-testing-create-testnet.sh b/.github/tests/00-cardano-node-integration-tests/usr/local/lib/cardano-node-integration-testing-create-testnet.sh new file mode 100644 index 0000000..6327c7d --- /dev/null +++ b/.github/tests/00-cardano-node-integration-tests/usr/local/lib/cardano-node-integration-testing-create-testnet.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +# © 2020 PERLUR Group +# +# SPDX-License-Identifier: GPL-3.0-only OR LGPL-3.0-only + +# Print diagnostic information +echo "PWD:" $(pwd) + +TESTNET_MAGIC=${RANDOM} + +if cardano-cli genesis create \ + --genesis-dir testnet \ + --gen-utxo-keys 3 \ + --supply 100000 \ + --testnet-magic ${TESTNET_MAGIC}; +then + echo "INFO: Initial testing Shelley environment created!" +else + echo "ERROR: Initial testing Shelley environment creation failed!" + exit 0 +fi + + +# +# Modify genesis.spec.json +# + +TMP_FILE=$(mktemp) +cat testnet/genesis.spec.json | jq .epochLength=300 > ${TMP_FILE} +cat ${TMP_FILE} \ + | jq .protocolParams.decentralisationParam=0 > testnet/genesis.spec.json + +rm ${TMP_FILE} + +# +# Modify genesis.json +# + +TMP_FILE=$(mktemp) +cat testnet/genesis.json | jq .epochLength=300 > ${TMP_FILE} +cat ${TMP_FILE} \ + | jq .protocolParams.decentralisationParam=0 > etc/genesis.json +cp ${TMP_FILE} testnet/genesis.json + +rm ${TMP_FILE} \ No newline at end of file diff --git a/.github/tests/00-cardano-node-integration-tests/usr/local/lib/cardano-node-integration-testing-update-genesis.sh b/.github/tests/00-cardano-node-integration-tests/usr/local/lib/cardano-node-integration-testing-update-genesis.sh new file mode 100644 index 0000000..ee3e9ce --- /dev/null +++ b/.github/tests/00-cardano-node-integration-tests/usr/local/lib/cardano-node-integration-testing-update-genesis.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +# © 2020 PERLUR Group +# +# SPDX-License-Identifier: GPL-3.0-only OR LGPL-3.0-only + +# Print diagnostic information +echo "PWD:" $(pwd) + +# +# Modify genesis.spec.json +# + +TMP_FILE=$(mktemp) +cat testnet/genesis.spec.json | jq .epochLength=300 > ${TMP_FILE} +cat ${TMP_FILE} \ + | jq .protocolParams.decentralisationParam=0 > testnet/genesis.spec.json + +rm ${TMP_FILE} + +# +# Modify genesis.json +# + +TMP_FILE=$(mktemp) +cat testnet/genesis.json | jq .epochLength=300 > ${TMP_FILE} +cat ${TMP_FILE} \ + | jq .protocolParams.decentralisationParam=0 > etc/genesis.json +cp ${TMP_FILE} testnet/genesis.json + +rm ${TMP_FILE} \ No newline at end of file diff --git a/.github/workflows/cardano-node-integration-testing.yaml b/.github/workflows/cardano-node-integration-testing.yaml new file mode 100644 index 0000000..46738bf --- /dev/null +++ b/.github/workflows/cardano-node-integration-testing.yaml @@ -0,0 +1,17 @@ +name: Cardano Node Integration Testing + +on: + push: + pull_request: + branches: [ master ] + +jobs: + prepare_testnet_shelley: + name: Prepare Cardano Node Testnet - Shelley + runs-on: ubuntu-latest + + steps: + - name: Prepare Git environment + uses: actions/checkout@v2 + - name: Build Cardano Node Shelley Testnet Docker Images + run: bash .github/tests/00-cardano-node-integration-tests/prepare-cardano-node-shelley-testnet-environment.sh \ No newline at end of file