Skip to content

Commit

Permalink
Added the initial version of the action and a worfklow to validate it
Browse files Browse the repository at this point in the history
- There are some work in progress to tackle, since we need to have an example of how to use the action created. This is ongoing.

- Adding results to the action outputs

- In order to be able to validate results, we need to pass the test result to outputs from
the Github configuration. This commit does it.

- Adding the workflow to validate the GH Action

- Adding the step to login so we can pull the image

- Refactor of CI to build and push using repo credentials

- Applying changes from review

- Adding the waitTime and maxAttempts configurable with env variables
  • Loading branch information
fmacleal committed Jul 15, 2024
1 parent 7ec45ae commit 0ace3ac
Show file tree
Hide file tree
Showing 15 changed files with 192 additions and 61 deletions.
15 changes: 15 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
INCLUDE_CASES=00_00_01-sync.js,01_01_01-pre_orchid_2wp.js
RUN_EACH_TEST_FILE_THESE_TIMES=1
RUN_ALL_TESTS_THESE_TIMES=1

# Amount of time in milliseconds for the `waitForBlock` utility function to wait.
# Configurable because depending on the resources of the machine the tests are running on, the wait time might change.
# In a machine with little resources (CPU, RAM, disk), a small wait time might not be enough because blocks can be mined slow and `waitForBlock`
# might fail with a message like `Block number 800 never reached, last seen was 600`, or `Blockchain not advancing after attempting to find a new block 80 times checking every 200 milliseconds.
# Couldn't reach block number 800. Last block number seen was: 600`. In a machine with enough resources having a high wait time might be a waste of time since the tests would run slower because if this wait time.
# In this case, it can be set to a small value. `200` recommended for most machines with enough resources. `500`, `600`, etc., or more for machine with limited resources.
# Adjust as needed, starting with low values so the tests run as fast as they can.
WAIT_FOR_BLOCK_ATTEMPT_TIME_MILLIS=

# Max attempts for the `waitForBlock` utility function to 'wait' for the given block, trying to find that block once every `WAIT_FOR_BLOCK_ATTEMPT_TIME_MILLIS`.
# The same as the `WAIT_FOR_BLOCK_ATTEMPT_TIME_MILLIS` variable, the value for this variable could be updated depending on the machine the tests are running on.
# `80` recommended for most machines with enough resources. `160`, `250` or more for machine with limited resources.
# Adjust as needed, starting with low values so the tests run as fast as they can.
WAIT_FOR_BLOCK_MAX_ATTEMPTS=
36 changes: 36 additions & 0 deletions .github/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Rootstock Integration Tests Action'
description: 'This action provides a containerized environment for running integration tests on Rootstock.'
author: 'Rootstock Labs'

inputs:
rskj-branch:
description: 'The rskj branch to checkout'
required: false
default: 'master'
federator-branch:
description: 'The federate-node branch to checkout'
required: false
default: 'master'
rit-branch:
description: 'The rootstock-integration-tests branch to checkout'
required: false
default: 'main'
rit-log-level:
description: 'Log level for the rootstock-integration-tests'
required: false
default: 'info'

outputs:
status:
description: 'The status of the integration tests'
message:
description: 'The output message of the integration tests'

runs:
using: docker
image: ./images/Dockerfile
env:
RSKJ_BRANCH: ${{ inputs.rskj-branch }}
FEDERATOR_BRANCH: ${{ inputs.federator-branch }}
RIT_BRANCH: ${{ inputs.rit-branch }}
RIT_LOG_LEVEL: ${{ inputs.rit-log-level }}
27 changes: 2 additions & 25 deletions .github/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL Description="Custom RSK node image to execute Rootstock Integration Tests"

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
wget gnupg2 curl git ca-certificates mocha \
wget gnupg2 curl git ca-certificates mocha \
&& apt clean

# -- nodeJs ---------------------------------------------------------
Expand Down Expand Up @@ -32,29 +32,6 @@ ENV JAVA_HOME="/usr/lib/jvm/java-$JAVA_VERSION-openjdk-amd64" \
RUN export JAVA_HOME=$JAVA_HOME \
&& export PATH="$JAVA_HOME:$PATH"

