From abd3f5d42478154054a16ab4d80a687a9d2ae169 Mon Sep 17 00:00:00 2001 From: fmacleal Date: Wed, 17 Jul 2024 16:20:37 +0200 Subject: [PATCH] Applying some other suggestions from review - Refactored the name from federator to powpeg-node - Created a regular user to be used by the process - Created a first version of a README for the action - Added exit codes to the actions --- .github/README.md | 47 +++++++++++++++++++ .github/images/Dockerfile | 16 +++++-- .github/images/entrypoint.sh | 15 ++++-- ...ederator.sh => configure_gradle_powpeg.sh} | 3 +- .github/workflows/ci.yml | 2 +- .gitignore | 3 +- 6 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 .github/README.md rename .github/images/scripts/{configure_gradle_federator.sh => configure_gradle_powpeg.sh} (99%) diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 00000000..324b9adb --- /dev/null +++ b/.github/README.md @@ -0,0 +1,47 @@ +# Rootstock Integration Tests Action + +This action provides a containerized environment for running integration tests on Rootstock. +It receives as inputs the branches of powpeg, rskj and rootstock-integration-tests repositories, +checkout at the branches passed as parameters, build the projects and run the integration tests. + +The rootstock-integration-tests it's a project that tests the integration between rskj and powpeg-node, +it validates that the peg-in and peg-out processes are working correctly. It's extremely important to both projects, +and should be executed before any release of both projects or any merge to the master/main branch. + +## Inputs + +### `rskj-branch` + +**Optional** The rskj branch to checkout. Default is `master`. + +### `powpeg-node-branch` + +**Optional** The powpeg-node branch to checkout. Default is `master`. + +### `rit-branch` + +**Optional** The rootstock-integration-tests branch to checkout. Default is `main`. + +### `rit-log-level` + +**Optional** Log level for the rootstock-integration-tests. Default is `info`. + +## Outputs + +### `status` + +The status of the integration tests. + +### `message` + +The output message of the integration tests. + +## Example usage + +```yaml +uses: docker://ghcr.io/rsksmart/rootstock-integration-tests/rit:latest +with: + rskj-branch: master + powpeg-node-branch: master + rit-branch: main +``` \ No newline at end of file diff --git a/.github/images/Dockerfile b/.github/images/Dockerfile index 3ffddc6f..77dbce36 100644 --- a/.github/images/Dockerfile +++ b/.github/images/Dockerfile @@ -26,10 +26,9 @@ ENV JAVA_VERSION 11 RUN apt-get -y install "openjdk-$JAVA_VERSION-jdk" -ENV JAVA_HOME="/usr/lib/jvm/java-$JAVA_VERSION-openjdk-amd64" \ - PATH="$JAVA_HOME:$PATH" +ENV JAVA_HOME="/usr/lib/jvm/java-$JAVA_VERSION-openjdk-amd64" -RUN export JAVA_HOME=$JAVA_HOME \ +RUN export JAVA_HOME="$JAVA_HOME" \ && export PATH="$JAVA_HOME:$PATH" # -- bitcoind --------------------------------------------------------- @@ -42,6 +41,10 @@ RUN cd /tmp \ && rm -v /opt/bitcoin/bin/test_bitcoin /opt/bitcoin/bin/bitcoin-qt \ && ln -sv /opt/bitcoin/bin/* /usr/local/bin +# -- Create a non-root user and group -- +RUN groupadd -r rituser && useradd -r -g rituser -d /usr/src/ rituser +RUN mkdir -p /usr/src/ && chown -R rituser:rituser /usr/src/ + # -- configure entrypoint to run RIT-------------------------------------------- RUN mkdir -p /usr/src/logbacks @@ -54,11 +57,14 @@ COPY rit-local-configs/logbacks/* /usr/src/logbacks/ COPY scripts/* /usr/src/ RUN chmod +x /usr/src/entrypoint.sh \ - && chmod +x /usr/src/configure_gradle_federator.sh \ + && chmod +x /usr/src/configure_gradle_powpeg.sh \ && chmod +x /usr/src/configure_rit_locally.sh \ && mkdir -p /usr/src/bitcoindata \ && chmod -R 755 /usr/src/bitcoindata \ - && ls -la /usr/src + && chown -R rituser:rituser /usr/src/ + +# -- Switch to non-root user -- +USER rituser ENTRYPOINT ["/usr/src/entrypoint.sh"] diff --git a/.github/images/entrypoint.sh b/.github/images/entrypoint.sh index 13a1ab51..c01d12c2 100644 --- a/.github/images/entrypoint.sh +++ b/.github/images/entrypoint.sh @@ -12,11 +12,11 @@ chmod +x ./configure.sh && chmod +x gradlew 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 "${INPUT_FEDERATOR_BRANCH}" +cp configure_gradle_powpeg.sh powpeg +cd powpeg && git checkout "${INPUT_POWPEG_NODE_BRANCH}" chmod +x ./configure.sh && chmod +x gradlew -FED_VERSION=$(bash configure_gradle_federator.sh) -echo "FED_VERSION=$FED_VERSION" +POWPEG_VERSION=$(bash configure_gradle_powpeg.sh) +echo "POWPEG_VERSION=$POWPEG_VERSION" ./configure.sh ./gradlew --info --no-daemon clean build -x test @@ -30,7 +30,7 @@ cd rit git checkout "${INPUT_RIT_BRANCH}" chmod +x ./configure.sh ./configure.sh -./configure_rit_locally.sh "${FED_VERSION}" +./configure_rit_locally.sh "${POWPEG_VERSION}" export LOG_LEVEL="${INPUT_RIT_LOG_LEVEL}" echo -e "\n\n--------- Executing Rootstock Integration Tests ---------\n\n" @@ -48,3 +48,8 @@ echo -e "$MESSAGE" echo "status=${STATUS}" >>"${GITHUB_OUTPUT}" echo "message=${MESSAGE}" >>"${GITHUB_OUTPUT}" + +if [ $STATUS -ne 0 ]; then + exit 1 +fi +exit 0 \ No newline at end of file diff --git a/.github/images/scripts/configure_gradle_federator.sh b/.github/images/scripts/configure_gradle_powpeg.sh similarity index 99% rename from .github/images/scripts/configure_gradle_federator.sh rename to .github/images/scripts/configure_gradle_powpeg.sh index 0c7d3925..1baac99f 100755 --- a/.github/images/scripts/configure_gradle_federator.sh +++ b/.github/images/scripts/configure_gradle_powpeg.sh @@ -37,7 +37,6 @@ done < "src/main/resources/version.properties" # Concatenate modifier and versionNumber FED_VERSION="$modifier-$versionNumber" echo "$FED_VERSION" - if [[ $FED_VERSION == SNAPSHOT* || $FED_VERSION == RC* ]]; then echo -e "$SETTINGS_GRADLE_CONTENT_LOCAL" > DONT-COMMIT-settings.gradle -fi +fi \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a33b8066..9a6e7f72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: run: | docker run \ --env RSKJ_BRANCH="master" \ - --env FEDERATOR_BRANCH="master" \ + --env POWPEG_NODE_BRANCH="master" \ --env "GITHUB_OUTPUT=/github-output" \ -v "$GITHUB_OUTPUT:/github-output" \ --rm ${{ env.TEST_TAG }} diff --git a/.gitignore b/.gitignore index 14024e55..af2e55a2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ config/*.js **/*.bip39 logs .env -.DS_Store \ No newline at end of file +.DS_Store +.idea/ \ No newline at end of file