Skip to content

Chore/test coverage badge #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Esto es necesario para acceder al historial completo

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

- name: Run tests
run: npm run test:handler

- name: Install jq
run: sudo apt-get install jq

- name: Generate coverage badge
run: |
COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
echo "![Coverage](https://img.shields.io/badge/coverage-${COVERAGE}%25-brightgreen)" > coverage/coverage_badge.md

- name: Create and switch to a new branch
run: |
git checkout -b update-coverage-badge

- name: Update README with coverage badge
run: |
BADGE_CONTENT=$(cat coverage/coverage_badge.md)
sed -i "s|!\[Coverage\](.*)|${BADGE_CONTENT}|" README.md

- name: Show repository information
run: |
echo "Current Repository: $(git remote -v)"

- name: Commit and push changes
run: |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}"
git config --local user.name "${{ secrets.GIT_USER_NAME }}"
git add README.md
git commit -m "Update coverage badge"
git push origin HEAD:update-coverage-badge

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
title: "Update coverage badge"
body: "This PR updates the coverage badge in README."
base: main
head: update-coverage-badge
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![Coverage](https://img.shields.io/badge/coverage-<valor_dinámico>%25-brightgreen)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/index.ts",
"scripts": {
"test:e2e": "cross-env NODE_ENV=automated_tests jest --testRegex='.*\\.e2e\\.spec\\.ts$'",
"test:handler": "cross-env NODE_ENV=automated_tests jest --testRegex='.*\\.handler\\.spec\\.ts$' --coverage",
"test:handler": "cross-env NODE_ENV=automated_tests jest --testRegex='.*\\.handler\\.spec\\.ts$' --coverage --coverageReporters=json-summary",
"prebuild": "del /q dist",
"create-package": "node -e \"require('fs').writeFileSync('temp-dependencies-layer/package.json', JSON.stringify({ name: 'temp-dependencies-layer', version: '1.0.0', dependencies: {} }))\"",
"build:index": "esbuild src/index.ts --banner:js=\"/* global handler */\" --bundle --minify --sourcemap --platform=node --target=es2020 --outdir=temp-index",
Expand Down
Loading