From a679f876cc6d0bafb44ebf2d8c051d538311b936 Mon Sep 17 00:00:00 2001 From: Reynold Morel Date: Wed, 28 Aug 2024 15:57:46 -0400 Subject: [PATCH] Adding Rootstock Integration Tests workflow --- .github/workflows/rit.yml | 83 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/rit.yml diff --git a/.github/workflows/rit.yml b/.github/workflows/rit.yml new file mode 100644 index 00000000000..153bba7116c --- /dev/null +++ b/.github/workflows/rit.yml @@ -0,0 +1,83 @@ +name: Rootstock Integration Tests + +on: + push: + branches: + - "master" + - "*-rc" + pull_request: + types: [opened, reopened, synchronize] + branches: + - "**" + issue_comment: + types: + - created + - edited + +jobs: + rootstock-integration-tests: + name: Rootstock Integration Tests + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Checkout rskj Repository + if: github.event_name == 'pull_request' + uses: actions/checkout@v3 + with: + repository: rsksmart/rskj + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 1 + + - name: Get PR Description + if: github.event_name == 'pull_request' + id: get-pr-description + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + PR_DESC=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER") + + echo "PR Description: $PR_DESC" + + rskj_branch=$(echo "$PR_DESC" | grep -Po '(?<=RSKj Branch: rskj:)\w+' || echo "master") + fed_branch=$(echo "$PR_DESC" | grep -Po '(?<=PowPeg Node Branch: fed:)\w+' || echo "master") + rit_branch=$(echo "$PR_DESC" | grep -Po '(?<=Rootstock Integration Tests Branch: rit:)\w+' || echo "main") + + echo "RSKJ_BRANCH=$rskj_branch" >> $GITHUB_ENV + echo "FED_BRANCH=$fed_branch" >> $GITHUB_ENV + echo "RIT_BRANCH=$rit_branch" >> $GITHUB_ENV + + echo "{\"rskj_branch\": \"$rskj_branch\", \"fed_branch\": \"$fed_branch\", \"rit_branch\": \"$rit_branch\"}" > debug-values.json + + - name: Test jq Installation + run: | + echo '{"key":"value"}' | jq '.key' + cat debug-values.json + echo "RSKJ Branch: $(jq -r '.rskj_branch' debug-values.json)" + echo "FED Branch: $(jq -r '.fed_branch' debug-values.json)" + echo "RIT Branch: $(jq -r '.rit_branch' debug-values.json)" + + - name: Checkout Rootstock Integration Tests Repository + uses: actions/checkout@v4 + with: + repository: rsksmart/rootstock-integration-tests + ref: ${{ env.RIT_BRANCH }} + fetch-depth: 0 + + - name: Check Comment Condition + run: | + echo "Evaluating condition..." + if [[ "${{ github.event_name }}" == "issue_comment" && "${{ github.event.comment.body }}" == *"/pipeline:run"* ]]; then + echo "Condition met: Pipeline run command detected in comment." + else + echo "Condition not met: Comment body is '${{ github.event.comment.body }}'" + fi + + - name: Run Rootstock Integration Tests + if: github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/pipeline:run')) + uses: rsksmart/rootstock-integration-tests@v1 + with: + rskj-branch: ${{ env.RSKJ_BRANCH }} + powpeg-node-branch: ${{ env.FED_BRANCH }} + + - name: Notify on Status + run: echo "Rootstock Integration Tests pipeline triggered"