Skip to content

Commit

Permalink
Update workflow permissions and badges
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicasyu committed Aug 18, 2023
1 parent 8522c50 commit 70a0857
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 9 deletions.
62 changes: 56 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,61 @@ jobs:
- name: Test with pytest
run: |
source .venv/bin/activate
pytest --cov-report xml --cov=src/ tests/
pytest --cov-report html --cov=src/ tests/
rm htmlcov/.gitignore
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
- name: Publish coverage report
if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.10' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
verbose: true
branch: gh-pages
folder: htmlcov
target-folder: _coverage

- name: Extract coverage percent
if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.10' }}
run: |
echo "COVERAGE=$(grep -oP 'pc_cov">\K([0-9]+)' htmlcov/index.html)" >> $GITHUB_ENV
- name: Generate coverage badge
if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.10' }}
uses: knightdave/[email protected]
with:
file: docs/_badges/coverage.svg
label: coverage
value: ${{ env.COVERAGE }}
value_format: "%d%%"
anybadge_args: 50=red 60=orange 80=yellow 100=green
template: docs/_badges/template.svg
overwrite: true

- name: Generate passing badge
if: success()
uses: knightdave/[email protected]
with:
file: docs/_badges/build.svg
label: build
value: passing
color: green
template: docs/_badges/template.svg
overwrite: true

- name: Generate failing badge
if: failure()
uses: knightdave/[email protected]
with:
file: docs/_badges/build.svg
label: build
value: failing
color: red
template: docs/_badges/template.svg
overwrite: true

- name: Publish badge
if: success() || failure()
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_badges
target-folder: _badges
clean: false
60 changes: 59 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,62 @@ jobs:
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_build/html/
folder: docs/_build/html
clean-exclude: |
_badges
_coverage
- name: Generate style badge
uses: knightdave/[email protected]
with:
file: docs/_badges/style.svg
label: code style
value: black
color: black
template: docs/_badges/template.svg
overwrite: true

- name: Extract license
run: |
echo "LICENSE=$(grep -oP 'license = "\K([A-z-0-9]+)(?=")' pyproject.toml)" >> $GITHUB_ENV
- name: Generate license badge
uses: knightdave/[email protected]
with:
file: docs/_badges/license.svg
label: license
value: ${{ env.LICENSE }}
color: yellowgreen
template: docs/_badges/template.svg
overwrite: true

- name: Generate passing badge
if: success()
uses: knightdave/[email protected]
with:
file: docs/_badges/documentation.svg
label: docs
value: passing
color: green
template: docs/_badges/template.svg
overwrite: true

- name: Generate failing badge
if: failure()
uses: knightdave/[email protected]
with:
file: docs/_badges/documentation.svg
label: docs
value: failing
color: red
template: docs/_badges/template.svg
overwrite: true

- name: Publish badge
if: success() || failure()
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_badges
target-folder: _badges
clean: false
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,34 @@ jobs:
run: |
source .venv/bin/activate
mypy src
- name: Generate passing badge
if: success()
uses: knightdave/[email protected]
with:
file: docs/_badges/lint.svg
label: lint
value: passing
color: green
template: docs/_badges/template.svg
overwrite: true

- name: Generate failing badge
if: failure()
uses: knightdave/[email protected]
with:
file: docs/_badges/lint.svg
label: lint
value: failing
color: red
template: docs/_badges/template.svg
overwrite: true

- name: Publish badge
if: success() || failure()
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs/_badges
target-folder: _badges
clean: false
26 changes: 24 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:

runs-on: ubuntu-latest

permissions:
id-token: write
contents: write
pull-requests: read

steps:

- name: Checkout the repo
Expand Down Expand Up @@ -65,7 +70,6 @@ jobs:
tag: ${{ env.RELEASE_VERSION }}
name: ${{ env.RELEASE_VERSION }}
body: ${{ steps.build_changelog.outputs.changelog }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python 3.9
uses: actions/setup-python@v4
Expand All @@ -84,5 +88,23 @@ jobs:
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1

- name: Generate version badge
if: success()
uses: knightdave/[email protected]
with:
file: docs/_badges/version.svg
label: version
value: ${{ env.RELEASE_VERSION }}
color: teal
template: docs/_badges/template.svg
overwrite: true

- name: Publish badge
if: success()
uses: JamesIves/github-pages-deploy-action@v4
with:
password: ${{ secrets.PYPI_TOKEN }}
branch: gh-pages
folder: docs/_badges
target-folder: _badges
clean: false
11 changes: 11 additions & 0 deletions docs/_badges/template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 70a0857

Please sign in to comment.