Skip to content
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
44 changes: 36 additions & 8 deletions .github/workflows/gitflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- "release/*"
- "feature/*"
- "hotfix/*"
- "bugfix/*"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -44,7 +45,7 @@ jobs:
else
# Create the pull request
PR_URL=$(gh pr create \
--label "GitFlow" \
--label "gitflow" \
--base develop \
--head "$MAIN_BRANCH" \
--title "Sync $MAIN_BRANCH to develop" \
Expand All @@ -58,6 +59,7 @@ jobs:
gh pr merge "$PR_NUMBER" --merge --auto
fi


# Release to Main
- name: Create Pull Request for Release to Main
if: github.ref_name && startsWith(github.ref, 'refs/heads/release/')
Expand All @@ -76,13 +78,14 @@ jobs:
echo "PR from $RELEASE_BRANCH to develop already exists (open, closed, or merged). Skipping."
else
gh pr create \
--label "GitFlow" \
--label "gitflow" \
--base main \
--head "$RELEASE_BRANCH" \
--title "Merge $RELEASE_BRANCH into Main" \
--body "$PR_BODY"
fi


# Feature to Develop
- name: Create Pull Request for Feature to Develop
if: github.ref_name && startsWith(github.ref, 'refs/heads/feature/')
Expand All @@ -101,12 +104,37 @@ jobs:
echo "PR from $FEATURE_BRANCH to develop already exists (open, closed, or merged). Skipping."
else
gh pr create \
--label "GitFlow" \
--label "gitflow" \
--base develop \
--head "$FEATURE_BRANCH" \
--title "Feature: Merge $FEATURE_BRANCH into Develop" \
--body "$PR_BODY"
fi


# Bugfix to Develop
- name: Create Pull Request for Bugfix to Develop
if: github.ref_name && startsWith(github.ref, 'refs/heads/bugfix/')
run: |
# Extract branch name
BUGFIX_BRANCH=$(echo "${{ github.ref }}" | sed 's|refs/heads/||')

PR_DESCRIPTION="This Pull Request merges the hotfix branch '$BUGFIX_BRANCH' into 'develop'."
PR_BODY=$(cat .github/PULL_REQUEST_TEMPLATE/hotfix_bugfix.md)
PR_BODY=$(echo "$PR_BODY" | sed "s|\$PR_DESCRIPTION|$PR_DESCRIPTION|g")

# PR for bugfix to develop
if gh pr list --base develop --head "$BUGFIX_BRANCH" --json id | grep -q id; then
echo "PR from $HOTFIX_BRANCH to develop already exists. Skipping."
else
gh pr create \
--label "gitflow" \
--base develop \
--head "$BUGFIX_BRANCH" \
--title "Bugfix: Merge $$BUGFIX_BRANCH into Develop" \
--body "$PR_BODY"
fi


# Hotfix to Main and Develop
- name: Create Pull Request for Hotfix to Main and Develop
Expand All @@ -116,7 +144,7 @@ jobs:
HOTFIX_BRANCH=$(echo "${{ github.ref }}" | sed 's|refs/heads/||')

PR_DESCRIPTION="This Pull Request merges the hotfix branch '$HOTFIX_BRANCH' into 'main'. Fixes critical issues in **production**."
PR_BODY=$(cat .github/PULL_REQUEST_TEMPLATE/hotfix.md)
PR_BODY=$(cat .github/PULL_REQUEST_TEMPLATE/hotfix_bugfix.md)
PR_BODY=$(echo "$PR_BODY" | sed "s|\$PR_DESCRIPTION|$PR_DESCRIPTION|g")

# Check if PR already exists (open, closed, or merged)
Expand All @@ -126,26 +154,26 @@ jobs:
echo "PR from $HOTFIX_BRANCH to main already exists (open, closed, or merged). Skipping."
else
gh pr create \
--label "GitFlow" \
--label "gitflow" \
--base main \
--head "$HOTFIX_BRANCH" \
--title "Hotfix: Merge $HOTFIX_BRANCH into Main" \
--body "$PR_BODY"
fi

PR_DESCRIPTION="This Pull Request merges the hotfix branch '$HOTFIX_BRANCH' into 'develop'. Fixes critical issues in **production**."
PR_BODY=$(cat .github/PULL_REQUEST_TEMPLATE/hotfix.md)
PR_BODY=$(cat .github/PULL_REQUEST_TEMPLATE/hotfix_bugfix.md)
PR_BODY=$(echo "$PR_BODY" | sed "s|\$PR_DESCRIPTION|$PR_DESCRIPTION|g")

# PR for hotfix to develop
if gh pr list --base develop --head "$HOTFIX_BRANCH" --json id | grep -q id; then
echo "PR from $HOTFIX_BRANCH to develop already exists. Skipping."
else
gh pr create \
--label "GitFlow" \
--label "gitflow" \
--base develop \
--head "$HOTFIX_BRANCH" \
--title "Hotfix: Sync $HOTFIX_BRANCH with Develop" \
--title "Hotfix: Merge $HOTFIX_BRANCH into Develop" \
--body "$PR_BODY"
fi

Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,19 @@ jobs:
- name: Format
run: yarn format

- name: Build
run: yarn build

- name: Test
run: yarn test
run: yarn test:coverage

- name: Build
run: yarn build
- name: Create badges
if: contains(github.head_ref, 'release/') && contains(github.base_ref, 'main')
run: yarn readme:coverage

- name: Commit and push changes
if: contains(github.head_ref, 'release/') && contains(github.base_ref, 'main')
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.GH_PAT }}
commit_message: "docs: test coverage badges update"
9 changes: 9 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ npm run lint:fix
echo "Running format fix..."
npm run format:fix

echo "Running build..."
npm run build

echo "Running test coverage..."
npm run test:coverage

echo "Running readme coverage update..."
npm run readme:coverage

# shellcheck disable=SC2103
cd ..

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ test:
test-coverage:
docker compose -f yarn.cli.yml run --rm yarn test:coverage

# Run to update readme coverage
readme-coverage:
docker compose -f yarn.cli.yml run --rm yarn readme:coverage

# Updates all project libraries to their latest versions using Yarn,
# running in a container defined in the yarn.cli.yml file.
upgrade-lib:
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>


### Documentation available in languages

[![en](https://img.shields.io/badge/lang-en-blue.svg)](README.md)
[![pt-br](https://img.shields.io/badge/lang-pt--br-green.svg)](README.pt-br.md)

### Test Coverage

![Entrypoints](app/test/badges/entrypoints.svg)
![Core](app/test/badges/core.svg)
![Infrastructure](app/test/badges/infrastructure.svg)
![Shared](app/test/badges/shared.svg)

## Introduction

Expand Down
9 changes: 9 additions & 0 deletions README.pt-br.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
[![en](https://img.shields.io/badge/lang-en-blue.svg)](README.md)
[![pt-br](https://img.shields.io/badge/lang-pt--br-green.svg)](README.pt-br.md)


### Cobertura de teste

![Entrypoints](app/test/badges/entrypoints.svg)
![Core](app/test/badges/core.svg)
![Infrastructure](app/test/badges/infrastructure.svg)
![Shared](app/test/badges/shared.svg)


## Introdução

Este projeto foi desenvolvido com fins didáticos, visando explorar e aprofundar o conhecimento no framework **NestJS**.
Expand Down
Loading
Loading