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

Update PSA tools #10010

Merged
merged 3 commits into from Mar 11, 2019

Conversation

Projects
None yet
8 participants
@orenc17
Copy link
Contributor

commented Mar 8, 2019

Description

  • Update PSA tools documentation
    Add option to git commit for each platform
  • Docstrings for all functions
  • Small refactor

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

Release Notes

@0xc0170

0xc0170 approved these changes Mar 8, 2019

@0xc0170 0xc0170 requested a review from ChiefBureaucraticOfficer Mar 8, 2019

@0xc0170 0xc0170 requested a review from ARMmbed/mbed-os-psa Mar 8, 2019

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Mar 8, 2019

@0xc0170

This comment has been minimized.

Copy link
Member

commented Mar 8, 2019

CI started

@alzix

alzix approved these changes Mar 8, 2019

Copy link
Contributor

left a comment

LGTM

@mbed-ci

This comment has been minimized.

Copy link

commented Mar 8, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 1
Build artifacts

@ChiefBureaucraticOfficer
Copy link

left a comment

Meets criteria, PSA feature delivery. Approved.

@adbridge

This comment has been minimized.

Copy link
Contributor

commented Mar 8, 2019

Moved to a fix type as this now has a code commit as well

@adbridge

This comment has been minimized.

Copy link
Contributor

commented Mar 8, 2019

CI restarted

@adbridge adbridge added needs: work and removed needs: CI labels Mar 8, 2019

tools/psa/release.py Outdated
'commit',
'-m', commit_message
]

This comment has been minimized.

Copy link
@adbridge

adbridge Mar 8, 2019

Contributor

Have you tried this on both windows and linux ? We had problems running on linux with this format of command passing to subprocess. Hence we do it this way:

def run_cmd(command, exit_on_failure=False):
    """ Run a system command returning a status result
    
    This is just a wrapper for the run_cmd_with_output() function, but
    only returns the status of the call.
    
    Args:
    command - system command as a list of tokens
    exit_on_failure - If True exit the program on failure (default = False)
    
    Returns:
    return_code - True/False indicating the success/failure of the command
    """
    return_code, _ = run_cmd_with_output(command, exit_on_failure)       
    return return_code

def run_cmd_with_output(command, exit_on_failure=False):
    """ Run a system command returning a status result and any command output
    
    Passes a command to the system and returns a True/False result once the 
    command has been executed, indicating success/failure. If the command was 
    successful then the output from the command is returned to the caller.
    Commands are passed as a string. 
    E.g. The command 'git remote -v' would be passed in as "git remote -v"
    Args:
    command - system command as a string
    exit_on_failure - If True exit the program on failure (default = False)
    
    Returns:
    return_code - True/False indicating the success/failure of the command
    output - The output of the command if it was successful, else empty string
    """
    text = '[Exec] ' + command
    userlog.debug(text)
    returncode = 0
    output = ""
    try:
        output = subprocess.check_output(command, shell=True)
    except subprocess.CalledProcessError as e:
        text = "The command " + str(command) + "failed with return code: " + str(e.returncode)
        userlog.warning(text)
        returncode = e.returncode
        if exit_on_failure:
            sys.exit(1)
    return returncode, output


Then called by:
cmd = "git rev-parse HEAD"
return_code, sha = run_cmd_with_output(cmd, exit_on_failure=True)

This method works on both platforms .

This comment has been minimized.

Copy link
@orenc17

orenc17 Mar 8, 2019

Author Contributor

Tested on Mac

This comment has been minimized.

Copy link
@alzix

alzix Mar 8, 2019

Contributor

shell=False is a default setting and considered to be more secure as it prevent shell injection. It should be our choice of preference when calling to subprocess.
It works perfectly on linux. But there are some limitations about it that you should be aware of. E.g. aliases are not honored. Environment variables passed via $ sign are not interpolated, e.t.c.
Oren's script is perfectly valid

This comment has been minimized.

Copy link
@cmonr

cmonr Mar 8, 2019

Contributor

Tested on Mac

Was expecting more of a "Tested in multiple OSs"

This comment has been minimized.

Copy link
@orenc17

orenc17 Mar 8, 2019

Author Contributor

@cmonr I think it's quite good considering it's my day off

This comment has been minimized.

Copy link
@adbridge

adbridge Mar 11, 2019

Contributor

@alzix As we are only ever running internally on the ARM network then shell injection is hardly a major concern. I didn't say his script wasn't valid, I merely pointed out that there can be a number of issues running it that way including compatibility on windows and linux, which were born out by much testing of our own scripts. Providing his script runs fine on all the different OS' (which it seems is the case) then I have no problem with it.

