mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2026-08-08 23:54:01 -04:00
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:
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user