Skip to content

Commit 52c4990

Browse files
Merge pull request #9 from Mipmipp/chore/test-coverage-badge
Chore/test coverage badge
2 parents 6cc1003 + 00578b2 commit 52c4990

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

.github/workflows/main.yml

+39
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
steps:
1616
- name: Checkout repository
1717
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0 # Esto es necesario para acceder al historial completo
1820

1921
- name: Set up Node.js
2022
uses: actions/setup-node@v2
@@ -26,3 +28,40 @@ jobs:
2628

2729
- name: Run tests
2830
run: npm run test:handler
31+
32+
- name: Install jq
33+
run: sudo apt-get install jq
34+
35+
- name: Generate coverage badge
36+
run: |
37+
COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
38+
echo "![Coverage](https://img.shields.io/badge/coverage-${COVERAGE}%25-brightgreen)" > coverage/coverage_badge.md
39+
40+
- name: Create and switch to a new branch
41+
run: |
42+
git checkout -b update-coverage-badge
43+
44+
- name: Update README with coverage badge
45+
run: |
46+
BADGE_CONTENT=$(cat coverage/coverage_badge.md)
47+
sed -i "s|!\[Coverage\](.*)|${BADGE_CONTENT}|" README.md
48+
49+
- name: Show repository information
50+
run: |
51+
echo "Current Repository: $(git remote -v)"
52+
53+
- name: Commit and push changes
54+
run: |
55+
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
56+
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
57+
git add README.md
58+
git commit -m "Update coverage badge"
59+
git push origin HEAD:update-coverage-badge
60+
61+
- name: Create Pull Request
62+
uses: peter-evans/create-pull-request@v3
63+
with:
64+
title: "Update coverage badge"
65+
body: "This PR updates the coverage badge in README."
66+
base: main
67+
head: update-coverage-badge

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "src/index.ts",
66
"scripts": {
77
"test:e2e": "cross-env NODE_ENV=automated_tests jest --testRegex='.*\\.e2e\\.spec\\.ts$'",
8-
"test:handler": "cross-env NODE_ENV=automated_tests jest --testRegex='.*\\.handler\\.spec\\.ts$' --coverage",
8+
"test:handler": "cross-env NODE_ENV=automated_tests jest --testRegex='.*\\.handler\\.spec\\.ts$' --coverage --coverageReporters=json-summary",
99
"prebuild": "del /q dist",
1010
"create-package": "node -e \"require('fs').writeFileSync('temp-dependencies-layer/package.json', JSON.stringify({ name: 'temp-dependencies-layer', version: '1.0.0', dependencies: {} }))\"",
1111
"build:index": "esbuild src/index.ts --banner:js=\"/* global handler */\" --bundle --minify --sourcemap --platform=node --target=es2020 --outdir=temp-index",

0 commit comments

Comments
 (0)