From 067c20cfeea3b43a8d0cf8ff0e7fcb4778446716 Mon Sep 17 00:00:00 2001 From: Mipmipp Date: Mon, 7 Oct 2024 22:32:49 -0300 Subject: [PATCH 1/7] Update run test:handler to save cov --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4980c53..1473a3c 100644 --- a/package.json +++ b/package.json @@ -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", From eedf88871979b55ffa1644468b0533311ce81719 Mon Sep 17 00:00:00 2001 From: Mipmipp Date: Mon, 7 Oct 2024 22:33:26 -0300 Subject: [PATCH 2/7] Update CI/CD --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 35bc1ac..901bba7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,3 +26,26 @@ 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: Update README with coverage badge + run: | + BADGE_CONTENT=$(cat coverage/coverage_badge.md) + sed -i "s|!\[Coverage\](.*)|${BADGE_CONTENT}|" README.md + + - 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 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7961ffc162b2ca719e78c26d8b6d825d8a30f5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Hernando?= <106466126+Mipmipp@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:37:33 -0300 Subject: [PATCH 3/7] Create README.md --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..5e0b3e3 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +![Coverage](https://img.shields.io/badge/coverage-%25-brightgreen) From 0276dd636876ea9ef561904bdee8101ec24bc49e Mon Sep 17 00:00:00 2001 From: Mipmipp Date: Mon, 7 Oct 2024 22:39:48 -0300 Subject: [PATCH 4/7] Update CI/CD --- .github/workflows/main.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 901bba7..126ac95 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up Node.js uses: actions/setup-node@v2 @@ -35,6 +37,10 @@ jobs: 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) @@ -46,6 +52,14 @@ jobs: git config --local user.name "${{ secrets.GIT_USER_NAME }}" git add README.md git commit -m "Update coverage badge" - git push + git push origin update-coverage-badge env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - 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 From 90af746714ca9e8ff614f36527146bb7320da59b Mon Sep 17 00:00:00 2001 From: Mipmipp Date: Mon, 7 Oct 2024 22:42:29 -0300 Subject: [PATCH 5/7] Update CI/CD --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 126ac95..ee79e9d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,8 @@ jobs: git config --local user.name "${{ secrets.GIT_USER_NAME }}" git add README.md git commit -m "Update coverage badge" - git push origin update-coverage-badge + git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/OWNER/REPO.git HEAD:update-coverage-badge + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a6a01b6e4c5b35372f30b8d89e6c7316df0fdffb Mon Sep 17 00:00:00 2001 From: Mipmipp Date: Mon, 7 Oct 2024 22:44:18 -0300 Subject: [PATCH 6/7] Update CI/CD --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee79e9d..209315b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 with: - fetch-depth: 0 + fetch-depth: 0 # Esto es necesario para acceder al historial completo - name: Set up Node.js uses: actions/setup-node@v2 @@ -46,16 +46,17 @@ jobs: 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 https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/OWNER/REPO.git HEAD:update-coverage-badge - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/Mipmipp/localstack-ts-api-gateway-lambda-dynamodb-crud-example.git HEAD:update-coverage-badge - name: Create Pull Request uses: peter-evans/create-pull-request@v3 From 00578b2b83b4de32e11092d41f1075e7f1d9db70 Mon Sep 17 00:00:00 2001 From: Mipmipp Date: Mon, 7 Oct 2024 22:45:41 -0300 Subject: [PATCH 7/7] Update CI/CD --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 209315b..8e1eb13 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: git config --local user.name "${{ secrets.GIT_USER_NAME }}" git add README.md git commit -m "Update coverage badge" - git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/Mipmipp/localstack-ts-api-gateway-lambda-dynamodb-crud-example.git HEAD:update-coverage-badge + git push origin HEAD:update-coverage-badge - name: Create Pull Request uses: peter-evans/create-pull-request@v3