From 0b84f6f0e272478614c4c15817e035f92b75fc28 Mon Sep 17 00:00:00 2001 From: scosman Date: Thu, 17 Oct 2024 12:55:24 -0400 Subject: [PATCH] Add test count badge --- .github/workflows/test_count.yml | 57 ++++++++++++++++++++++++++++++++ .gitignore | 1 + README.md | 10 +++--- 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test_count.yml diff --git a/.github/workflows/test_count.yml b/.github/workflows/test_count.yml new file mode 100644 index 0000000..41a3073 --- /dev/null +++ b/.github/workflows/test_count.yml @@ -0,0 +1,57 @@ +name: Test Count Badge + +on: + push: + branches: + - main # Adjust this if your main branch has a different name + +jobs: + count_tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + cache: "pip" + + - name: Install Python dependencies + run: | + pip install -r requirements.txt + pip install -r dev-requirements.txt + + - name: Set up Node.js + uses: actions/setup-node@v4 + + - name: Install NPM dependencies + run: npm install + working-directory: ./app/web_ui + + - name: Count Python tests + run: | + PYTHON_TEST_COUNT=$(python3 -m pytest --collect-only -q . | grep "tests collected" | awk '{print $1}' | sed 's/[^0-9]//g') + echo "PYTHON_TEST_COUNT=$PYTHON_TEST_COUNT" >> $GITHUB_ENV + + - name: Count NPM tests + run: | + JS_TEST_COUNT=$(npx vitest run --no-color | grep 'Tests *[0-9]* passed ([0-9]*)' | awk '{print $2}' | sed 's/[^0-9]*//g') + echo "JS_TEST_COUNT=$JS_TEST_COUNT" >> $GITHUB_ENV + working-directory: ./app/web_ui + + - name: Calculate total test count + run: | + TOTAL_TEST_COUNT=$((PYTHON_TEST_COUNT + JS_TEST_COUNT)) + echo "TOTAL_TEST_COUNT=$TOTAL_TEST_COUNT" >> $GITHUB_ENV + + - name: Create test count badge + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: 57742c1b1b60d597a6aba5d5148d728e + filename: test_count_kiln.json + label: Test Count + message: ${{ env.TOTAL_TEST_COUNT }} + color: brightgreen diff --git a/.gitignore b/.gitignore index 99a234b..3a529df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Byte-compiled / optimized / DLL files .env +.act_secrets __pycache__/ *.py[cod] *$py.class diff --git a/README.md b/README.md index 77859e2..7d9d2f3 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ Coming soon... -| | | -| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| CI | [![Build and Test](https://github.com/Kiln-AI/kiln/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/build_and_test.yml) [![Format and Lint](https://github.com/Kiln-AI/kiln/actions/workflows/format_and_lint.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/format_and_lint.yml) [![Desktop Apps Build](https://github.com/Kiln-AI/kiln/actions/workflows/build_desktop.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/build_desktop.yml) [![Web UI Build](https://github.com/Kiln-AI/kiln/actions/workflows/web_format_lint_build.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/web_format_lint_build.yml) | -| Package | [![PyPI - Version](https://img.shields.io/pypi/v/kiln-ai.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.org/project/kiln-ai/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kiln-ai.svg?logo=python&label=Python&logoColor=gold)](https://pypi.org/project/kiln-ai/) | -| Meta | [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/) [![types - Mypy](https://img.shields.io/badge/types-pyright-blue.svg)](https://github.com/microsoft/pyright) | +| | | +| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| CI | [![Build and Test](https://github.com/Kiln-AI/kiln/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/build_and_test.yml) [![Format and Lint](https://github.com/Kiln-AI/kiln/actions/workflows/format_and_lint.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/format_and_lint.yml) [![Desktop Apps Build](https://github.com/Kiln-AI/kiln/actions/workflows/build_desktop.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/build_desktop.yml) [![Web UI Build](https://github.com/Kiln-AI/kiln/actions/workflows/web_format_lint_build.yml/badge.svg)](https://github.com/Kiln-AI/kiln/actions/workflows/web_format_lint_build.yml) ![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/scosman/57742c1b1b60d597a6aba5d5148d728e/raw/test_count_kiln.json) | +| Package | [![PyPI - Version](https://img.shields.io/pypi/v/kiln-ai.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.org/project/kiln-ai/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kiln-ai.svg?logo=python&label=Python&logoColor=gold)](https://pypi.org/project/kiln-ai/) | +| Meta | [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/) [![types - Mypy](https://img.shields.io/badge/types-pyright-blue.svg)](https://github.com/microsoft/pyright) | ## Development