From 1cb1b98e6ed3ea3e6d5b363e32c532494f59b078 Mon Sep 17 00:00:00 2001 From: Nathaniel Mitchell Date: Thu, 9 Jan 2025 10:07:43 -0800 Subject: [PATCH] Add unit test code coverage minimum requirement Signed-off-by: Nathaniel Mitchell --- .github/workflows/tests.yml | 47 ++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 23b6f93531..758fce87e7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-22.04 container: image: docker://${{ matrix.distro.image_prefix }}${{ matrix.distro.name }}:${{ matrix.distro.tag }} - + environment: pullrequests steps: - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 @@ -131,7 +131,7 @@ jobs: modinfo "${MODULE}" - name: Upload Linux driver from ${{ steps.modinfo.outputs.module_path }} - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: chipsec-${{ steps.versions.outputs.chipsec }}.${{ matrix.distro.name }}-${{ matrix.distro.tag }}${{ matrix.distro.variant }}-${{ steps.versions.outputs.kernel }}.${{ steps.versions.outputs.uname_m }} path: ${{ steps.modinfo.outputs.module_path }} @@ -180,14 +180,14 @@ jobs: run: python setup.py build_ext -i - name: Upload Windows Main driver - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: chipsec_drivers_windows_x64_py${{ matrix.versions.python }}_win${{ matrix.versions.window }} path: drivers/windows/chipsec/x64 if-no-files-found: error - name: Upload Windows PCI Filter driver - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: pcifilter_drivers_windows_x64_py${{ matrix.versions.python }}_win${{ matrix.versions.window }} path: drivers/windows/pcifilter/x64 @@ -231,6 +231,35 @@ jobs: with: egress-policy: audit + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Dump job context + env: + JOB_CONTEXT: ${{ toJson(job) }} + run: echo "$JOB_CONTEXT" + - name: Dump steps context + env: + STEPS_CONTEXT: ${{ toJson(steps) }} + run: echo "$STEPS_CONTEXT" + - name: Dump runner context + env: + RUNNER_CONTEXT: ${{ toJson(runner) }} + run: echo "$RUNNER_CONTEXT" + - name: Dump strategy context + env: + STRATEGY_CONTEXT: ${{ toJson(strategy) }} + run: echo "$STRATEGY_CONTEXT" + - name: Dump matrix context + env: + MATRIX_CONTEXT: ${{ toJson(matrix) }} + run: echo "$MATRIX_CONTEXT" + - name: Dump vars context + env: + VARS_CONTEXT: ${{ toJson(vars) }} + run: echo "$VARS_CONTEXT" + - name: Set up Python ${{ matrix.versions.python }} uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: @@ -246,7 +275,7 @@ jobs: run: | sudo apt-get update -q sudo apt-get install -qqy dkms nasm python3-setuptools - pip install distro pytest + pip install distro pytest pytest-cov pip install -r linux_requirements.txt sudo pip uninstall importlib_metadata sudo pip install importlib_metadata --force-reinstall @@ -267,7 +296,13 @@ jobs: run: python3 -m unittest - name: Run Python pytest - run: python -m pytest tests + env: + MINCOV: ${{ vars.COVERAGE_MINIMUM_REQUIREMENT }} + run: | + echo "${{ vars }}" + echo "${{ vars.COVERAGE_MINIMUM_REQUIREMENT }}" + echo "${{ vars.coverage_minimum_requirement }}" + python -m pytest --cov --cov-report=term-missing --cov-fail-under="${{ vars.coverage_minimum_requirement }}" - name: Run xml cfg checker run: |