Skip to content

Commit 09a4c51

Browse files
authored
Merge pull request #537 from LerianStudio/release-candidate
refactor: running /ring:dev-refactor on Reporter
2 parents 9f79f17 + 2c4fc28 commit 09a4c51

File tree

324 files changed

+48787
-11047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+48787
-11047
lines changed

.dockerignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.git
2+
.github
3+
docs/
4+
tests/
5+
reports/
6+
artifacts/
7+
*.md
8+
.env*
9+
.idea
10+
.vscode
11+
.DS_Store
12+
coverage.*
13+
.golangci.yml
14+
scripts/
15+
mk/

.githooks/commit-msg

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,43 @@
11
#!/bin/sh
22
#
3-
# Add a specific emoji to the end of the first line in every commit message
4-
# based on the conventional commits keyword.
3+
# Validate commit message format (conventional commits) and add a specific
4+
# emoji to the end of the first line based on the keyword.
55

66
if [ ! -f "$1" ] || grep -q "fixup!" "$1"; then
77
# Exit if we didn't get a target file for some reason
88
# or we have a fixup commit
99
exit 0
1010
fi
1111

12-
KEYWORD=$(head -n 1 "$1" | awk '{print $1}' | sed -e 's/://')
12+
# Read the first line of the commit message
13+
FIRST_LINE=$(head -n 1 "$1")
14+
15+
# Allow merge commits without further validation
16+
if echo "$FIRST_LINE" | grep -qE "^Merge "; then
17+
exit 0
18+
fi
19+
20+
# Validate conventional commit format
21+
# Format: type(optional-scope): description
22+
commit_msg_regex="^(feat|fix|refactor|style|test|docs|build|chore|ci|perf|revert)(\(.{1,20}\))?: (.{1,100})$"
23+
24+
if ! echo "$FIRST_LINE" | grep -qE "$commit_msg_regex"; then
25+
echo "ERROR: Invalid commit message format." >&2
26+
echo "" >&2
27+
echo " Got: $FIRST_LINE" >&2
28+
echo "" >&2
29+
echo " Expected format: type(scope): description" >&2
30+
echo " Valid types: feat, fix, refactor, style, test, docs, build, chore, ci, perf, revert" >&2
31+
echo " Scope is optional, max 20 chars. Description max 100 chars." >&2
32+
echo "" >&2
33+
echo " Examples:" >&2
34+
echo " feat: add report generation endpoint" >&2
35+
echo " fix(worker): handle nil template gracefully" >&2
36+
echo " chore: update dependencies" >&2
37+
exit 1
38+
fi
39+
40+
KEYWORD=$(echo "$FIRST_LINE" | awk '{print $1}' | sed -e 's/://')
1341

1442
case $KEYWORD in
1543
"feat"|"feat("*)
@@ -42,6 +70,9 @@ case $KEYWORD in
4270
"chore"|"chore("*)
4371
EMOJI=":wrench:"
4472
;;
73+
"revert"|"revert("*)
74+
EMOJI=":rewind:"
75+
;;
4576
*)
4677
EMOJI=""
4778
;;

