Skip to content

Commit

Permalink
Fixing some issues on RIT workflow
Browse files Browse the repository at this point in the history
Issues fixed:
1 - Remove the trigger on push for master  and *-rc -> we don't need that
anymore since we are running it for every commit on PRs against these branches.

2 - Solve the issue that the status of an execution triggered via workflow doesn't update the PR status.
 And if we need to use a different branch for RIT, Powpeg and RIT in the PR, it won't change the status to
 green after the workflow_dispatch execution -> We will do that adding a parsing on the description, looking
 for the branch that need to be used for that PR. If there is no branch configured on the description, we will
 try to use the default one.
  • Loading branch information
fmacleal committed Sep 12, 2024
1 parent a1e21dc commit e0a6a2e
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/rit.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Rootstock Integration Tests

on:
push:
branches: ["master", "*-rc"]
pull_request:
types: [ opened, synchronize, reopened ]
branches: ["master", "*-rc"]
Expand All @@ -17,27 +15,57 @@ on:
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@v6
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
return pr.data.body;
result-encoding: string
- name: PR description fetch
run: echo '${{ steps.fetch-pr-description.outputs.result }}'

- name: Set Branch Variables
id: set-branch-variables
run: |
# Default values
RSKJ_BRANCH="master"
RIT_BRANCH="${{ github.event.inputs.rit-branch || 'main' }}"
POWPEG_BRANCH="${{ github.event.inputs.powpeg-branch || 'master' }}"
# 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 }}"
# Set the Powpeg branch
if [[ -n "${{ github.event.inputs.powpeg-branch }}" ]]; then
POWPEG_BRANCH="${{ github.event.inputs.powpeg-branch }}"
elif [[ -n "$PR_DESCRIPTION" && "$PR_DESCRIPTION" =~ fed:${{ env.REGEX_PARSE_BRANCH }} ]]; then
POWPEG_BRANCH="${BASH_REMATCH[1]}"
else
POWPEG_BRANCH="master"
fi
echo "RSKJ_BRANCH=$RSKJ_BRANCH" >> $GITHUB_ENV
echo "RIT_BRANCH=$RIT_BRANCH" >> $GITHUB_ENV
Expand Down

0 comments on commit e0a6a2e

Please sign in to comment.