Files
discord-ollama/.github/workflows/coverage.yml
T
Jonathan SmoleyandGitHub 7583d6d179 Fix: Code Coverage Badge Failed (#196)
* switch coverage to codecov

* reset node, increment ver

* remove auto-pass job var

* remove coverage 'env' note

* set badge with new action

* add fqvn for action

* fix step name

* make badge commit explicit
2026-07-16 17:44:11 -07:00

75 lines
2.3 KiB
YAML

name: Coverage
run-name: Code Coverage
on:
pull_request:
branches:
- master
types: [opened, reopened]
permissions:
contents: write
concurrency:
group: coverage-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
Discord-Node-Coverage:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Set up Node Environment
uses: actions/setup-node@v4
with:
node-version: lts/jod
cache: npm
- name: Install Project Dependencies
run: npm install
- name: Create Environment Variables
run: |
touch .env
echo CLIENT_TOKEN = ${{ secrets.BOT_TOKEN }} >> .env
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
echo OLLAMA_PORT = ${{ secrets.OLLAMA_PORT }} >> .env
echo MODEL = ${{ secrets.MODEL }} >> .env
- name: Run tests with coverage
run: npm run coverage
- name: Generate coverage badge
uses: wjervis7/vitest-badge-action@v1.0.0
if: success() || failure()
with:
result-type: statements
badge-text: 'Coverage (Statements)'
badge-path: ./imgs/coverage.svg
upload-badge: false
- name: Check whether badge commit is already latest
id: badge-check
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened')
run: |
if [ "$(git log -1 --pretty=%s)" = "update with coverage badge" ]; then
echo "already_latest=true" >> $GITHUB_OUTPUT
else
echo "already_latest=false" >> $GITHUB_OUTPUT
fi
- name: Commit badge to PR branch
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') && steps.badge-check.outputs.already_latest != 'true'
uses: stefanzweifel/git-auto-commit-action@v7
with:
file_pattern: ./imgs/coverage.svg
commit_message: 'update with coverage badge'
branch: ${{ github.head_ref }}