.githooks/pre-commit

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,22 @@ if [[ $branch == "main" || $branch == "develop" || $branch == release/* ]]; then
1010
exit 1
1111
fi
1212

13-
commit_msg_type_regex='feature|fix|refactor|style|test|docs|build'
14-
commit_msg_scope_regex='.{1,20}'
15-
commit_msg_description_regex='.{1,100}'
16-
commit_msg_regex="^(${commit_msg_type_regex})(\(${commit_msg_scope_regex}\))?: (${commit_msg_description_regex})\$"
17-
merge_msg_regex="^Merge branch '.+'\$"
18-
19-
zero_commit="0000000000000000000000000000000000000000"
20-
21-
# Do not traverse over commits that are already in the repository
22-
excludeExisting="--not --all"
23-
24-
error=""
25-
while read oldrev newrev refname; do
26-
# branch or tag get deleted
27-
if [ "$newrev" = "$zero_commit" ]; then
28-
continue
29-
fi
30-
31-
# Check for new branch or tag
32-
if [ "$oldrev" = "$zero_commit" ]; then
33-
rev_span=$(git rev-list $newrev $excludeExisting)
34-
else
35-
rev_span=$(git rev-list $oldrev..$newrev $excludeExisting)
36-
fi
37-
38-
for commit in $rev_span; do
39-
commit_msg_header=$(git show -s --format=%s $commit)
40-
if ! [[ "$commit_msg_header" =~ (${commit_msg_regex})|(${merge_msg_regex}) ]]; then
41-
echo "$commit" >&2
42-
echo "ERROR: Invalid commit message format" >&2
43-
echo "$commit_msg_header" >&2
44-
error="true"
45-
fi
46-
done
47-
done
13+
# Block .env files from being committed
14+
env_files=$(git diff --cached --name-only | grep -E '\.env($|\.)')
15+
if [[ -n "$env_files" ]]; then
16+
echo "${bold}Blocked: .env files must not be committed:${normal}"
17+
echo "$env_files"
18+
exit 1
19+
fi
4820

49-
if [ -n "$error" ]; then
21+
# Run gofmt on staged .go files
22+
staged_go_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$')
23+
if [[ -n "$staged_go_files" ]]; then
24+
unformatted=$(echo "$staged_go_files" | xargs gofmt -l 2>/dev/null)
25+
if [[ -n "$unformatted" ]]; then
26+
echo "${bold}The following Go files need formatting (gofmt):${normal}"
27+
echo "$unformatted"
28+
echo "Run: gofmt -w <file>"
5029
exit 1
30+
fi
5131
fi

.githooks/pre-push

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@
33
source "$PWD"/pkg/shell/colors.sh
44
source "$PWD"/pkg/shell/ascii.sh
55

6+
# Block force-push to protected branches and enforce branch naming
7+
protected_branches="main develop release-candidate"
8+
69
while read local_ref local_sha remote_ref remote_sha; do
10+
# Detect force-push: remote_sha is not ancestor of local_sha (and neither is zero)
11+
if [[ "$remote_sha" != "0000000000000000000000000000000000000000" ]] && [[ "$local_sha" != "0000000000000000000000000000000000000000" ]]; then
12+
remote_branch=$(echo "$remote_ref" | sed 's|^refs/heads/||')
13+
for protected in $protected_branches; do
14+
if [[ "$remote_branch" == "$protected" ]]; then
15+
if ! git merge-base --is-ancestor "$remote_sha" "$local_sha" 2>/dev/null; then
16+
echo "${bold}Force-push to protected branch '$protected' is blocked."
17+
exit 1
18+
fi
19+
fi
20+
done
21+
fi
22+
723
if [[ "$local_ref" =~ ^refs/heads/ ]]; then
824
branch_name=$(echo "$local_ref" | sed 's|^refs/heads/||')
925

.github/workflows/build.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515

1616
jobs:
1717
build:
18-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/build.yml@v1.10.2
18+
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/build.yml@v1.11.0
1919
with:
2020
runner_type: "blacksmith-4vcpu-ubuntu-2404"
2121
# Monorepo configuration
@@ -42,16 +42,20 @@ jobs:
4242
# =========================
4343
update_gitops:
4444
needs: [build]
45-
if: (contains(github.ref, '-beta') || contains(github.ref, '-rc')) && needs.build.result == 'success'
46-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/gitops-update.yml@v1.10.2
45+
if: needs.build.result == 'success'
46+
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/gitops-update.yml@v1.11.0
4747
with:
4848
runner_type: "firmino-lxc-runners"
4949
gitops_repository: "LerianStudio/midaz-firmino-gitops"
5050
gitops_server: "firmino"
5151
app_name: "reporter"
5252
artifact_pattern: "gitops-tags-reporter-*"
53-
yaml_key_mappings: '{"manager.tag": ".manager.image.tag", "worker.tag": ".worker.image.tag"}'
54-
configmap_updates: '{"manager.tag": ".manager.configmap.VERSION", "worker.tag": ".worker.configmap.VERSION"}'
53+
gitops_file_dev: "gitops/environments/firmino/helmfile/applications/dev/reporter/values.yaml"
54+
gitops_file_stg: "gitops/environments/firmino/helmfile/applications/stg/reporter/values.yaml"
55+
gitops_file_prd: "gitops/environments/firmino/helmfile/applications/prd/reporter/values.yaml"
56+
gitops_file_sandbox: "gitops/environments/firmino/helmfile/applications/sandbox/reporter/values.yaml"
57+
yaml_key_mappings: '{"reporter-manager.tag": ".manager.image.tag", "reporter-worker.tag": ".worker.image.tag"}'
58+
configmap_updates: '{"reporter-manager.tag": ".manager.configmap.VERSION", "reporter-worker.tag": ".worker.configmap.VERSION"}'
5559
commit_message_prefix: "reporter"
5660
enable_argocd_sync: true
5761
argocd_app_name: "firmino-reporter"
@@ -61,15 +65,15 @@ jobs:
6165
# =========================
6266
# E2E TESTS
6367
# =========================
64-
api-dog-e2e-tests:
65-
needs: update_gitops
66-
if: (contains(github.ref, '-beta') || contains(github.ref, '-rc')) && needs.update_gitops.result == 'success'
67-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/api-dog-e2e-tests.yml@v1.10.2
68-
with:
69-
runner_type: "firmino-lxc-runners"
70-
auto_detect_environment: true
71-
secrets:
72-
test_scenario_id: ${{ secrets.REPORTER_APIDOG_TEST_SCENARIO_ID }}
73-
apidog_access_token: ${{ secrets.APIDOG_ACCESS_TOKEN }}
74-
dev_environment_id: ${{ secrets.REPORTER_APIDOG_DEV_ENVIRONMENT_ID }}
75-
stg_environment_id: ${{ secrets.REPORTER_APIDOG_STG_ENVIRONMENT_ID }}
68+
# api-dog-e2e-tests:
69+
# needs: [update_gitops]
70+
# if: needs.update_gitops.result == 'success'
71+
# uses: LerianStudio/github-actions-shared-workflows/.github/workflows/api-dog-e2e-tests.yml@v1.11.0
72+
# with:
73+
# runner_type: "firmino-lxc-runners"
74+
# auto_detect_environment: true
75+
# secrets:
76+
# test_scenario_id: ${{ secrets.REPORTER_APIDOG_TEST_SCENARIO_ID }}
77+
# apidog_access_token: ${{ secrets.APIDOG_ACCESS_TOKEN }}
78+
# dev_environment_id: ${{ secrets.REPORTER_APIDOG_DEV_ENVIRONMENT_ID }}
79+
# stg_environment_id: ${{ secrets.REPORTER_APIDOG_STG_ENVIRONMENT_ID }}

.github/workflows/go-combined-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ on:
2525
jobs:
2626
go-analysis:
2727
name: Go Analysis
28-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-pr-analysis.yml@v1.3.5
28+
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-pr-analysis.yml@v1.11.0
2929
with:
3030
runner_type: "blacksmith-4vcpu-ubuntu-2404"
3131
filter_paths: '["components/manager", "components/worker"]'

.github/workflows/gptchangelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
changelog:
2424
# Run if: manual trigger OR Release workflow succeeded
2525
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
26-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/gptchangelog.yml@v1.10.2
26+
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/gptchangelog.yml@v1.11.0
2727
with:
2828
runner_type: "blacksmith-4vcpu-ubuntu-2404"
2929
# No filter_paths = single app mode (non-monorepo)

.github/workflows/pr-security-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727

2828
jobs:
2929
security-scan:
30-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/pr-security-scan.yml@v1.3.5
30+
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/pr-security-scan.yml@v1.11.0
3131
with:
3232
runner_type: "blacksmith-4vcpu-ubuntu-2404"
3333
filter_paths: |-

.github/workflows/pr-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212

1313
jobs:
1414
validate:
15-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/pr-validation.yml@v1.3.5
15+
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/pr-validation.yml@v1.11.0
1616
with:
1717
runner_type: "blacksmith-4vcpu-ubuntu-2404"
1818
pr_title_types: |

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# =========================
2323
release:
2424
name: Create Release
25-
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/release.yml@v1.10.2
25+
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/release.yml@v1.11.0
2626
with:
2727
runner_type: "blacksmith-4vcpu-ubuntu-2404"
2828
secrets: inherit

0 commit comments

Comments
 (0)