From c01c56357911c711a3831000544e58c7a3f4d3e7 Mon Sep 17 00:00:00 2001 From: Johnathan Irvin Date: Tue, 23 May 2023 12:29:59 -0400 Subject: [PATCH] feat(ci): Added unit testing on PR * Taken from [python-template](https://github.com/JohnnyIrvin/python-template) --- .github/workflows/unit-test.yml | 48 +++++++++++++++++++++++++++++++++ build.py | 3 +-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..e8ddf93 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 Johnathan P. Irvin +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +name: Unit Tests + +on: + pull_request: + branches: + - trunk + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Test with pytest + run: | + python -m pytest diff --git a/build.py b/build.py index c52cbcb..2ef76c9 100755 --- a/build.py +++ b/build.py @@ -12,7 +12,7 @@ def copy_and_apply_func(src_dir: str, dst_dir: str, func: Callable[[str], None]) src_dir (str): The source directory. dst_dir (str): The destination directory. func (Callable[[str], None]): The function to apply to each file. - """ + """ for root, _, files in os.walk(src_dir): for file in files: @@ -117,7 +117,6 @@ def minimize(html: str) -> str: """ return html.replace("\n", "").replace("\t", "").replace(" ", "") - def main() -> None: """ The main entry point for the script.