diff --git a/.github/commit_template_validation.py b/.github/commit_template_validation.py new file mode 100755 index 0000000000..26b550b1a2 --- /dev/null +++ b/.github/commit_template_validation.py @@ -0,0 +1,139 @@ +import subprocess +import sys +import argparse +import re + +COMMIT_MESSAGE_FORMAT = ''' +########### ERROR : INVALID COMMIT MESSAGE! ############ +-------------- Please follow the commit message format as below -------------- + +RDKDEV-1234 : Fixes code download failure to set-top via IP download + +Reason for change: Enable capabilities for IPV6 connections . +Test Procedure: Refer ticket +-------------------------------------------------------------------------------- +''' + + +# Execute a command and return the output and error. +# +# Args: +# cmd (str): The command to execute. +# ignore (bool): Whether to ignore the error if the command fails. Default is True. +# cwd (str): The current working directory for the command. Default is None. +# +# Returns: +# tuple: A tuple containing the output (stdout) and error (stderr) of the command. +def executeCmd(cmd, ignore=True, cwd=None): + + proc = subprocess.Popen("%s" % cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, cwd=cwd) + out, err = proc.communicate() + if proc.returncode != 0: + out = proc.returncode + if ignore is False: + raise IOError('Failed to execute: %s, error %s' % (cmd, err)) + err = str('Failed to execute: %s, error %d' % (cmd, proc.returncode)) + return out, err + +# Validate the commits in a project. +# +# Args: +# newrev (str): The new revision. +# +# Returns: +# dict: A dictionary containing the commits and their validation errors. +def validate_commits(newrev, message): + + commits = {} + #commit_message, _ = executeCmd('git log --format=%s -n 1 {0} --no-merges'.format(newrev), ignore=False) + errors = [] + errors += validate_message(message) + if errors: + commits[newrev] = errors + print (COMMIT_MESSAGE_FORMAT) + print('-------------- Commit message in PR is: --------------') + print(message) + print('--------------------------------------------------------------------------------') + + return commits + + +# Validate the commit message has a JIRA ticket reference and is not a revert. +# In addition, the commit message should have : +# 1] Synopsis with a Jira ticket reference in first line +# 2] Title should not exceed 80 characters +# 3] Commit message should not contain new line character +# +# Args: +# message (str): The commit message. +# +# Returns: +# list: A list of validation errors. +def validate_message(message): + errors = [] + JIRA_PROJ_REGEX = r"\s*[A-Z0-9]+-[0-9]+" + + if message.startswith('Revert'): + # Do not validate revert messages. + return errors + + # check if message contains new line character + if '\n' in message: + errors.append('Commit message should not contain new line character') + + if len(message) > 80: + errors.append('Summary line must not exceed 80 characters.') + + if not re.match(JIRA_PROJ_REGEX, message): + errors.append('Summary line must have at least one JIRA ticket reference.') + + return errors + + + + + +# Validate pushed refs. + +# Usage: +# python commit_template_validation.py --newrev --message + +# Arguments: +# --newrev: The sha revision in Pull Request. +# --message: The commit message title of the PR. + +# Returns: +# int: 0 for success, 1 for failure. + +def main(): + + parser = argparse.ArgumentParser(description='Validate pushed refs:', formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument('--newrev', required=True) + parser.add_argument('--message', required=True) + + params = parser.parse_args() + + commits = validate_commits(params.newrev, params.message) + error_messages = set() + commits_sha = set() + + for commit, errors in commits.items(): + commits_sha.add(commit) + for error_message in errors: + error_messages.add(error_message) + + is_invalid = any(error_messages) + if is_invalid: + print('ERRORS:\n - ' + '\n - '.join(error_messages)) + print('COMMIT ID:\n - ' + '\n - '.join(commits_sha)) + + print('\n########################################################') + + return 1 if is_invalid else 0 + +if __name__ == '__main__': + sys.exit(main()) + + + + diff --git a/.github/workflows/commit-message-policy.yml b/.github/workflows/commit-message-policy.yml new file mode 100644 index 0000000000..b623665ce6 --- /dev/null +++ b/.github/workflows/commit-message-policy.yml @@ -0,0 +1,25 @@ +name: Validate Commit Message AAMP +on: + pull_request_target: + pull_request: + branches: + - dev_sprint_25_2 + - feature/VPLAY-10292_new + - feature/VPLAY-10292 + - feature/VPLAY-10292_temp + types: [ opened, reopened, edited, synchronize, unlocked ] + +jobs: + validate-commit-message: + name: commit-template-validation + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Executing Validation Script + run: | + python3 .github/commit_template_validation.py --newrev "${{ github.event.pull_request.head.sha }}" --message "${{ github.event.pull_request.title }}" diff --git a/AampTsbDataManager.cpp b/AampTsbDataManager.cpp index 24ec9a37eb..a7c42ea8ec 100644 --- a/AampTsbDataManager.cpp +++ b/AampTsbDataManager.cpp @@ -446,7 +446,7 @@ void AampTsbDataManager::Flush() * @fn GetNextDiscFragment * @brief API to get next discontinuous fragment in the list. If not found, will return nullptr. * @param[in] position - Absolute position, in seconds since 1970, for querying the discontinuous fragment - * @param[in] backwordSerach - Search direction from the position to discontinuous fragment, default forward + * @param[in] backwordSearch - Search direction from the position to discontinuous fragment, default forward * @return TsbFragmentData shared object to fragment data */ TsbFragmentDataPtr AampTsbDataManager::GetNextDiscFragment(double position, bool backwardSearch) diff --git a/AampTsbDataManager.h b/AampTsbDataManager.h index 6468774162..06905f993f 100644 --- a/AampTsbDataManager.h +++ b/AampTsbDataManager.h @@ -391,10 +391,10 @@ class AampTsbDataManager * @fn GetNextDiscFragment * @brief API to get next discontinuous fragment in the list. If not found, will return nullptr. * @param[in] position - Absolute position, in seconds since 1970, for querying the discontinuous fragment - * @param[in] backwordSerach - Search direction from the position to discontinuous fragment, default forward + * @param[in] backwordSearch - Search direction from the position to discontinuous fragment, default forward * @return TsbFragmentData shared object to fragment data */ - std::shared_ptr GetNextDiscFragment(double position, bool backwordSerach = false); + std::shared_ptr GetNextDiscFragment(double position, bool backwordSearch = false); /** * @fn DumpData diff --git a/dash/mpd/MPDModel.cpp b/dash/mpd/MPDModel.cpp index 46b0ac9757..53409dc93b 100644 --- a/dash/mpd/MPDModel.cpp +++ b/dash/mpd/MPDModel.cpp @@ -1432,7 +1432,7 @@ void DashMPDRoot::setLocation(string location) { } /** - * @briefa Set fetchTime + * @brief Set fetchTime * @param FetchTime */ void DashMPDRoot::setFetchTime(double fetchTime) { diff --git a/main_aamp.h b/main_aamp.h index ae1eccb736..1c02070c6a 100644 --- a/main_aamp.h +++ b/main_aamp.h @@ -717,7 +717,7 @@ class StreamSink * @brief API to set track Id to audio sync property in case of AC4 audio * * @param[in] trackId - AC4 track Id parsed by aamp based of preference - * @return bol sttaus of API + * @return bol status of API */ /** diff --git a/ota_shim.cpp b/ota_shim.cpp index abb69544fd..c67b05b136 100644 --- a/ota_shim.cpp +++ b/ota_shim.cpp @@ -46,7 +46,7 @@ void StreamAbstractionAAMP_OTA::onPlayerStatusHandler(PlayerStatusData data) { { // Check if event is for current aamp instance, // sometimes blocked events are delayed and in fast channel change - // senario , it is delivered late. + // scenario , it is delivered late. currentLocator = aamp->GetManifestUrl(); if( 0 != currentLocator.compare(data.eventUrl)) diff --git a/tsprocessor.cpp b/tsprocessor.cpp index 021ec73b66..0a391ca3c6 100644 --- a/tsprocessor.cpp +++ b/tsprocessor.cpp @@ -2045,9 +2045,9 @@ bool TSProcessor::processStartCode(unsigned char *buffer, bool& keepScanning, in } } break; - case 2: // Slice data partiton A - case 3: // Slice data partiton B - case 4: // Slice data partiton C + case 2: // Slice data partition A + case 3: // Slice data partition B + case 4: // Slice data partition C break; case 6: // SEI break;