Skip to content

Commit

Permalink
Merge branch 'next' into fix/documentation-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
kschrief authored Nov 5, 2024
2 parents 9c49c4e + fe137d0 commit 6d620e6
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 4 deletions.
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" \
"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

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [3.2.0-next.6](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.2.0-next.5...v3.2.0-next.6) (2024-11-05)


### Bug Fixes

* Generate full SDKs in CI for tooling changes ([#226](https://github.com/rdkcentral/firebolt-openrpc/issues/226)) ([953f533](https://github.com/rdkcentral/firebolt-openrpc/commit/953f533ad89044c10bd09737205deda89f510fb5))

# [3.2.0-next.5](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.2.0-next.4...v3.2.0-next.5) (2024-10-28)


Expand Down
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.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebolt-js/openrpc",
"version": "3.2.0-next.5",
"version": "3.2.0-next.6",
"description": "The Firebolt SDK Code & Doc Generator",
"main": "languages/javascript/src/sdk.mjs",
"type": "module",
Expand Down

0 comments on commit 6d620e6

Please sign in to comment.