From 84cd5950c8b97166264e154ae11e9520775b4d30 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 8 Aug 2025 21:32:47 -0500 Subject: [PATCH] initial commit --- .coveragerc | 3 ++ .github/workflows/build.yml | 60 +++++++++++++++++++++++++++++++++++++ subfunctions.py | 26 ++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 .coveragerc create mode 100644 .github/workflows/build.yml create mode 100644 subfunctions.py diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..adf036d --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[run] +patch = subprocess +branch = true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6ad56db --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,60 @@ +# SPDX-FileCopyrightText: 2021-2024 Jeff Epler +# +# SPDX-License-Identifier: CC0-1.0 + +name: Test wwvbgen + +on: + push: + pull_request: + release: + types: [published] + check_suite: + types: [rerequested] + +jobs: + test: + strategy: + fail-fast: false + matrix: + python-version: + - '3.13' + os-version: + - 'ubuntu-latest' + - 'windows-latest' + - 'macos-latest' + + runs-on: ${{ matrix.os-version }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install deps + run: | + python -mpip install wheel + python -mpip install coverage + + - name: Inspect system details + run: | + python -v -mcoverage --help + + - name: Coverage + run: | + python -mcoverage run subfunctions.py 0 1 2 + python -mcoverage combine + python -mcoverage xml --include "*.py" + python -mcoverage html --include "*.py" + python -mcoverage report --fail-under=90 --include "*.py" + + - name: Upload Coverage as artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage for ${{ matrix.python-version }} on ${{ matrix.os-version }} + path: coverage.xml diff --git a/subfunctions.py b/subfunctions.py new file mode 100644 index 0000000..9bb989d --- /dev/null +++ b/subfunctions.py @@ -0,0 +1,26 @@ +import subprocess +import argparse + +def f1(): + print("function 1") +def f2(): + print("function 2") +def f3(): + print("function 3") + +functions = [f1, f2, f3] + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("cases", nargs='+', type=int) + args = parser.parse_args() + + if len(args.cases) > 1: + for c in args.cases: + subprocess.call(["python", __file__, f"{c}"]) + else: + case = args.cases[0] + functions[case]() + +if __name__ == '__main__': + main()