diff --git a/.github/action.yml b/.github/action.yml new file mode 100644 index 00000000..8c093f38 --- /dev/null +++ b/.github/action.yml @@ -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 }} \ No newline at end of file diff --git a/.github/images/entrypoint.sh b/.github/images/entrypoint.sh index 21753661..a0a4c11e 100644 --- a/.github/images/entrypoint.sh +++ b/.github/images/entrypoint.sh @@ -2,10 +2,6 @@ set -e -RSKJ_BRANCH="master" -POWPEG_BRANCH="master" - - echo -e "\n\n--------- Starting the configuration of rskj ---------\n\n" git clone https://github.com/rsksmart/rskj.git rskj @@ -18,7 +14,7 @@ cd .. echo -e "\n\n--------- Starting the configuration of powpeg ---------\n\n" 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 $FEDERATOR_BRANCH chmod +x ./configure.sh && chmod +x gradlew ./configure_gradle_federator.sh ./configure.sh @@ -31,9 +27,11 @@ 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 $RIT_BRANCH chmod +x ./configure.sh ./configure.sh ./configure_rit_locally.sh "$FED_VERSION" +export LOG_LEVEL=$RIT_LOG_LEVEL echo -e "\n\n--------- Executing Rootstock Integration Tests ---------\n\n" npm install -y diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..9fc0b521 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: Continuous Integration Tests + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + test-rit-docker: + name: Test Rootstock Integration Tests docker image + runs-on: ubuntu-latest + + services: + registry: + image: registry:2 + ports: + - 5001:5000 + + env: + TEST_TAG: localhost:5001/actions/container-action:latest + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Setup Docker BuildX + id: setup-buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + driver-opts: network=host + platforms: linux/amd64,linux/arm64 + + + - name: Build the RIT Container + id: build + uses: docker/build-push-action@v6 + with: + context: .github/images + push: true + tags: ${{ env.TEST_TAG }} + + - name: Run the RIT Container + id: run + env: + RSKJ_BRANCH: 'master' + FEDERATOR_BRANCH: 'master' + run: | + docker run \ + --env RSKJ_BRANCH="${{ env.RSKJ_BRANCH }}" \ + --env FEDERATOR_BRANCH="${{ env.FEDERATOR_BRANCH }}" \ + --rm ${{ env.TEST_TAG }} \ No newline at end of file