From 5c6d0293446967e6687d77b11debf5f24cccc9bb Mon Sep 17 00:00:00 2001 From: David Dai Date: Sun, 25 Aug 2024 22:59:48 +0800 Subject: [PATCH] Add coverage badge & use short sha for docker tag --- .github/workflows/build_docker.yml | 10 ++++++++-- .github/workflows/unit_test.yml | 9 ++++++--- Makefile | 6 +++--- README.md | 2 ++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index c361542..978d190 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -20,6 +20,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + + - name: Get short SHA + uses: benjlevesque/short-sha@v3.0 + id: short-sha + with: + length: 7 - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -43,7 +49,7 @@ jobs: push: true tags: | ${{ env.GHCR_REPO }}:latest - ${{ env.GHCR_REPO }}:${{ github.sha }} + ${{ env.GHCR_REPO }}:${{ env.SHA }} cache-from: type=gha cache-to: type=gha,mode=max @@ -56,6 +62,6 @@ jobs: push: true tags: | ${{ env.GHCR_REPO }}:latest - ${{ env.GHCR_REPO }}:${{ github.sha }} + ${{ env.GHCR_REPO }}:${{ env.SHA }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index f7723eb..6de11fe 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -27,8 +27,11 @@ jobs: python -m pip install "pip<24.1" pip install -r requirements-full.txt pip install "sqlite-vec==0.1.1" + pip install pytest pytest-cov coverage codecov - name: Test with pytest run: | - pip install pytest pytest-cov coverage - coverage run -m pytest - coverage report --include="**/*.py" --omit="**/*_test.py" + pytest --cov + - name: Upload results to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/Makefile b/Makefile index d0eceb0..42dbe6e 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,6 @@ lint: @ruff check test: - coverage run -m pytest - coverage report --include="**/*.py" --omit="**/*_test.py" - @coverage html --include="**/*.py" --omit="**/*_test.py" + coverage run --source=. --omit="**/*_test.py,bots/mmbot.py,bots/telegram_bot.py" -m pytest + coverage report + @coverage html diff --git a/README.md b/README.md index 6509c23..3992d0d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # Beancount Bot +[![codecov](https://codecov.io/github/StdioA/beancount-bot/graph/badge.svg?token=PPEO1607AJ)](https://codecov.io/github/StdioA/beancount-bot) ![ghcr image size](https://ghcr-badge.egpl.dev/stdioa/beancount-bot/size?color=%2344cc11&tag=latest&label=image+size&trim=) + [中文文档](README_zh.md) A Beancount bot that allows for quick manual recording of simple transactions via IM software.