github README中添加徽章

  1. 静态标签
  2. Github Actions 徽章
  3. 代码测试覆盖率标签

README.md中添加徽章的方法

静态标签

大部分标签可以再shields.io中找到并直接使用

Github Actions 徽章

https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW_FILE>/badge.svg

代码测试覆盖率标签

使用codecov

注册授权后,选择仓库,将TOKEN复制到GithubSecrets中。

name: Coverage upload to Codecov

on: push: branches: - master
jobs: coverage: runs-on: ubuntu-latest
steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v4 with: python-version: "3.x" - name: Install Dependencies run: | python -m pip install --upgrade pip pip install poetry poetry install - name: Run Pytest Coverage run: | poetry run python -m pytest --cov --cov-report xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml flags: unittests

pull后等待action 上传 coverage.xml文件到codecov

然后到codecovsettings/badge中选择markdown,复制到README.md中。


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 365433079@qq.com