Skip to content

Commit ac1b531

Browse files
authored
chore: add GA for branch naming convention (#352)
* chore: add GA for branch naming convention chore: add GA for sematical commit messages chore: add git message template * chore: add husky chore: add commit message template
1 parent ce3a18f commit ac1b531

10 files changed

Lines changed: 254 additions & 10 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Validate Branch Name
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened ]
6+
7+
jobs:
8+
check-branch-name:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check branch name format
12+
run: |
13+
BRANCH_NAME="${{ github.head_ref }}"
14+
echo "Checking branch name: $BRANCH_NAME"
15+
if [[ ! "$BRANCH_NAME" =~ ^(chore|feature|fix|hotfix|patch|refactor)/[a-z0-9._-]+$ ]]; then
16+
echo "❌ Invalid branch name: $BRANCH_NAME"
17+
echo "✅ Should match: feature/foo-bar, hotfix/issue-123, etc."
18+
exit 1
19+
fi
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Check Commit Messages
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lint-commits:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: wagoid/commitlint-github-action@v5

.gitmessage.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Conventional Commit template
2+
# Lines starting with # are ignored by Git.
3+
# Keep header ≤72 chars; subject in imperative mood.
4+
# Examples of <type>: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
5+
6+
<type>(<scope>): <subject>
7+
8+
# Why?
9+
# - What problem does this change solve?
10+
# - Why now / context?
11+
12+
# What changed?
13+
# - Key changes, trade-offs, alternatives considered
14+
# - Any user-facing behavior changes
15+
16+
# How was it tested?
17+
# - Test strategy, manual steps, screenshots if relevant
18+
19+
# Notes
20+
# - Known limitations, follow-ups, migrations
21+
22+
# Footer (one per line)
23+
# BREAKING CHANGE: <describe the breaking change and migration path>
24+
# Closes #123
25+
# Relates-to #456
26+
# Co-authored-by: Name <email>

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx commitlint --edit "$1"

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.19.4

Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ ARG XDEBUG_VERSION="xdebug-3.3.2"
77
ENV COMPOSER_ALLOW_SUPERUSER=1
88
ENV GITHUB_OAUTH_TOKEN=$GITHUB_OAUTH_TOKEN
99
ENV PHP_DIR /usr/local/etc/php
10+
ARG YARN_VERSION="1.22.22"
11+
ARG NVM_VERSION="v0.40.3"
12+
ARG NODE_VERSION="20.19.4"
1013

11-
ARG NVM_VERSION="v0.39.7"
12-
ARG NODE_VERSION="18.20.2"
1314
# base packages
1415
RUN apt-get update
1516
RUN apt-get install -y \
@@ -33,16 +34,18 @@ RUN apt-get install -y \
3334
libmagickwand-dev
3435

3536

36-
# nvm
3737

