Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added a new job to trigger Firebolt api workflow #226

Merged
merged 48 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
129abb5
fix: Added a new job to trigger Firebolt api workflow
kdivya153 Oct 10, 2024
abe639d
Update check-pr.yml
kdivya153 Oct 10, 2024
208be47
Update check-pr.yml
kdivya153 Oct 12, 2024
14b7826
Update check-pr.yml
kdivya153 Oct 12, 2024
6c053dd
Update check-pr.yml
kdivya153 Oct 12, 2024
2393f27
Update check-pr.yml
kdivya153 Oct 12, 2024
2ab644d
Update check-pr.yml
kdivya153 Oct 13, 2024
ba0f2ca
Update check-pr.yml
kdivya153 Oct 13, 2024
e159c43
Update check-pr.yml
kdivya153 Oct 13, 2024
b056178
Update check-pr.yml
kdivya153 Oct 16, 2024
05f16b2
Update check-pr.yml
kdivya153 Oct 16, 2024
f53a930
Update check-pr.yml
kdivya153 Oct 21, 2024
9667c9b
Update check-pr.yml
kdivya153 Oct 21, 2024
37272bf
Update check-pr.yml
kdivya153 Oct 21, 2024
4736893
Update check-pr.yml
kdivya153 Oct 21, 2024
f658420
Update check-pr.yml
kdivya153 Oct 21, 2024
9cb3c3c
Update check-pr.yml
kdivya153 Oct 21, 2024
98755f3
Update check-pr.yml
kdivya153 Oct 21, 2024
6623fcc
Update check-pr.yml
kdivya153 Oct 21, 2024
65ee344
Update check-pr.yml
kdivya153 Oct 21, 2024
87b46ae
Merge branch 'next' into FIRESDK-142
kdivya153 Oct 21, 2024
c3eda37
Update check-pr.yml
kdivya153 Oct 21, 2024
2b91add
Update check-pr.yml
kdivya153 Oct 21, 2024
1300b30
Update check-pr.yml
kdivya153 Oct 21, 2024
c805064
Update check-pr.yml
kdivya153 Oct 21, 2024
2ad4c03
Delete slack.yml
kdivya153 Oct 22, 2024
bddb232
Added ReadMe
kdivya153 Oct 22, 2024
0528ff4
updated ReadMe
kdivya153 Oct 22, 2024
7e371ba
Update check-pr.yml
kdivya153 Oct 28, 2024
1aab2c5
Update check-pr.yml
kdivya153 Oct 28, 2024
e8451e0
Update check-pr.yml
kdivya153 Oct 28, 2024
0e097b6
Update check-pr.yml
kdivya153 Oct 29, 2024
4c47741
Merge branch 'next' into FIRESDK-142
kdivya153 Oct 29, 2024
92c5402
Update check-pr.yml
kdivya153 Oct 29, 2024
bddb69b
Update check-pr.yml
kdivya153 Oct 29, 2024
b34101b
Update check-pr.yml
kdivya153 Oct 29, 2024
ca5363f
Update check-pr.yml
kdivya153 Oct 29, 2024
76e95c4
Update check-pr.yml
kdivya153 Oct 29, 2024
77a9852
Update check-pr.yml
kdivya153 Oct 29, 2024
53de12d
Update check-pr.yml
kdivya153 Oct 29, 2024
83fd4d8
Update check-pr.yml
kdivya153 Oct 29, 2024
ca30764
Update check-pr.yml
kdivya153 Oct 29, 2024
bff01be
Update check-pr.yml
kdivya153 Oct 29, 2024
052218a
Update README.md
kdivya153 Oct 29, 2024
8bfc6f5
Update check-pr.yml
kdivya153 Oct 29, 2024
8a89b2e
Update check-pr.yml
kdivya153 Oct 29, 2024
4a07375
Update check-pr.yml
kdivya153 Oct 29, 2024
d2924ef
Update check-pr.yml
kdivya153 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 186 additions & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ on:
- 'opened'
- 'reopened'
- 'synchronize'
push:
branches:
- next
env:
HUSKY: 0
jobs:
release:
name: Run npm pack
name: Trigger Workflows
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -26,3 +29,185 @@ jobs:
run: npm ci
- name: Run validation and tests
run: npm pack

