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
This commit is contained in:
Jonathan Smoley
2026-07-16 17:44:11 -07:00
committed by GitHub
parent 4aadea4611
commit 7583d6d179
10 changed files with 549 additions and 424 deletions
+6 -4
View File
@@ -1,5 +1,6 @@
name: Builds
run-name: Validate Node and Docker Builds
on:
push:
branches:
@@ -9,15 +10,16 @@ jobs:
Discord-Node-Build: # test if the node install and run
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Node Environment lts/jod
- name: Set up Node Environment
uses: actions/setup-node@v4
with:
node-version: lts/jod
cache: "npm"
cache: npm
- name: Install Project Dependencies
run: |
@@ -48,11 +50,11 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Node Environment lts/jod
- name: Set up Node Environment
uses: actions/setup-node@v4
with:
node-version: lts/jod
cache: "npm"
cache: npm
- name: Create Environment Variables
run: |
+45 -21
View File
@@ -1,28 +1,39 @@
name: Coverage
run-name: Code Coverage
on:
push:
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
environment: coverage
timeout-minutes: 2
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Set up Node Environment lts/jod
- name: Set up Node Environment
uses: actions/setup-node@v4
with:
node-version: lts/jod
cache: "npm"
cache: npm
- name: Install Project Dependencies
run: |
npm install
run: npm install
- name: Create Environment Variables
run: |
@@ -32,19 +43,32 @@ jobs:
echo OLLAMA_PORT = ${{ secrets.OLLAMA_PORT }} >> .env
echo MODEL = ${{ secrets.MODEL }} >> .env
- name: Collect Code Coverage
run: |
LINE_PCT=$(npm run coverage | tail -2 | head -1 | awk '{print $3}')
echo "COVERAGE=$LINE_PCT" >> $GITHUB_ENV
- name: Upload Code Coverage
uses: schneegans/dynamic-badges-action@v1.7.0
- 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:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ vars.GIST_ID }}
filename: coverage.json
label: Coverage
message: ${{ env.COVERAGE }}
valColorRange: ${{ env.COVERAGE }}
maxColorRange: 100
minColorRange: 0
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 }}
+3 -5
View File
@@ -1,9 +1,6 @@
name: Deploy
run-name: Deploy Application Latest
# on:
# push:
# tags:
# - 'v*'
on: workflow_dispatch
jobs:
@@ -11,6 +8,7 @@ jobs:
runs-on: self-hosted
environment: deploy
timeout-minutes: 5
steps:
- name: Checkout Repo
uses: actions/checkout@v4
@@ -40,7 +38,7 @@ jobs:
git clone https://github.com/kevinthedang/discord-ollama.git ${{ secrets.PATH }}
cd ${{ secrets.PATH }}
- name: Install nvm and Node.js lts/jod
- name: Install nvm and Node.js
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
+4 -2
View File
@@ -1,5 +1,6 @@
name: Tests
run-name: Unit Tests
on:
pull_request:
branches:
@@ -21,15 +22,16 @@ jobs:
Discord-Node-Test:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Node Environment lts/jod
- name: Set up Node Environment
uses: actions/setup-node@v4
with:
node-version: lts/jod
cache: "npm"
cache: npm
- name: Install Project Dependencies
run: |