Skip to content

Fixing some issues on RIT workflow #83

Fixing some issues on RIT workflow

Fixing some issues on RIT workflow #83

Workflow file for this run

name: Rootstock Integration Tests
on:
pull_request:
types: [ opened, synchronize, reopened ]
branches: ["master", "*-rc"]
workflow_dispatch:
inputs:
rit-branch:
description: 'Branch for Rootstock Integration Tests'
required: false
default: 'main'
powpeg-branch:
description: 'Branch for PowPeg Node'
required: false
default: 'master'
env:
REGEX_PARSE_BRANCH: '([a-zA-Z0-9/_-]+)'
jobs:
rootstock-integration-tests:
name: Rootstock Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Fetch Pull Request Description
id: fetch-pr-description
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
// Simplified function to remove Markdown tags
function removeMarkdown(text) {
return text
.replace(/!\[.*?\]\(.*?\)/g, '') // Remove images
.replace(/\[.*?\]\(.*?\)/g, '') // Remove links
.replace(/`.*?`/g, '') // Remove inline code
.replace(/```[\s\S]*?```/g, '') // Remove code blocks
.replace(/#+\s/g, '') // Remove headers
.replace(/>\s/g, '') // Remove blockquotes
.replace(/[*_~]/g, '') // Remove emphasis
.replace(/-\s/g, '') // Remove list items
.replace(/\[ \]|\[x\]/gi, '') // Remove checkboxes
.replace(/<!--[\s\S]*?-->/g, '') // Remove comments
.replace(/\n{2,}/g, '\n'); // Remove extra newlines
}
const cleanedBody = removeMarkdown(pr.data.body);
return cleanedBody;
- name: PR description fetch
run: |
PR_DESCRIPTION="${{ steps.fetch-pr-description.outputs.result }}"
if [[ "$PR_DESCRIPTION" =~ fed:([a-zA-Z0-9\/_-]+) ]]; then
echo "Found PR description"
POWPEG_BRANCH="${BASH_REMATCH[1]}"
else
echo "Default branch master"
POWPEG_BRANCH="master"
fi
echo "PR_DESCRIPTION=PR_DESCRIPTION"
- name: Set Branch Variables
id: set-branch-variables
run: |
# Default values
RSKJ_BRANCH="master"
RIT_BRANCH="${{ github.event.inputs.rit-branch || 'main' }}"
# Set the RSKJ branch
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/*-rc" ]]; then
RSKJ_BRANCH="${{ github.ref }}"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
RSKJ_BRANCH="${{ github.ref_name }}"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
RSKJ_BRANCH="${{ github.head_ref }}"
fi
PR_DESCRIPTION="${{ steps.fetch-pr-description.outputs.result }}"
echo "PR_DESCRIPTION set"
# Set the Powpeg branch
if [[ -n "${{ github.event.inputs.powpeg-branch }}" ]]; then
POWPEG_BRANCH="${{ github.event.inputs.powpeg-branch }}"
elif [[ "${{ steps.fetch-pr-description.outputs.result }}" =~ fed:([a-zA-Z0-9/_-]+) ]]; then
echo "Found PR description"
POWPEG_BRANCH="${BASH_REMATCH[1]}"
else
echo "Default branch master"
POWPEG_BRANCH="master"
fi
echo "RSKJ_BRANCH=$RSKJ_BRANCH" >> $GITHUB_ENV
echo "RIT_BRANCH=$RIT_BRANCH" >> $GITHUB_ENV
echo "POWPEG_BRANCH=$POWPEG_BRANCH" >> $GITHUB_ENV
- name: Run Rootstock Integration Tests
uses: rsksmart/rootstock-integration-tests@497172fd38dcfaf48c77f9bb1eeb6617eef5eed6 #v1
with:
rskj-branch: ${{ env.RSKJ_BRANCH }}
powpeg-node-branch: ${{ env.POWPEG_BRANCH }}
rit-branch: ${{ env.RIT_BRANCH }}