- name: Trigger Workflows
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.WORKFLOW_TRIGGER_SECRET }}
repository: rdkcentral/firebolt-apis
event-type: trigger-workflow
client-payload: '{"OPENRPC_PR_BRANCH": "${{ github.event.pull_request.head.ref }}"}'

- name: Wait for Triggered Workflow to Initialize
run: |
echo "Waiting for the workflow to initialize..."
sleep 40

- name: Get JS Workflow Run ID
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
WORKFLOW_NAME="MFOS standalone sanity report - CORE,MANAGE,DISCOVERY"
MAX_RETRIES=20
SLEEP_TIME=15 # seconds

for ((i=0; i<MAX_RETRIES; i++)); do
# Fetch workflows
response=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows")

# Capture workflow ID
js_workflow_id=$(echo "$response" | jq --arg WORKFLOW_NAME "$WORKFLOW_NAME" '.workflows[] | select(.name == $WORKFLOW_NAME).id')

# Capture the specific run ID for the workflow
js_run_id=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$js_workflow_id/runs?per_page=1" | \
jq -r '.workflow_runs[0].id')


echo "JavaScript Workflow Run ID: $js_run_id"

if [ "$js_run_id" != "null" ]; then
echo "JS_RUN_ID=$js_run_id" >> $GITHUB_ENV
break
else
echo "Waiting for JavaScript workflow to start..."
sleep $SLEEP_TIME
fi
done

# Poll until the C++ SDK workflow run is available
- name: Get CPP Workflow Run ID
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
WORKFLOW_NAME="CXX build"
MAX_RETRIES=20
SLEEP_TIME=15 # seconds

for ((i=0; i<MAX_RETRIES; i++)); do
# Fetch workflow ID
cpp_workflow_id=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows" | jq \
--arg WORKFLOW_NAME "$WORKFLOW_NAME" '.workflows[] | select(.name == $WORKFLOW_NAME).id')

# Capture the specific run ID for the workflow
cpp_run_id=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/$cpp_workflow_id/runs?per_page=1" | \
jq -r '.workflow_runs[0].id')

if [ "$cpp_run_id" != "null" ]; then
echo "CPP_RUN_ID=$cpp_run_id" >> $GITHUB_ENV
break
else
echo "Waiting for C++ workflow to start..."
sleep $SLEEP_TIME
fi
done

- name: Poll Firebolt-api for JavaScript SDK generation
id: poll-javascript-sdk
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
RUN_ID="${{ env.JS_RUN_ID }}"
MAX_POLLS=30 # Max polls before timeout
POLL_INTERVAL=50 # In seconds