# -- python ---------------------------------------------------------
ENV PYTHON_VERSION=2.7.16

# Install dependencies
RUN apt-get update \
&& apt-get install -y gcc make openssl libffi-dev libgdbm-dev libsqlite3-dev libssl-dev zlib1g-dev \
&& apt-get clean

RUN export PREVIOUS_PATH=$(pwd) \
&& cd /tmp

#Build Python from source
RUN wget https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz \
&& tar --extract -f Python-$PYTHON_VERSION.tgz \
&& cd ./Python-$PYTHON_VERSION/ \
&& ./configure --with-ensurepip=install --enable-optimizations --prefix=/usr/local \
&& make && make install \
&& cd ../ \
&& rm -r ./Python-$PYTHON_VERSION* \
&& python --version \
&& pip --version \
&& cd $PREVIOUS_PATH

# -- bitcoind ---------------------------------------------------------
ENV BITCOIN_VERSION 0.18.1

Expand Down Expand Up @@ -85,4 +62,4 @@ RUN chmod +x /usr/src/entrypoint.sh \

ENTRYPOINT ["/usr/src/entrypoint.sh"]

EXPOSE 18332
EXPOSE 18332
35 changes: 21 additions & 14 deletions .github/images/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@

set -e

RSKJ_BRANCH="master"
POWPEG_BRANCH="master"


echo -e "\n\n--------- Starting the configuration of rskj ---------\n\n"

cd /usr/src/
git clone https://github.com/rsksmart/rskj.git rskj
cd rskj && git checkout $RSKJ_BRANCH
cd rskj && git checkout ${INPUT_RSKJ_BRANCH}
chmod +x ./configure.sh && chmod +x gradlew
./configure.sh
./gradlew --no-daemon clean build -x test
cd ..

echo -e "\n\n--------- Starting the configuration of powpeg ---------\n\n"
cd /usr/src/
git clone https://github.com/rsksmart/powpeg-node.git powpeg
cp configure_gradle_federator.sh powpeg
cd powpeg && git checkout $POWPEG_BRANCH
cd powpeg && git checkout ${INPUT_FEDERATOR_BRANCH}
chmod +x ./configure.sh && chmod +x gradlew
./configure_gradle_federator.sh
FED_VERSION=$(bash configure_gradle_federator.sh)
echo "FED_VERSION=$FED_VERSION"
./configure.sh
./gradlew --info --no-daemon clean build -x test

Expand All @@ -31,13 +27,24 @@ mv configure_rit_locally.sh rit
mv regtest.js rit/config/regtest.js
mv /usr/src/logbacks/* /usr/src/rit/logbacks/
cd rit
git checkout ${INPUT_RIT_BRANCH}
chmod +x ./configure.sh
./configure.sh
./configure_rit_locally.sh "$FED_VERSION"
./configure_rit_locally.sh "${FED_VERSION}"
export LOG_LEVEL=${INPUT_RIT_LOG_LEVEL}

echo -e "\n\n--------- Executing Rootstock Integration Tests ---------\n\n"
npm install -y
npm run test-fail-fast

# Keep the container running
tail -f /dev/null
STATUS=$?

echo -e "\n\n--------- RIT Tests Result ---------\n\n"
if [ $STATUS -ne 0 ]; then
MESSAGE="Rootstock Integration Tests Status: FAILED"
else
MESSAGE="Rootstock Integration Tests Status: PASSED"
fi
echo -e "$MESSAGE"

echo "status=${STATUS}" >>${GITHUB_OUTPUT}
echo "message=${MESSAGE}" >> ${GITHUB_OUTPUT}
3 changes: 1 addition & 2 deletions .github/images/rit-local-configs/logbacks/logback-fed-1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<appender name="FILE-AUDIT"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/Users/fredrhae/Documents/repos/powpeg-config/logs/rsk-fed-1.log</file>
<file>/usr/src/logs/rsk-fed-1.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%date{yyyy-MM-dd-HH:mm:ss.SSS} %p [%c{1}] %m%n
Expand Down Expand Up @@ -111,4 +111,3 @@
<appender-ref ref="FILE-AUDIT"/>
</root>
</configuration>

Loading

0 comments on commit 0ace3ac

Please sign in to comment.