-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial port from Project Mu * Quote Python_home and Python_command if needed to avoid BaseTools change
- Loading branch information
Showing
61 changed files
with
8,437 additions
and
6 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,2 @@ | ||
[run] | ||
omit = edk2toolext/tests/* |
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,5 @@ | ||
[flake8] | ||
#E266 too many leading '#' for block comment | ||
#E722 do not use bare 'except' | ||
ignore = E266,E722 | ||
max_line_length = 120 |
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,59 @@ | ||
* text=auto | ||
|
||
*.md text | ||
*.txt text | ||
|
||
# Graphics | ||
*.png binary | ||
*.jpg binary | ||
*.jpeg binary | ||
*.gif binary | ||
*.tif binary | ||
*.tiff binary | ||
*.ico binary | ||
# SVG treated as an asset (binary) by default. | ||
*.svg text | ||
|
||
# Scripts | ||
*.bash text eol=lf | ||
*.sh text eol=lf | ||
# These are explicitly windows files and should use crlf | ||
*.bat text eol=crlf | ||
*.cmd text eol=crlf | ||
*.ps1 text eol=crlf | ||
|
||
# Serialisation | ||
*.json text | ||
*.toml text | ||
*.xml text | ||
*.yaml text | ||
*.yml text | ||
|
||
# Archives | ||
*.7z binary | ||
*.gz binary | ||
*.tar binary | ||
*.zip binary | ||
*.exe binary | ||
|
||
# | ||
# Exclude files from exporting | ||
# | ||
|
||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
|
||
|
||
# Basic .gitattributes for a python repo. | ||
|
||
# Source files | ||
# ============ | ||
*.pxd text diff=python | ||
*.py text diff=python | ||
*.py3 text diff=python | ||
*.pyc text diff=python | ||
*.pyd text diff=python | ||
*.pyo text diff=python | ||
*.pyw text diff=python | ||
*.pyx text diff=python | ||
*.pyz text diff=python |
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,14 @@ | ||
*.exe | ||
*.pyc | ||
Lib | ||
dist | ||
*.egg-info | ||
build. | ||
/cov_html | ||
/.pytest_cache | ||
/pytest_report.html | ||
/.coverage | ||
/cov.xml | ||
/test.junit.xml | ||
flake8.err.log | ||
/.eggs |
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,108 @@ | ||
## | ||
# Quick script to check that python code in the package | ||
# aligns with pep8 and file encoding. I have not found | ||
# a way to enforce that with tools like flake8 | ||
# | ||
# There must be a better way. :) | ||
# | ||
# Copyright (c) Microsoft Corporation | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
import glob | ||
import os | ||
import sys | ||
import logging | ||
|
||
|
||
def TestEncodingOk(apath, encodingValue): | ||
try: | ||
with open(apath, "rb") as fobj: | ||
fobj.read().decode(encodingValue) | ||
except Exception as exp: | ||
logging.critical("Encoding failure: file: {0} type: {1}".format(apath, encodingValue)) | ||
logging.error("EXCEPTION: while processing {1} - {0}".format(exp, apath)) | ||
return False | ||
return True | ||
|
||
|
||
def TestLineEndingsOk(apath, Windows: bool): | ||
WIN_EOL = b'\r\n' | ||
UNIX_EOL = b'\n' | ||
|
||
with open(apath, "rb") as fobj: | ||
content_uni = fobj.read() | ||
|
||
if(not Windows): | ||
if(WIN_EOL in content_uni): | ||
logging.critical("Windows EOL in use file: {0}".format(apath)) | ||
return False | ||
return True | ||
|
||
else: | ||
# windows | ||
# since UNIX EOL is substring of WIN EOL replace WIN with something | ||
# else and then look for UNIX | ||
content_no_nl = content_uni.replace(WIN_EOL, b" ") | ||
if UNIX_EOL in content_no_nl: | ||
logging.critical("UNIX EOL in use file: {0}".format(apath)) | ||
return False | ||
return True | ||
|
||
|
||
def TestFilenameLowercase(apath): | ||
if apath != apath.lower(): | ||
logging.critical(f"Lowercase failure: file {apath} not lower case path") | ||
logging.error(f"\n\tLOWERCASE: {apath.lower()}\n\tINPUTPATH: {apath}") | ||
return False | ||
return True | ||
|
||
|
||
def TestNoSpaces(apath): | ||
if " " in apath: | ||
logging.critical(f"NoSpaces failure: file {apath} has spaces in path") | ||
return False | ||
return True | ||
|
||
|
||
def TestRequiredLicense(apath): | ||
lic = ["SPDX-License-Identifier: BSD-2-Clause-Patent"] | ||
try: | ||
with open(apath, "rb") as fobj: | ||
contents = fobj.read().decode() | ||
found = False | ||
for l in lic: | ||
if l in contents: | ||
found = True | ||
break | ||
if not found: | ||
logging.critical(f"License failure: file {apath} has incorrect, invalid, or unsupported license") | ||
return False | ||
except Exception as exp: | ||
logging.critical(f"License failure: Exception trying to read file: {apath}") | ||
logging.error("EXCEPTION: while processing {1} - {0}".format(exp, apath)) | ||
return False | ||
return True | ||
|
||
|
||
p = os.path.join(os.getcwd(), "edk2toolext") | ||
pyfiles = glob.glob(os.path.join(p, "**", "*.py"), recursive=True) | ||
error = 0 | ||
for a in pyfiles: | ||
aRelativePath = os.path.relpath(a, os.getcwd()) | ||
if(not TestEncodingOk(a, "ascii")): | ||
error += 1 | ||
if(not TestFilenameLowercase(aRelativePath)): | ||
error += 1 | ||
if(not TestNoSpaces(aRelativePath)): | ||
error += 1 | ||
if(not TestRequiredLicense(a)): | ||
error += 1 | ||
|
||
# Don't check EOL. Use .gitattributes | ||
# if(not TestLineEndingsOk(a, True)): | ||
# error += 1 | ||
|
||
logging.critical(f"Found {error} error(s) in {len(pyfiles)} file(s)") | ||
sys.exit(error) |
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,27 @@ | ||
## @file | ||
# Quick script to check that the wheel/package created is aligned on a git tag. | ||
# Official releases should not be made from non-tagged code. | ||
# | ||
# Copyright (c) Microsoft Corporation | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
import glob | ||
import os | ||
import sys | ||
|
||
p = os.path.join(os.getcwd(), "dist") | ||
whlfile = glob.glob(os.path.join(p, "*.whl")) | ||
if(len(whlfile) != 1): | ||
for filename in whlfile: | ||
print(filename) | ||
raise Exception("Too many wheel files") | ||
rfn = os.path.relpath(whlfile[0], os.getcwd()) | ||
v = rfn.split("-")[1] | ||
if v.count(".") != 2: | ||
raise Exception("Version %s not in format major.minor.patch" % v) | ||
if "dev" in v: | ||
raise Exception("No Dev versions allowed to be published.") | ||
print("version: " + str(v)) | ||
sys.exit(0) |
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 @@ | ||
Copyright (c) 2019, TianoCore and contributors. All rights reserved. | ||
Copyright (c) Microsoft All rights reserved. | ||
|
||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
Subject to the terms and conditions of this license, each copyright holder | ||
and contributor hereby grants to those receiving rights under this license | ||
a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
(except for failure to satisfy the conditions of this license) patent | ||
license to make, have made, use, offer to sell, sell, import, and otherwise | ||
transfer this software, where such license applies only to those patent | ||
claims, already acquired or hereafter acquired, licensable by such copyright | ||
holder or contributor that are necessarily infringed by: | ||
|
||
(a) their Contribution(s) (the licensed copyrights of copyright holders and | ||
non-copyrightable additions of contributors, in source or binary form) | ||
alone; or | ||
|
||
(b) combination of their Contribution(s) with the work of authorship to | ||
which such Contribution(s) was added by such copyright holder or | ||
contributor, if, at the time the Contribution is added, such addition | ||
causes such combination to be necessarily infringed. The patent license | ||
shall not apply to any other combinations which include the | ||
Contribution. | ||
|
||
Except as expressly stated above, no rights or licenses from any copyright | ||
holder or contributor is granted under this license, whether expressly, by | ||
implication, estoppel or otherwise. | ||
|
||
DISCLAIMER | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
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,7 @@ | ||
exclude *.yml | ||
exclude *.md | ||
exclude *.txt | ||
exclude .flake8 | ||
exclude .coveragerc | ||
exclude .gitignore | ||
include edk2toolext/bin/NuGet.exe |
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,83 @@ | ||
workspace: | ||
clean: all | ||
|
||
steps: | ||
- checkout: self | ||
clean: true | ||
|
||
- task: UsePythonVersion@0 | ||
inputs: | ||
versionSpec: '3.7.x' | ||
architecture: 'x64' | ||
|
||
- script: python -m pip install --upgrade pip | ||
displayName: 'Install/Upgrade pip' | ||
|
||
- script: pip uninstall -y edk2_pytool_extensions | ||
displayName: 'Remove existing version of self' | ||
|
||
- script: pip install --upgrade -r requirements.txt | ||
displayName: 'Install requirements' | ||
|
||
- script: pip install -e . | ||
displayName: 'Install from Source' | ||
|
||
- script: pytest -v --junitxml=test.junit.xml --html=pytest_report.html --self-contained-html --cov=edk2toolext --cov-report html:cov_html --cov-report xml:cov.xml --cov-config .coveragerc | ||
displayName: 'Run UnitTests' | ||
|
||
# Publish Test Results to Azure Pipelines/TFS | ||
- task: PublishTestResults@2 | ||
displayName: 'Publish junit test results' | ||
continueOnError: true | ||
condition: succeededOrFailed() | ||
inputs: | ||
testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit | ||
testResultsFiles: 'test.junit.xml' | ||
mergeTestResults: true # Optional | ||
publishRunAttachments: true # Optional | ||
|
||
# Publish Build Artifacts | ||
# Publish build artifacts to Azure Pipelines/TFS or a file share | ||
- task: PublishBuildArtifacts@1 | ||
inputs: | ||
pathtoPublish: 'pytest_report.html' | ||
artifactName: 'Edk2_pytool_extensions unit test report' | ||
continueOnError: true | ||
condition: succeededOrFailed() | ||
|
||
# Publish Code Coverage Results | ||
# Publish Cobertura code coverage results | ||
- task: PublishCodeCoverageResults@1 | ||
inputs: | ||
codeCoverageTool: 'cobertura' # Options: cobertura, jaCoCo | ||
summaryFileLocation: $(System.DefaultWorkingDirectory)/cov.xml | ||
reportDirectory: $(System.DefaultWorkingDirectory)/cov_html | ||
condition: succeededOrFailed() | ||
|
||
- script: flake8 . | ||
displayName: 'Run flake8' | ||
condition: succeededOrFailed() | ||
|
||
# Only capture and archive the lint log on failures. | ||
- script: flake8 . > flake8.err.log | ||
displayName: 'Capture flake8 failures' | ||
condition: Failed() | ||
|
||
- task: PublishBuildArtifacts@1 | ||
inputs: | ||
pathtoPublish: 'flake8.err.log' | ||
artifactName: 'Flake8 Error log file' | ||
continueOnError: true | ||
condition: Failed() | ||
|
||
- task: PythonScript@0 | ||
inputs: | ||
scriptSource: 'filePath' | ||
scriptPath: 'BasicDevTests.py' | ||
#script: # Required when scriptSource == Inline | ||
#arguments: # Optional | ||
#pythonInterpreter: # Optional | ||
#workingDirectory: # Optional | ||
#failOnStderr: false # Optional | ||
displayName: 'Check basic file and folder tests' | ||
condition: succeededOrFailed() |
Oops, something went wrong.