@adbridge

This comment has been minimized.

Copy link
Contributor

commented Mar 8, 2019

NOTE: ARMmbed/mbed-os-release#82 is dependent on this going in first and being compatible.

@mbed-ci

This comment has been minimized.

Copy link

commented Mar 8, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 2
Build artifacts

@orenc17 orenc17 force-pushed the kfnta:psa_tools_docs_update branch Mar 8, 2019

@orenc17 orenc17 changed the title Update docs for PSA tools Update PSA tools Mar 8, 2019

@0xc0170 0xc0170 added needs: CI and removed needs: work labels Mar 8, 2019

@0xc0170

This comment has been minimized.

Copy link
Member

commented Mar 8, 2019

CI restarted

@adbridge review answered?

@mbed-ci

This comment has been minimized.

Copy link

commented Mar 8, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 3
Build artifacts

@0xc0170 0xc0170 added needs: review and removed needs: CI labels Mar 9, 2019

@orenc17 orenc17 force-pushed the kfnta:psa_tools_docs_update branch Mar 10, 2019

@NirSonnenschein

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2019

started CI on latest fix

@orenc17 orenc17 force-pushed the kfnta:psa_tools_docs_update branch Mar 10, 2019

@orenc17 orenc17 force-pushed the kfnta:psa_tools_docs_update branch Mar 10, 2019

@orenc17

This comment has been minimized.

Copy link
Contributor Author

commented Mar 10, 2019

@adbridge Tested on windows and linux as well

@mbed-ci

This comment has been minimized.

Copy link

commented Mar 10, 2019

Test run: FAILED

Summary: 1 of 9 test jobs failed
Build number : 4
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-ARMC6
@0xc0170

This comment has been minimized.

Copy link
Member

commented Mar 10, 2019

Can you review latest failures? And fix the latest commit typo 1a47960a2b23774c4af219722a0c5149f6e7d596 (the fist line in the commit msg)

@mbed-ci

This comment has been minimized.

Copy link

commented Mar 10, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 5
Build artifacts

@NirSonnenschein

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2019

@0xc0170 latest test run succeeded.
@orenc17 please fix the typo (#10010 (comment))

Enhancements
* Replace call with check_call to throw exception on failure
* Check if binaries actually been changes before calling git commit
* Docstrings for all functions
* Small refactor

@orenc17 orenc17 force-pushed the kfnta:psa_tools_docs_update branch to f534caa Mar 10, 2019

@orenc17

This comment has been minimized.

Copy link
Contributor Author

commented Mar 10, 2019

@0xc0170 @NirSonnenschein Typo fixed

@0xc0170

This comment has been minimized.

Copy link
Member

commented Mar 11, 2019

CI restarted

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Mar 11, 2019

@mbed-ci

This comment has been minimized.

Copy link

commented Mar 11, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 6
Build artifacts

@0xc0170 0xc0170 added ready for merge and removed needs: CI labels Mar 11, 2019

@0xc0170 0xc0170 merged commit ba24cb2 into ARMmbed:master Mar 11, 2019

28 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci/build-ARMC5 Success
Details
jenkins-ci/build-ARMC6 Success
Details
jenkins-ci/build-GCC_ARM Success
Details
jenkins-ci/build-IAR8 Success
Details
jenkins-ci/cloud-client-test Success
Details
jenkins-ci/dynamic-memory-usage RTOS ROM(+0 bytes) RAM(+0 bytes)
Details
jenkins-ci/exporter Success
Details
jenkins-ci/greentea-test Success
Details
jenkins-ci/mbed2-build-ARMC5 Success
Details
jenkins-ci/mbed2-build-ARMC6 Success
Details
jenkins-ci/mbed2-build-GCC_ARM Success
Details
jenkins-ci/mbed2-build-IAR8 Success
Details
jenkins-ci/unittests Success
Details
travis-ci/astyle Local astyle testing has passed
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/doxy-spellcheck Local doxy-spellcheck testing has passed
Details
travis-ci/events Passed, runtime is 10195 cycles (+173 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/include_check Local include_check testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 8408B (+0.00%)
Details
travis-ci/psa-autogen Local psa-autogen testing has passed
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details
travis-ci/tools-py3.5 Local tools-py3.5 testing has passed
Details
travis-ci/tools-py3.6 Local tools-py3.6 testing has passed
Details
travis-ci/tools-py3.7 Local tools-py3.7 testing has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.