3838
# nvm + node + yarn via corepack
3939
ENV NVM_DIR=/root/.nvm
4040
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash
4141
# Install Node, enable Corepack (Yarn)
42-
RUN bash -lc "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && corepack enable && corepack prepare yarn@stable --activate"
43-
42+
RUN bash -lc "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && corepack enable && corepack prepare yarn@$YARN_VERSION --activate"
4443
RUN apt clean && rm -rf /var/lib/apt/lists/*
4544

45+
# Set up our PATH correctly so we don't have to long-reference npm, node, &c.
46+
ENV NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
47+
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
48+
4649
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4750

4851
RUN install-php-extensions bcmath exif gettext gd imagick mbstring openssl pcntl pdo pdo_mysql sockets ${XDEBUG_VERSION} zip apcu redis igbinary

commitlint.config.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
const WIP_REGEX = /^wip[:]?$/i;
2+
const RULE_ERROR_LEVEL = 2;
3+
const HEADER_MAX_LENGTH = 100;
4+
const SUBJECT_MIN_LENGTH = 5;
5+
6+
module.exports = {
7+
extends: ["@commitlint/config-conventional"],
8+
rules: {
9+
"custom-subject-empty": [RULE_ERROR_LEVEL, "never"],
10+
"custom-type-enum": [RULE_ERROR_LEVEL, "always"],
11+
"custom-no-wip": [RULE_ERROR_LEVEL, "always"],
12+
"custom-no-wip-subject": [RULE_ERROR_LEVEL, "always"],
13+
"subject-min-length": [RULE_ERROR_LEVEL, "always", SUBJECT_MIN_LENGTH],
14+
"subject-case": [0], // optional: allow flexibility in subject case
15+
"header-max-length": [RULE_ERROR_LEVEL, "always", HEADER_MAX_LENGTH]
16+
},
17+
plugins: [
18+
{
19+
rules: {
20+
"custom-subject-empty": ({ subject }) =>
21+
subject && subject.trim().length > 0
22+
? [true]
23+
: [
24+
false,
25+
"The commit needs a description after the colon (:). Eg: feat: add new feature"
26+
],
27+
"custom-type-enum": ({ type }) => {
28+
const allowedTypes = [
29+
"feat",
30+
"fix",
31+
"hotfix",
32+
"docs",
33+
"style",
34+
"refactor",
35+
"test",
36+
"chore"
37+
];
38+
39+
if (!type) {
40+
return [
41+
false,
42+
"Missing type. Use: feat, fix, chore, refactor, etc."
43+
];
44+
}
45+
46+
if (!allowedTypes.includes(type)) {
47+
return [
48+
false,
49+
`Type "${type} is invalid". Allowed types: ${allowedTypes.join(
50+
", "
51+
)}`
52+
];
53+
}
54+
55+
return [true];
56+
},
57+
"custom-no-wip": ({ header }) => {
58+
const isWipOnly = WIP_REGEX.test(header.trim());
59+
return [
60+
!isWipOnly,
61+
"Commit message cannot be just \"WIP\" (use a descriptive message)."
62+
];
63+
},
64+
"custom-no-wip-subject": ({ subject }) => {
65+
if (!subject) return [true];
66+
67+
const isWipOnly = WIP_REGEX.test(subject.trim());
68+
return [
69+
!isWipOnly,
70+
"Subject cannot be just \"WIP\". Use a descriptive message like \"implement user login\" instead."
71+
];
72+
}
73+
}
74+
}
75+
]
76+
};

gitmessage.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Conventional Commit template
2+
# Lines starting with # are ignored by Git.
3+
# Keep header ≤72 chars; subject in imperative mood.
4+
# Examples of <type>: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
5+
6+
<type>(<scope>): <subject>
7+
8+
# Why?
9+
# - What problem does this change solve?
10+
# - Why now / context?
11+
12+
# What changed?
13+
# - Key changes, trade-offs, alternatives considered
14+
# - Any user-facing behavior changes
15+
16+
# How was it tested?
17+
# - Test strategy, manual steps, screenshots if relevant
18+
19+
# Notes
20+
# - Known limitations, follow-ups, migrations
21+
22+
# Footer (one per line)
23+
# BREAKING CHANGE: <describe the breaking change and migration path>
24+
# Closes #123
25+
# Relates-to #456
26+
# Co-authored-by: Name <email>

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"private": true,
33
"scripts": {
44
"prod": "gulp --production",
5-
"dev": "gulp watch"
5+
"dev": "gulp watch",
6+
"prepare": "husky",
7+
"postinstall":"git config --local commit.template .gitmessage.txt || true"
68
},
79
"devDependencies": {
8-
"gulp": "^3.9.1",
9-
"laravel-elixir": "^5.0.0",
10-
"bootstrap-sass": "^3.3.0"
11-
}
10+
"@commitlint/config-conventional": "^19.8.1",
11+
"husky": "^9.0.11"
12+
},
13+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
1214
}

yarn.lock

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@commitlint/config-conventional@^19.8.1":
6+
version "19.8.1"
7+
resolved "https://registry.yarnpkg.com/@commitlint/config-conventional/-/config-conventional-19.8.1.tgz#eab42df58cda44f18410ae0cbd6785ece00f214b"
8+
integrity sha512-/AZHJL6F6B/G959CsMAzrPKKZjeEiAVifRyEwXxcT6qtqbPwGw+iQxmNS+Bu+i09OCtdNRW6pNpBvgPrtMr9EQ==
9+
dependencies:
10+
"@commitlint/types" "^19.8.1"
11+
conventional-changelog-conventionalcommits "^7.0.2"
12+
13+
"@commitlint/types@^19.8.1":
14+
version "19.8.1"
15+
resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-19.8.1.tgz#7971fbd56b0cfb31692a4e1941b74ac8217c44e5"
16+
integrity sha512-/yCrWGCoA1SVKOks25EGadP9Pnj0oAIHGpl2wH2M2Y46dPM2ueb8wyCVOD7O3WCTkaJ0IkKvzhl1JY7+uCT2Dw==
17+
dependencies:
18+
"@types/conventional-commits-parser" "^5.0.0"
19+
chalk "^5.3.0"
20+
21+
"@types/conventional-commits-parser@^5.0.0":
22+
version "5.0.1"
23+
resolved "https://registry.yarnpkg.com/@types/conventional-commits-parser/-/conventional-commits-parser-5.0.1.tgz#8cb81cf170853496cbc501a3b32dcf5e46ffb61a"
24+
integrity sha512-7uz5EHdzz2TqoMfV7ee61Egf5y6NkcO4FB/1iCCQnbeiI1F3xzv3vK5dBCXUCLQgGYS+mUeigK1iKQzvED+QnQ==
25+
dependencies:
26+
"@types/node" "*"
27+
28+
"@types/node@*":
29+
version "24.5.2"
30+
resolved "https://registry.yarnpkg.com/@types/node/-/node-24.5.2.tgz#52ceb83f50fe0fcfdfbd2a9fab6db2e9e7ef6446"
31+
integrity sha512-FYxk1I7wPv3K2XBaoyH2cTnocQEu8AOZ60hPbsyukMPLv5/5qr7V1i8PLHdl6Zf87I+xZXFvPCXYjiTFq+YSDQ==
32+
dependencies:
33+
undici-types "~7.12.0"
34+
35+
array-ify@^1.0.0:
36+
version "1.0.0"
37+
resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece"
38+
integrity sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==
39+
40+
chalk@^5.3.0:
41+
version "5.6.2"
42+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.6.2.tgz#b1238b6e23ea337af71c7f8a295db5af0c158aea"
43+
integrity sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==
44+
45+
compare-func@^2.0.0:
46+
version "2.0.0"
47+
resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-2.0.0.tgz#fb65e75edbddfd2e568554e8b5b05fff7a51fcb3"
48+
integrity sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==
49+
dependencies:
50+
array-ify "^1.0.0"
51+
dot-prop "^5.1.0"
52+
53+
conventional-changelog-conventionalcommits@^7.0.2:
54+
version "7.0.2"
55+
resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-7.0.2.tgz#aa5da0f1b2543094889e8cf7616ebe1a8f5c70d5"
56+
integrity sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w==
57+
dependencies:
58+
compare-func "^2.0.0"
59+
60+
dot-prop@^5.1.0:
61+
version "5.3.0"
62+
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.3.0.tgz#90ccce708cd9cd82cc4dc8c3ddd9abdd55b20e88"
63+
integrity sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==
64+
dependencies:
65+
is-obj "^2.0.0"
66+
67+
husky@^9.0.11:
68+
version "9.1.7"
69+
resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.7.tgz#d46a38035d101b46a70456a850ff4201344c0b2d"
70+
integrity sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==
71+
72+
is-obj@^2.0.0:
73+
version "2.0.0"
74+
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982"
75+
integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==
76+
77+
undici-types@~7.12.0:
78+
version "7.12.0"
79+
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.12.0.tgz#15c5c7475c2a3ba30659529f5cdb4674b622fafb"
80+
integrity sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ==

0 commit comments

Comments
 (0)