-
Notifications
You must be signed in to change notification settings - Fork 267
143 lines (127 loc) · 5.29 KB
/
rit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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/_-]+)`'
VALID_BRANCH_REGEX: '^[a-zA-Z0-9._/-]+$'
jobs:
rootstock-integration-tests:
name: Rootstock Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Fetch Pull Request Description
id: fetch-pr-description
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
{
echo 'pr_description<<EOF'
gh pr view ${{ github.event.pull_request.number }} --json body -q .body
echo EOF
} >> "$GITHUB_ENV"
- name: Set Branch Variables
id: set-branch-variables
env:
PR_DESCRIPTION: ${{ env.pr_description }}
run: |
# Default values
RSKJ_BRANCH="master"
# Set the RSKJ branch
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
RSKJ_BRANCH="${{ github.ref_name }}"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "$PR_DESCRIPTION" =~ rskj:${{ env.REGEX_PARSE_BRANCH }} ]]; then
RSKJ_BRANCH="${BASH_REMATCH[1]}"
else
RSKJ_BRANCH="${{ github.head_ref }}"
fi
fi
# Set the Powpeg branch
if [[ -n "${{ github.event.inputs.powpeg-branch }}" ]]; then
POWPEG_BRANCH="${{ github.event.inputs.powpeg-branch }}"
elif [[ "$PR_DESCRIPTION" =~ fed:${{ env.REGEX_PARSE_BRANCH }} ]]; then
POWPEG_BRANCH="${BASH_REMATCH[1]}"
else
POWPEG_BRANCH="master"
fi
# Set the RIT branch
if [[ -n "${{ github.event.inputs.rit-branch }}" ]]; then
RIT_BRANCH="${{ github.event.inputs.rit-branch }}"
elif [[ "$PR_DESCRIPTION" =~ rit:${{ env.REGEX_PARSE_BRANCH }} ]]; then
RIT_BRANCH="${BASH_REMATCH[1]}"
else
RIT_BRANCH="main"
fi
if ! [[ "$RIT_BRANCH" =~ $VALID_BRANCH_REGEX ]]; then
echo "Error: Invalid RIT branch name: $RIT_BRANCH"
exit 1
fi
if ! [[ "$POWPEG_BRANCH" =~ $VALID_BRANCH_REGEX ]]; then
echo "Error: Invalid PowPeg branch name: $POWPEG_BRANCH"
exit 1
fi
if ! [[ "$RSKJ_BRANCH" =~ $VALID_BRANCH_REGEX ]]; then
echo "Error: Invalid RSKJ branch name: $RSKJ_BRANCH"
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 }}
- name: Send Slack Notification on Success
if: success() && github.event.pull_request.head.repo.owner.login == 'rsksmart'
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
channel-id: 'C8X9Q4PBM' # integration-tests channel
payload: |
{
"attachments": [
{
"color": "good",
"text": "OK: :+1: Pull request: ${{ github.head_ref }} - [#${{ github.run_number }}] - (${{ env.BUILD_URL }}) - *Branches used* [rskj:`rsksmart#${{ env.RSKJ_BRANCH }}`] [fed:`${{ env.POWPEG_BRANCH }}`] [rootstock-integration-tests:`${{ env.RIT_BRANCH }}`]"
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.GHA_SLACK_NOTIFICATION_TOKEN }}
- name: Send Slack Notification on Failure
if: failure() && github.event.pull_request.head.repo.owner.login == 'rsksmart'
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
channel-id: 'C8X9Q4PBM' # integration-tests channel
payload: |
{
"attachments": [
{
"color": "danger",
"text": "FAILED: :robot_face: *Pull request*: ${{ github.head_ref }} - [#${{ github.run_number }}] - (${{ env.BUILD_URL }}) - *Branches used* [rskj:`rsksmart#${{ env.RSKJ_BRANCH }}`] [fed:`${{ env.POWPEG_BRANCH }}`] [rootstock-integration-tests:`${{ env.RIT_BRANCH }}`]"
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.GHA_SLACK_NOTIFICATION_TOKEN }}