Rootstock Integration Tests #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
jobs: | |
rootstock-integration-tests: | |
name: Rootstock Integration Tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
repository: ${{ github.repository }} # Use the forked repository | |
ref: ${{ github.head_ref }} | |
fetch-depth: 0 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Branch Variables | |
id: set-branch-variables | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
github_event_input_powpeg_branch: ${{ github.event.inputs.powpeg-branch }} | |
github_event_input_rit_branch: ${{ github.event.inputs.rit-branch }} | |
github_event_name: ${{ github.event_name }} | |
github_event_pull_request_number: ${{ github.event.pull_request.number }} | |
github_head_ref: ${{ github.head_ref }} | |
run: | | |
PR_DESCRIPTION=pr-description.txt | |
ALLOWED_BRANCH_CHARACTERS='[-./0-9A-Z_a-z]' | |
default_rskj_branch=master | |
default_powpeg_branch=master | |
default_rit_branch=main | |
get_branch_from_description() { | |
_prefix=$1 | |
_search_re='\@`'$_prefix:$ALLOWED_BRANCH_CHARACTERS'\{1,\}`@' | |
_replace_re='s@.*`'$_prefix:'\('$ALLOWED_BRANCH_CHARACTERS'\{1,\}\)`.*@\1@p' | |
_branch=$(sed -n "$_search_re $_replace_re" "$PR_DESCRIPTION") | |
echo "$_branch" | |
} | |
is_valid_branch_name() { | |
echo "$1" | grep -qx "$ALLOWED_BRANCH_CHARACTERS\\{1,\\}" | |
} | |
if [ "$github_event_name" = workflow_dispatch ]; then | |
RSKJ_BRANCH=$github_head_ref | |
POWPEG_BRANCH=${github_event_input_powpeg_branch:-$default_powpeg_branch} | |
RIT_BRANCH=${github_event_input_rit_branch:-$default_rit_branch} | |
elif [ "$github_event_name" = pull_request ]; then | |
gh pr view "$github_event_pull_request_number" --json body -q .body >"$PR_DESCRIPTION" | |
RSKJ_BRANCH=$(get_branch_from_description rskj) | |
: ${RSKJ_BRANCH:=${github_head_ref:-$default_rskj_branch}} | |
POWPEG_BRANCH=$(get_branch_from_description fed) | |
: ${POWPEG_BRANCH:=$default_powpeg_branch} | |
RIT_BRANCH=$(get_branch_from_description rit) | |
: ${RIT_BRANCH:=$default_rit_branch} | |
else | |
RSKJ_BRANCH=$default_rskj_branch | |
POWPEG_BRANCH=$default_powpeg_branch | |
RIT_BRANCH=$default_rit_branch | |
fi | |
if ! is_valid_branch_name "$RSKJ_BRANCH"; then | |
echo "rskj: invalid branch name: $RSKJ_BRANCH" >&2 | |
exit 1 | |
fi | |
if ! is_valid_branch_name "$POWPEG_BRANCH"; then | |
echo "fed: invalid branch name: $POWPEG_BRANCH" >&2 | |
exit 1 | |
fi | |
if ! is_valid_branch_name "$RIT_BRANCH"; then | |
echo "rit: invalid branch name: $RIT_BRANCH" >&2 | |
exit 1 | |
fi | |
echo "RSKJ_BRANCH=$RSKJ_BRANCH" >> $GITHUB_ENV | |
echo "RIT_BRANCH=$RIT_BRANCH" >> $GITHUB_ENV | |
echo "POWPEG_BRANCH=$POWPEG_BRANCH" >> $GITHUB_ENV | |
- name: Set Build URL | |
id: set-build-url | |
run: | | |
BUILD_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
echo "BUILD_URL=$BUILD_URL" >> $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 }} |