# Poll the specific run ID for status
for ((i=0; i<MAX_POLLS; i++)); do
run_response=$(curl -s -H "Authorization: token $TOKEN" \
kschrief marked this conversation as resolved.
Show resolved Hide resolved
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")

status=$(echo $run_response | jq -r '.status')
conclusion=$(echo $run_response | jq -r '.conclusion')

if [ "$status" == "completed" ] && [ "$conclusion" == "success" ]; then
echo "JavaScript SDK generated successfully for the OpenRPC changes."
break
elif [ "$status" == "completed" ] && [ "$conclusion" == "failure" ]; then
echo "Failed to generate JavaScript SDK for the OpenRPC changes."
exit 1
else
echo "Still in progress. Checking again in ${POLL_INTERVAL} seconds..."
sleep $POLL_INTERVAL
fi
done

if [ "$i" -eq "$MAX_POLLS" ]; then
echo "Timeout reached while waiting for JavaScript SDK generation."
exit 1
fi

- name: Poll Firebolt-api for CPP SDK generation
id: poll-cpp-sdk
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="rdkcentral"
REPO_NAME="firebolt-apis"
RUN_ID="${{ env.CPP_RUN_ID }}"
MAX_POLLS=30 # Max polls before timeout
POLL_INTERVAL=50 # In seconds


# Poll the specific run ID for status
for ((i=0; i<MAX_POLLS; i++)); do
run_response=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")

status=$(echo $run_response | jq -r '.status')
conclusion=$(echo $run_response | jq -r '.conclusion')

if [ "$status" == "completed" ] && [ "$conclusion" == "success" ]; then
echo "JavaScript SDK generated successfully for the OpenRPC changes."
break
elif [ "$status" == "completed" ] && [ "$conclusion" == "failure" ]; then
echo "Failed to generate JavaScript SDK for the OpenRPC changes."
else
echo "Still in progress. Checking again in ${POLL_INTERVAL} seconds..."
sleep $POLL_INTERVAL
fi
done

if [ "$i" -eq "$MAX_POLLS" ]; then
echo "Timeout reached while waiting for JavaScript SDK generation."
exit 1
fi

- name: Post comments on PR
if: env.JS_SDK_CONCLUSION != 'unknown' || env.CPP_SDK_CONCLUSION != 'unknown' # Only run if at least one SDK ran
run: |
TOKEN="${{ secrets.WORKFLOW_TRIGGER_SECRET }}"
REPO_OWNER="${{ github.repository_owner }}"
REPO_NAME="${{ github.event.repository.name }}"
PR_NUMBER="${{ github.event.pull_request.number }}"

COMMENT_BODY=""

# JavaScript SDK status
if [[ "$JS_SDK_CONCLUSION" == "success" ]]; then
COMMENT_BODY+="JavaScript SDK generation succeeded for the OpenRPC changes.\\n"
elif [[ "$JS_SDK_CONCLUSION" == "failure" ]]; then
COMMENT_BODY+="JavaScript SDK generation failed for the OpenRPC changes.\\n"
fi

# C++ SDK status
if [[ "$CPP_SDK_CONCLUSION" == "success" ]]; then
COMMENT_BODY+="C++ SDK generation succeeded for the OpenRPC changes."
elif [[ "$CPP_SDK_CONCLUSION" == "failure" ]]; then
COMMENT_BODY+="C++ SDK generation failed for the OpenRPC changes."
fi

# Check if comment body is not empty before posting
if [ -n "$COMMENT_BODY" ]; then
curl -s -H "Authorization: token $TOKEN" \
-X POST \
-d "{\"body\": \"$COMMENT_BODY\"}" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments"
else
echo "No SDKs were generated, no comment will be posted."
fi

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,23 @@ They all have the same arguments and are all implemented using shared code for m
## OpenRPC Validation

Indicated by `--task validate`. Reads and validates a corpus of individual OpenRPC documents and validates the result of assembling them together into a single OpenRPC document.

### Pull Request Guidelines for the Firebolt-OpenRPC Repository

When submitting a Pull Request (PR) to the `next` branch of the Firebolt-OpenRPC repository, please adhere to the following process:

1. **Branch Naming Convention**:
- It is **advised** to use the **same branch name** for the PR in Firebolt-OpenRPC if there are changes in the `firebolt-api` repository. This ensures that if the branch names match, the OpenRPC workflow will be triggered again for that branch.
- If the branch names do not match, the OpenRPC PR will be tested against the `next` branch of the `firebolt-api`.

2. **Workflow Triggering**:
- Upon opening the PR in Firebolt-OpenRPC, it will trigger the workflow in Firebolt-APIs to generate the C++ SDK and JavaScript SDK.

4. **JavaScript Validation**:
- If the PR branch causes **Generation** or **Testing** failures for JavaScript, the PR will be **blocked**.

5. **C++ Validation**:
- If the PR branch causes **Generation**, **Testing**, or **Compilation** failures for C++, a **warning** will be added as a comment on the PR in a **visibly striking manner**. However, the PR will **not be blocked**.

Please ensure to follow these guidelines to maintain the integrity of the codebase. For further clarification, refer to the flow diagram [here](images/GithubActions.png).

Binary file added images/GithubActions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading