-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/media-info' of github.com:rdkcentral/firebolt-a…
…pis into feature/media-info
- Loading branch information
Showing
76 changed files
with
10,990 additions
and
103 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Attempt to merge next to main | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# Check if next can merge into main | ||
perform_merge: | ||
name: Perform merge if "next" can merge into "main" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} | ||
persist-credentials: true | ||
|
||
# Set user identity | ||
- name: Set-Identity | ||
run: | | ||
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}" | ||
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}" | ||
# Checkout "main" | ||
- name: Checkout main | ||
run: git checkout "main" | ||
|
||
- name: Perform the merge from next to main | ||
run: | | ||
git merge next | ||
git push origin "main" | ||
echo "Push to main succeeded" | ||
# If the merge cannot be performed, let stakeholders know | ||
message_on_failure: | ||
name: Merge failure | ||
needs: perform_merge | ||
runs-on: ubuntu-latest | ||
if: ${{ failure() }} | ||
|
||
steps: | ||
- name: Post error message (To-Do) | ||
run: echo "Next cannot be merged into main cleanly" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Attempt to merge next to next-major | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'next' | ||
|
||
jobs: | ||
# Check if next can merge into next-major | ||
perform_merge: | ||
name: Perform merge if "next" can merge into "next-major" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} | ||
persist-credentials: true | ||
|
||
# Set user identity | ||
- name: Set-Identity | ||
run: | | ||
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}" | ||
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}" | ||
# Checkout "next-major" | ||
- name: Checkout next-major | ||
run: git checkout "next-major" | ||
|
||
# Get the "next-major" version number | ||
- name: Extract next-major version | ||
id: extract_version | ||
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')" | ||
|
||
# Checkout "next" | ||
- name: Checkout next | ||
run: git checkout "next" | ||
|
||
# Update "next" version to match "next-major" | ||
- name: Update "next" version to match "next-major" | ||
run: | | ||
jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json | ||
if diff -q "package.json" "temp.json" >/dev/null; then | ||
echo "Versions are identical. No change required." | ||
rm temp.json | ||
else | ||
mv temp.json package.json | ||
git add package.json && git commit -m "Sync version to ${{ steps.extract_version.outputs.version }}" | ||
fi | ||
# Checkout "next-major" | ||
- name: Checkout next-major | ||
run: git checkout "next-major" | ||
|
||
- name: Perform the merge from next to next-major | ||
run: | | ||
git merge next | ||
git push origin "next-major" | ||
echo "Push to next-major succeeded" | ||
# If the merge cannot be performed, let stakeholders know | ||
message_on_failure: | ||
name: Merge failure | ||
needs: perform_merge | ||
runs-on: ubuntu-latest | ||
if: ${{ failure() }} | ||
|
||
steps: | ||
- name: Post error message (To-Do) | ||
run: echo "Next cannot be merged into next-major cleanly" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Comment Artifact URL on PR | ||
|
||
on: | ||
workflow_run: | ||
types: | ||
- "completed" | ||
workflows: | ||
- "Core SDK - MFOS standalone sanity report" | ||
|
||
jobs: | ||
comment-on-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get Artifact And Job Data | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
SERVER_URL: ${{ github.server_url }} | ||
GITHUB_REPO: ${{ github.repository }} | ||
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }} | ||
run: | | ||
./.github/workflows/utils.sh getArtifactData | ||
- name: Download an artifact | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { downloadArtifact } = require('./.github/workflows/utils.cjs'); | ||
downloadArtifact(process.env.ARTIFACT_ID,process.env.JOB_PATH,process.env.PR_NUMBER,context,github); | ||
- name: Unzip an artifact | ||
run: | | ||
./.github/workflows/utils.sh unzipArtifact | ||
- name: Post a Comment | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { createComment } = require('./.github/workflows/utils.cjs'); | ||
createComment(github, context); | ||
env: | ||
issue_number: ${{ env.PR_NUMBER }} | ||
Passes: ${{ env.Passes }} | ||
Failures: ${{ env.Failures }} | ||
Pending: ${{ env.Pending }} | ||
Skipped: ${{ env.Skipped }} | ||
ARTIFACT_URL: ${{ env.ARTIFACT_URL }} | ||
JOB_PATH: ${{ env.JOB_PATH }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,20 @@ on: | |
- 'main' | ||
- 'next' | ||
- 'next-major' | ||
- 'proposed' | ||
pull_request: | ||
types: [opened, synchronize] | ||
branches: | ||
- 'next' | ||
- 'proposed' | ||
env: | ||
HUSKY: 0 | ||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout/install project | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
|
@@ -29,68 +36,88 @@ jobs: | |
run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc' | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Set explicit npm dist-tag default | ||
if: github.ref_name == 'main' | ||
|
||
# Set NPM_DIST_TAGS and DOCS_TAG if applicable based on branch | ||
- name: Set main tags | ||
if: github.ref_name == 'main' && github.event_name != 'pull_request' | ||
run: | | ||
echo "NPM_DIST_TAG=latest" >> $GITHUB_ENV | ||
echo "RELEASE_CHANNEL=latest" >> $GITHUB_ENV | ||
- name: Override npm dist-tag for non-main releases | ||
if: github.ref_name != 'main' | ||
echo "DOCS_TAG=latest" >> $GITHUB_ENV | ||
- name: Set next tags | ||
if: github.ref_name == 'next' && github.event_name != 'pull_request' | ||
run: | | ||
echo "NPM_DIST_TAG=next" >> $GITHUB_ENV | ||
echo "DOCS_TAG=next" >> $GITHUB_ENV | ||
- name: Set next-major tags | ||
if: github.ref_name == 'next-major' && github.event_name != 'pull_request' | ||
run: | | ||
echo "NPM_DIST_TAG=next-major" >> $GITHUB_ENV | ||
echo "DOCS_TAGE=next-major" >> $GITHUB_ENV | ||
- name: Set feature branch tags | ||
if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' && github.event_name != 'pull_request' | ||
run: | | ||
echo "Setting NPM_DIST_TAG to '${{ github.ref_name }}'" | ||
echo "NPM_DIST_TAG=${{ github.ref_name }}" >> $GITHUB_ENV | ||
- name: Override release channel for non-main releases | ||
if: github.ref_name != 'main' | ||
echo "NPM_DIST_TAG=test" >> $GITHUB_ENV | ||
echo "FEATURE_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV | ||
- name: Set PR tags | ||
if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' && github.event_name == 'pull_request' | ||
run: | | ||
echo "Setting RELEASE_CHANNEL to '$(node ./src/js/version.mjs channel $NPM_DIST_TAG)' using branch name '$NPM_DIST_TAG'" | ||
echo "RELEASE_CHANNEL=$(node ./src/js/version.mjs channel $NPM_DIST_TAG)" >> $GITHUB_ENV | ||
echo "NPM_DIST_TAG=test" >> $GITHUB_ENV | ||
echo "DOCS_TAG=pr-$(node ./src/js/version.mjs branch-to-prerelease ${{ github.head_ref }})" >> $GITHUB_ENV | ||
echo "FEATURE_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV | ||
# Perform real (When not a PR) or dry-run (When PR) semantic-release | ||
- name: Release mono-artifact to GitHub | ||
if: github.ref_name != 'main' || github.event_name == 'workflow_dispatch' | ||
if: (github.ref_name != 'main' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | ||
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config. | ||
run: npx semantic-release | ||
- name: Dry-run mono-artifact | ||
if: github.ref_name == 'main' && github.event_name != 'workflow_dispatch' | ||
if: (github.ref_name == 'main' && github.event_name != 'workflow_dispatch') || github.event_name == 'pull_request' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | ||
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config. | ||
run: npx semantic-release --dry-run | ||
- name: Build artifacts for feature branches | ||
if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' | ||
run: | | ||
PRERELEASE=$(node ./src/js/version.mjs branch-to-prerelease $FEATURE_BRANCH) | ||
node ./src/js/version.mjs latest-prerelease $PRERELEASE | ||
npm version prerelease --preid $PRERELEASE --git-tag-version false | ||
npm version prerelease --preid $PRERELEASE --workspaces --git-tag-version false | ||
npm run dist | ||
- name: Check if semantic-release created a build | ||
id: check_build | ||
uses: andstor/file-existence-action@v2 | ||
with: | ||
files: "./src/sdks/core/dist/lib/firebolt.mjs" | ||
files: './src/sdks/core/dist/lib/firebolt.mjs' | ||
- name: Release Firebolt SDKs to NPM | ||
if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name != 'main' || github.event_name == 'workflow_dispatch') | ||
if: steps.check_build.outputs.files_exists == 'true' && github.event_name != 'pull_request' && (github.ref_name != 'main' || github.event_name == 'workflow_dispatch') | ||
env: | ||
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth. | ||
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config. | ||
run: npm publish --tag $RELEASE_CHANNEL --workspaces | ||
run: | | ||
npm --version | ||
echo "NPM DIST TAG :: " $NPM_DIST_TAG | ||
npm publish --tag $NPM_DIST_TAG --workspaces | ||
- name: Dry-run Firebolt SDKs to NPM | ||
if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name == 'main' && github.event_name != 'workflow_dispatch') | ||
env: | ||
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth. | ||
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config. | ||
run: npm publish --tag $RELEASE_CHANNEL --workspaces --dry-run | ||
run: npm publish --tag $NPM_DIST_TAG --workspaces --dry-run | ||
- name: Checkout firebolt GitHub.io repository | ||
if: steps.check_build.outputs.files_exists == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | ||
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config. | ||
run: | | ||
cd /tmp | ||
git clone https://rdkcentral:[email protected]/rdkcentral/firebolt.git ./firebolt-docs | ||
- name: Release docs to GitHub.io | ||
if: steps.check_build.outputs.files_exists == 'true' | ||
if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name == 'main' || github.ref_name == 'next' || github.ref_name == 'next-major' || github.event_name == 'pull_request') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | ||
npm_config_tag: ${{ env.NPM_DIST_TAG }} # <-- For main, this is `latest.` Otherwise, `next`, `next-major`, etc. See ./.releaserc for release branch config. | ||
run: | | ||
npm run publish:docs /tmp/firebolt-docs | ||
npm run publish:docs /tmp/firebolt-docs $DOCS_TAG | ||
cd /tmp/firebolt-docs | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Your Name" | ||
git add --all | ||
git commit -m "chore: Publish $RELEASE_CHANNEL" | ||
git diff-index --quiet HEAD || git commit -m "chore: Publish $DOCS_TAG" | ||
git push |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Core SDK - MFOS standalone sanity report | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
branches: [ next ] | ||
|
||
jobs: | ||
RunStandaloneTests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run tests and create assets | ||
env: | ||
EVENT_NAME: ${{ github.event_name }} | ||
GITHUB_REF: ${{ github.ref }} | ||
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} | ||
INTENT: ${{ secrets.INTENT }} | ||
run: | | ||
./.github/workflows/utils.sh runTests | ||
- name: Upload report.json as an artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: report | ||
path: ${{ github.workspace }}/report | ||
|
||
- name: Get results from report.json | ||
run: | | ||
./.github/workflows/utils.sh getResults |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
async function downloadArtifact(ARTIFACT_ID, JOB_PATH, PR_NUMBER, context, github) { | ||
if (!ARTIFACT_ID) { | ||
console.log("Send the comment to PR and exit the job"); | ||
// Create a comment | ||
const comment = `Failed to create a report:\n Job logs: ${JOB_PATH}`; | ||
|
||
// Post the comment to the pull request | ||
let prcomment = await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: PR_NUMBER, | ||
body: comment, | ||
}); | ||
|
||
process.exit(1); | ||
} else { | ||
// Download report.json | ||
let download = await github.rest.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: ARTIFACT_ID, | ||
archive_format: 'zip', | ||
}); | ||
|
||
let fs = require('fs'); | ||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/report.zip`, Buffer.from(download.data)); | ||
|
||
console.log("Artifact downloaded successfully."); | ||
} | ||
} | ||
|
||
async function createComment(github, context) { | ||
const { issue_number, Passes, Failures, Pending, Skipped, ARTIFACT_URL, JOB_PATH } = process.env; | ||
|
||
const body = ` | ||
Core SDK - MFOS standalone sanity report: | ||
Passes - ${Passes} Failures - ${Failures} Pending - ${Pending} Skipped - ${Skipped} | ||
Report JSON/HTML Files: ${ARTIFACT_URL} | ||
Job Logs: ${JOB_PATH} | ||
`; | ||
|
||
const response = await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue_number, | ||
body: body.trim() | ||
}); | ||
|
||
console.log('Comment updated successfully.'); | ||
} | ||
|
||
module.exports = { downloadArtifact, createComment }; |
Oops, something went wrong.