diff --git a/.cspell.json b/.cspell.json index 2d2eb603..8025044f 100644 --- a/.cspell.json +++ b/.cspell.json @@ -87,6 +87,7 @@ "DYNAMICVPD", "DYNAMICEXHII", "DYNAMICEXVPD", + "DYNAMICEX", "PCD's", "MDEPKG", "iommu", @@ -96,6 +97,10 @@ "nonlocalizable", "mkdocs", "DBXFILE", - "decodefs" + "decodefs", + "Guids", + "apath", + "vsvars", + "packagepatahlist" ] -} \ No newline at end of file +} diff --git a/.github/ISSUE_TEMPLATE/doc_report.yml b/.github/ISSUE_TEMPLATE/doc_report.yml index eab49b40..6c32ed08 100644 --- a/.github/ISSUE_TEMPLATE/doc_report.yml +++ b/.github/ISSUE_TEMPLATE/doc_report.yml @@ -27,4 +27,4 @@ body: label: Additional context description: "Any other additional context about the problem not covered by the above." validations: - required: false \ No newline at end of file + required: false diff --git a/.github/workflows/CIRunner.yml b/.github/workflows/CIRunner.yml index 4b4ec919..fc6f2292 100644 --- a/.github/workflows/CIRunner.yml +++ b/.github/workflows/CIRunner.yml @@ -36,44 +36,44 @@ jobs: with: python-version: ${{ inputs.python-version }} cache: 'pip' - + - name: Install pip Dependencies run: | python -m pip install --upgrade pip pip install --upgrade -r requirements.txt pip install --upgrade -r docs/user/requirements.txt pip install -e . - + - name: Set up Node ${{ inputs.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ inputs.node-version }} - + - name: Install npm Dependencies run: | npm install -g markdownlint-cli@0.32.2 npm install -g cspell@5.20.0 - + - name: Run flake8 if: success() || failure() run: flake8 ${{ inputs.package-src }} - + - name: Run markdownlint if: success() || failure() run: markdownlint "**/*.md" - + - name: Run cspell if: success() || failure() run: cspell -c .cspell.json "**/*.py" "**/*.md" - + - name: Run pydocstyle if: success() || failure() run: pydocstyle ${{ inputs.package-src }} - + - name: Run mkdocs build if: success() || failure() run: mkdocs build --strict - + - name: Run basic dev tests if: success() || failure() run: python BasicDevTests.py diff --git a/.github/workflows/UnitTestRunner.yml b/.github/workflows/UnitTestRunner.yml index c12fa8d8..a0555915 100644 --- a/.github/workflows/UnitTestRunner.yml +++ b/.github/workflows/UnitTestRunner.yml @@ -22,7 +22,7 @@ jobs: matrix: python-version: ${{ fromJson(inputs.python-versions) }} os: [ubuntu-latest, windows-latest] - + steps: - uses: actions/checkout@v3 @@ -31,16 +31,16 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' - + - name: Install pip Dependencies run: | python -m pip install --upgrade pip pip install --upgrade -r requirements.txt pip install -e . - + - name: Run Unit Tests run: coverage run -m pytest - + - name: Format Coverage results run: coverage xml @@ -48,7 +48,7 @@ jobs: uses: codecov/codecov-action@v3 with: verbose: false - + - uses: actions/upload-artifact@v3 with: name: Artifacts-${{matrix.os}}-${{matrix.python-version}} diff --git a/.github/workflows/VariableProducer.yml b/.github/workflows/VariableProducer.yml index 1a588fac..36655e98 100644 --- a/.github/workflows/VariableProducer.yml +++ b/.github/workflows/VariableProducer.yml @@ -6,10 +6,10 @@ on: workflow_call: outputs: - python-versions: + python-versions: description: 'Python Versions' value: ${{ jobs.produce.outputs.python-versions }} - node-versions: + node-versions: description: 'Node Versions' value: ${{ jobs.produce.outputs.node-versions }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0da06072..1196bac9 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -48,11 +48,11 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild @@ -61,7 +61,7 @@ jobs: # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. + # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | diff --git a/.github/workflows/doc-release.yml b/.github/workflows/doc-release.yml index afbc0cb4..56876c2f 100644 --- a/.github/workflows/doc-release.yml +++ b/.github/workflows/doc-release.yml @@ -14,7 +14,7 @@ jobs: variables: name: Variables uses: ./.github/workflows/VariableProducer.yml - + build: name: Build needs: variables @@ -23,28 +23,28 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - + - name: Set up Python ${{ fromJson(needs.variables.outputs.python-versions)[0] }} uses: actions/setup-python@v4 with: python-version: ${{ fromJson(needs.variables.outputs.python-versions)[0] }} cache: 'pip' - + - name: Install dependencies run: | python -m pip install --upgrade pip pip install --upgrade -r docs/user/requirements.txt - + - name: Build Documentation run: | mkdocs build --strict - + - name: Upload Github Pages Site Artifact uses: actions/upload-pages-artifact@v1 with: name: "github-pages" path: "site/" - + deploy: name: Deploy diff --git a/.github/workflows/run-ci.yml b/.github/workflows/run-ci.yml index 784faeb2..0dd3d708 100644 --- a/.github/workflows/run-ci.yml +++ b/.github/workflows/run-ci.yml @@ -13,11 +13,11 @@ on: branches: [ "master" ] jobs: - + variables: name: Variables uses: ./.github/workflows/VariableProducer.yml - + ci: needs: variables name: CI @@ -26,7 +26,7 @@ jobs: python-version: ${{ fromJson(needs.variables.outputs.python-versions)[0] }} node-version: ${{ fromJson(needs.variables.outputs.node-versions)[0] }} package-src: edk2toollib - + unit-test: needs: [variables,ci] name: Unit Test diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 3c9b0171..c1fc6a18 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -3,4 +3,4 @@ { "default": true, "MD013": {"line_length": 120, "code_blocks": false } -} \ No newline at end of file +} diff --git a/azure-pipelines/azure-pipelines-release.yml b/azure-pipelines/azure-pipelines-release.yml index 0629b2b1..44341852 100644 --- a/azure-pipelines/azure-pipelines-release.yml +++ b/azure-pipelines/azure-pipelines-release.yml @@ -14,7 +14,7 @@ resources: endpoint: tianocore # trigger when a vXX.XX.XX tag is created -trigger: +trigger: tags: include: - v* diff --git a/docs/contributor/developing.md b/docs/contributor/developing.md index 202001ed..4f2d747f 100644 --- a/docs/contributor/developing.md +++ b/docs/contributor/developing.md @@ -87,7 +87,7 @@ INFO: Newer editors are very helpful in resolving source formatting errors (whitespace, indentation, etc). In VSCode open the py file and use - ++alt+shift+f++ to auto format. + ++alt+shift+f++ to auto format. 2. Run a Basic Python docstring Check (using pydocstring) and resolve any issues @@ -130,6 +130,41 @@ markdownlint "**/*.md" ``` +### Githooks + +Optionally, there are two githooks provided to automate testing locally before running CI + +* githooks/basic-pre-commit-config.yaml + * This file runs only the quickest checks in order to test the code for common mistakes + * This yaml will pull in all the tools into an enviornment it needs to run +* githooks/advanced-pre-commit-config.yaml + * This file will run all the basic checks and the longer running checks + * This yaml will need mkdocs installed prior to running + +#### Installing + +Installing is entirely optional, a developer may choose to run this manually. +The following command will enable this pre-commit to prior to each commit. If it detects +issues it will fail to commit until they are fixed. + +```bash +pre-commit install -c githooks/basic-pre-commit-config.yaml +``` + +#### Running across the entire repository (Manually) + +This step is entirely manual but gives a good example of what the behavior of this tool will be. + +```bash +pre-commit run --all-files -c githooks/basic-pre-commit-config.yaml +``` + +#### Uninstalling + +```bash +pre-commit uninstall +``` + ## Conventions Shortlist ### File and folder names @@ -140,7 +175,7 @@ naming should follow PEP8 () ### Comments Docstring style comments should be added to each public function and class. -\*Existing code should be updated to be compliant as it is modified. +\*Existing code should be updated to be compliant as it is modified. ### New Module or Class @@ -150,7 +185,7 @@ purpose and provide general purpose support. The module should be added to the package in which the interface is defined. * For example for modules supporting interfaces defined in the UEFI - specification it would be in the __uefi__ package. + specification it would be in the __uefi__ package. * If it is defined by EDK2 then it should be in the __uefi.edk2__ package. Documentation of the feature should be added to the __docs/features__ folder in @@ -162,7 +197,7 @@ parameters and usage info. Unit tests should be written in python unittest or pytest format. A test module should be added in the same folder or package as the module and the filename -should be same as the module plus "_test". +should be same as the module plus "_test". ### Spell Checking / False Positives diff --git a/docs/user/features/build_objects.md b/docs/user/features/build_objects.md index 8f484815..ccfdc564 100644 --- a/docs/user/features/build_objects.md +++ b/docs/user/features/build_objects.md @@ -53,8 +53,6 @@ functionality. However, there are a few problems with that fact. you to be in a defines section. You have no way to know this from the main DSC file. -3. - ## Why were they made To better abstract away the essence of what a build is doing. DSC is a way to diff --git a/docs/user/features/windows_firmware_policy.md b/docs/user/features/windows_firmware_policy.md index c591944c..25d36bed 100644 --- a/docs/user/features/windows_firmware_policy.md +++ b/docs/user/features/windows_firmware_policy.md @@ -1,7 +1,7 @@ # Windows Firmware Policy Library This library supports creation and analysis of Windows Firmware Policy binaries -(unsigned) +(unsigned) ## Usage info @@ -17,14 +17,18 @@ This library supports creation and analysis of Windows Firmware Policy binaries covered here). 1. Construct a Dictionary with keys 'Manufacturer', 'Product', 'SerialNumber', 'OEM_01', 'OEM_02', & 'Nonce' populated with the targeting values read from - the device. + the device. 1. Construct an default ```FirmwarePolicy()``` object, then call - ```SetDeviceTarget(target_dictionary)``` to populate it with the targeting - information + + ```SetDeviceTarget(target_dictionary)``` + + to populate it with the targeting information 1. Bitwise OR the desired ```FirmwarePolicy.FW_POLICY_VALUE_foo``` values into an integer and pass to ```SetDevicePolicy(64_bit_device_policy)``` 1. The FirmwarePolicy object is now ready, serialize it to a file stream using + ```SerializeToStream(your_file_stream)``` + 1. For consumption by a secure device, sign the policy using instructions found elsewhere diff --git a/edk2toollib/tests/parsers/test_gitingore_parser.py b/edk2toollib/tests/parsers/test_gitingore_parser.py index 2b20843c..6a500e28 100644 --- a/edk2toollib/tests/parsers/test_gitingore_parser.py +++ b/edk2toollib/tests/parsers/test_gitingore_parser.py @@ -68,7 +68,7 @@ def test_gitignoreparser_filter(self): self.assertTrue(rule_tester(os.path.join(root, "reader", "testing.txt"))) # Test a rule which specifies that a folder at any depth from the - # root is correclty filtered. + # root is correctly filtered. # Example line in a .gitignore # **/Test/ diff --git a/edk2toollib/uefi/edk2/parsers/dsc_parser.py b/edk2toollib/uefi/edk2/parsers/dsc_parser.py index 6d0a212c..382f55ba 100644 --- a/edk2toollib/uefi/edk2/parsers/dsc_parser.py +++ b/edk2toollib/uefi/edk2/parsers/dsc_parser.py @@ -51,7 +51,7 @@ def __ParseLine(self, Line, file_name=None, lineno=None): # Other parser returns line_resolved, []. Need to figure out which is right return ("", [], None) - # not conditional keep procesing + # not conditional keep processing # check if conditional is active if (not self.InActiveCode()): @@ -189,7 +189,7 @@ def __ParseDefineLine(self, Line): # Other parser returns line_resolved, []. Need to figure out which is right return ("", []) - # not conditional keep procesing + # not conditional keep processing # check if conditional is active if (not self.InActiveCode()): diff --git a/githooks/advanced-pre-commit-config.yaml b/githooks/advanced-pre-commit-config.yaml new file mode 100644 index 00000000..78b92b5e --- /dev/null +++ b/githooks/advanced-pre-commit-config.yaml @@ -0,0 +1,38 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + types_or: [python, markdown] + - id: end-of-file-fixer + - id: check-added-large-files + - id: check-merge-conflict + - id: check-ast # check python ast +- repo: https://github.com/streetsidesoftware/cspell-cli + rev: v6.31.0 + hooks: + - id: cspell + types_or: [markdown, python] +- repo: https://github.com/PyCQA/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + entry: flake8 edk2toollib +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.12.0 + hooks: + - id: markdownlint + args: [--config, .markdownlint.yaml] +- repo: local + hooks: + - id: BasicDevTests + name: BasicDevTests + language: system + entry: python BasicDevTests.py + - id: mkdocs-build + name: Build MkDocs site + entry: mkdocs build --strict + language: python + always_run: true + pass_filenames: false + require_serial: true diff --git a/githooks/basic-pre-commit-config.yaml b/githooks/basic-pre-commit-config.yaml new file mode 100644 index 00000000..45cccf40 --- /dev/null +++ b/githooks/basic-pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + types_or: [python, markdown, yaml] + - id: check-added-large-files + - id: check-merge-conflict + - id: check-ast # check python ast +- repo: https://github.com/streetsidesoftware/cspell-cli + rev: v6.31.0 + hooks: + - id: cspell + types_or: [markdown, python] +- repo: https://github.com/PyCQA/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + entry: flake8 edk2toollib +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.12.0 + hooks: + - id: markdownlint + args: [--config, .markdownlint.yaml] diff --git a/mkdocs.yml b/mkdocs.yml index b80eed15..bd200f25 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -71,4 +71,4 @@ nav: - Windows Firmware Policy: features/windows_firmware_policy.md - Build Objects: features/build_objects.md - API Reference: - - ... | flat | api/**/*.md \ No newline at end of file + - ... | flat | api/**/*.md diff --git a/requirements.publisher.txt b/requirements.publisher.txt index d8756b44..c780d29a 100644 --- a/requirements.publisher.txt +++ b/requirements.publisher.txt @@ -1,3 +1,3 @@ wheel == 0.40.0 setuptools == 67.6.1 -twine == 4.0.2 \ No newline at end of file +twine == 4.0.2 diff --git a/requirements.txt b/requirements.txt index a40d439b..c9a37170 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ pytest == 7.3.1 coverage == 7.2.3 flake8 == 6.0.0 pydocstyle == 6.3.0 +pre-commit == 3.2.2