Skip to content

Commit

Permalink
Applying some other suggestions from review
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
fmacleal committed Jul 17, 2024
1 parent 7a8403c commit abd3f5d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 14 deletions.
47 changes: 47 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -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
```
16 changes: 11 additions & 5 deletions .github/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------------
Expand All @@ -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
Expand All @@ -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"]

Expand Down
15 changes: 10 additions & 5 deletions .github/images/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ config/*.js
**/*.bip39
logs
.env
.DS_Store
.DS_Store
.idea/

0 comments on commit abd3f5d

Please sign in to comment.