Skip to content
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

🧹 chore: │ enable better-commit and pre-commit check (#129) #131

Merged
merged 1 commit into from
Oct 8, 2024
Merged
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
🧹 chore: │ enable better-commit and pre-commit check (#129)
* 🧹 chore: │  enable better-commit and pre-commit check

Changelog: chore

* 🐛 fix(workflow): changes runner

Changelog: fix

* 🧹 chore: Add codeowners

Changelog: chore

* chore: takeout emoji and update workflow release-please

Changelog: chore

---------

Co-authored-by: dimzrio <driotantowi@gmail.com>
dmzrio and dimzrio authored Oct 8, 2024
commit 9acc0acfa1aa973d6e8b58771289a24b73115b84
182 changes: 182 additions & 0 deletions .better-commits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"check_status": true,
"commit_type": {
"enable": true,
"initial_value": "feat",
"max_items": 20,
"infer_type_from_branch": true,
"append_emoji_to_label": false,
"append_emoji_to_commit": false,
"options": [
{
"value": "feat",
"label": "feat",
"hint": "A new feature",
"emoji": "✨",
"trailer": "Changelog: feature"
},
{
"value": "fix",
"label": "fix",
"hint": "A bug fix",
"emoji": "🐛",
"trailer": "Changelog: fix"
},
{
"value": "docs",
"label": "docs",
"hint": "Documentation only changes",
"emoji": "📚",
"trailer": "Changelog: documentation"
},
{
"value": "refactor",
"label": "refactor",
"hint": "A code change that neither fixes a bug nor adds a feature",
"emoji": "🔨",
"trailer": "Changelog: refactor"
},
{
"value": "perf",
"label": "perf",
"hint": "A code change that improves performance",
"emoji": "🚀",
"trailer": "Changelog: performance"
},
{
"value": "test",
"label": "test",
"hint": "Adding missing tests or correcting existing tests",
"emoji": "🚨",
"trailer": "Changelog: test"
},
{
"value": "build",
"label": "build",
"hint": "Changes that affect the build system or external dependencies",
"emoji": "🚧",
"trailer": "Changelog: build"
},
{
"value": "ci",
"label": "ci",
"hint": "Changes to our CI configuration files and scripts",
"emoji": "🤖",
"trailer": "Changelog: ci"
},
{
"value": "chore",
"label": "chore",
"hint": "Other changes that do not modify src or test files",
"emoji": "🧹",
"trailer": "Changelog: chore"
},
{
"value": "",
"label": "none"
}
]
},
"commit_scope": {
"enable": true,
"custom_scope": true,
"max_items": 20,
"initial_value": "",
"options": [
{
"value": "workflow",
"label": "workflow"
},
{
"value": "backend",
"label": "backend"
},
{
"value": "frontend",
"label": "frontend"
},
{
"value": "infra",
"label": "infra"
},
{
"value": "sdet",
"label": "sdet"
},
{
"value": "",
"label": "none"
}
]
},
"check_ticket": {
"infer_ticket": true,
"confirm_ticket": true,
"add_to_title": true,
"append_hashtag": false,
"prepend_hashtag": "Never",
"surround": "",
"title_position": "start"
},
"commit_title": {
"max_size": 70
},
"commit_body": {
"enable": true,
"required": false
},
"commit_footer": {
"enable": false,
"initial_value": [],
"options": [
"closes",
"trailer",
"breaking-change",
"deprecated",
"custom"
]
},
"breaking_change": {
"add_exclamation_to_title": false
},
"confirm_with_editor": false,
"confirm_commit": true,
"print_commit_output": true,
"branch_pre_commands": [],
"branch_post_commands": [],
"worktree_pre_commands": [],
"worktree_post_commands": [],
"branch_user": {
"enable": false,
"required": false,
"separator": "/"
},
"branch_type": {
"enable": true,
"separator": "/"
},
"branch_version": {
"enable": false,
"required": false,
"separator": "/"
},
"branch_ticket": {
"enable": true,
"required": false,
"separator": "-"
},
"branch_description": {
"max_length": 70,
"separator": ""
},
"branch_action_default": "branch",
"branch_order": [
"user",
"version",
"type",
"ticket",
"description"
],
"enable_worktrees": false,
"overrides": {}
}
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit check

on:
pull_request:

env:
BRANCH: ${{ github.head_ref || github.ref_name }}

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cloudposse/github-action-pre-commit@v4.0.0
15 changes: 14 additions & 1 deletion .github/workflows/release-please-main.yml
Original file line number Diff line number Diff line change
@@ -8,10 +8,23 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
- uses: googleapis/release-please-action@v4
with:
release-type: simple
labels: "autorelease-pending"
release-labels: "autorelease-tagged"

- name: Checkout repository
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4

- name: Create tag major version
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/googleapis/release-please-action.git"
git tag -d v${{ steps.release.outputs.major }} || true
git push origin :v${{ steps.release.outputs.major }} || true
git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}"
git push origin v${{ steps.release.outputs.major }}
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: no-commit-to-branch

- repo: local
hooks:
- id: branch-convention
name: branch-convention
entry: ./branch-convention.sh
language: script
types: [file]
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.5.1"
".": "2.0.0"
}
4 changes: 4 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* @kitabisa/system-squad
frontend @adeherysh
backend @sswastioyono18
sdet @mananrangkuti
1 change: 0 additions & 1 deletion backend/cache/action.yaml
Original file line number Diff line number Diff line change
@@ -102,4 +102,3 @@ runs:
run: |
go mod download
go build

1 change: 0 additions & 1 deletion backend/unit_test/action.yaml
Original file line number Diff line number Diff line change
@@ -189,4 +189,3 @@ runs:
Condition: Current branch coverage must be bigger or equal than master branch coverage.
```
PR Coverage check passed.

2 changes: 0 additions & 2 deletions backend/unit_test_v2/README.md
Original file line number Diff line number Diff line change
@@ -53,5 +53,3 @@ To use this action with a custom command:
with:
custom_command_flag: true
custom_command: "your-custom-command"


1 change: 0 additions & 1 deletion backend/unit_test_v2/action.yaml
Original file line number Diff line number Diff line change
@@ -213,4 +213,3 @@ runs:
message: |
## ✅✅ Unit Test Coverage ✅✅
All new code passed the coverage threshold.

18 changes: 18 additions & 0 deletions branch-convention.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

REGEX="^(feat|fix|docs|refactor|perf|test|build|ci|chore)\/[A-Za-z0-9._-]+$|release-please--.*"

if [[ -z "${BRANCH}" ]]; then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
else
BRANCH="${BRANCH}"
fi

echo $BRANCH

if ! [[ $BRANCH =~ $REGEX ]]; then
echo "Your commit was rejected due to branching name"
echo "Please rename your branch with '(feat|fix|docs|refactor|perf|test|build|ci|chore)/lowercase-name' syntax"
echo "Or you can use better-branch tools"
exit 1
fi
2 changes: 0 additions & 2 deletions frontend/tools/bun/action.yaml
Original file line number Diff line number Diff line change
@@ -57,5 +57,3 @@ runs:
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-nextjs-


2 changes: 0 additions & 2 deletions frontend/tools/yarn/action.yaml
Original file line number Diff line number Diff line change
@@ -58,5 +58,3 @@ runs:
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-nextjs-


2 changes: 1 addition & 1 deletion infra/tools/gcloud/action.yaml
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ runs:

- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
with:
with:
install_components: ${{ inputs.gcloud_components }}

- name: Register gcloud as a docker credential helper
2 changes: 1 addition & 1 deletion infra/tools/setup-git/action.yaml
Original file line number Diff line number Diff line change
@@ -30,4 +30,4 @@ runs:
USERNAME: "${{ inputs.username }}"
EMAIL: "${{ inputs.username }}@users.noreply.github.com"
run: $GITHUB_ACTION_PATH/main.sh
shell: bash
shell: bash
2 changes: 1 addition & 1 deletion infra/tools/setup-git/main.sh
Original file line number Diff line number Diff line change
@@ -16,4 +16,4 @@ git config --$SCOPE user.email "${EMAIL}"
echo "::debug::Set git user's name"
git config --$SCOPE user.name "${USERNAME}"

echo "email=${EMAIL}" >> $GITHUB_OUTPUT
echo "email=${EMAIL}" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion infra/tools/setup-git/validate.sh
Original file line number Diff line number Diff line change
@@ -9,4 +9,4 @@ if [[ ! "${valid_scopes[@]}" =~ "${SCOPE}" ]]; then
echo "::error::Invalid scope specified: \"${SCOPE}\""
echo "::error::Valid scopes are \"global\", \"system\", \"local\", or \"worktree\"."
exit 1
fi
fi
20 changes: 20 additions & 0 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## What does this PR do?
_Place what this pull request changes and anything affected. If your PR block or require another PR, also need to mention here_

## Why are we doing this? Any context or related work?
_You may put your link or another here_

## Where should a reviewer start?
_optional -- if your changes affected so much files, it is encouraged to give helper for reviewer_

## Screenshots
_optional -- You may put the database, sequence or any diagram needed_

## Manual testing steps?
_Steps to do tests. including all possible that can hape_

## Config changes
_optional -- If there's config changes, put it here_

## Deployment instructions
_optional -- Better to put it if there's some 'special case' for deployment_
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
"packages": {
".": {}
}
}
}
2 changes: 1 addition & 1 deletion sdet/build/action.yaml
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ runs:
with:
setup_pnpm: ${{ inputs.setup_pnpm }}
setup_bun: ${{ inputs.setup_bun }}

- name: install packages
shell: bash
run: ${{ inputs.custom_command_packages }}
2 changes: 1 addition & 1 deletion sdet/tools/dispatch/README.md
Original file line number Diff line number Diff line change
@@ -22,4 +22,4 @@ SDET composite return dispatch
## Runs

This action is a `composite` action.
<!-- action-docs-runs -->
<!-- action-docs-runs -->
2 changes: 1 addition & 1 deletion sdet/tools/env/README.md
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@ SDET composite setup env
## Runs

This action is a `composite` action.
<!-- action-docs-runs -->
<!-- action-docs-runs -->
2 changes: 1 addition & 1 deletion sdet/tools/setup-tools/README.md
Original file line number Diff line number Diff line change
@@ -18,4 +18,4 @@ SDET composite setup tools
## Runs

This action is a `composite` action.
<!-- action-docs-runs -->
<!-- action-docs-runs -->
2 changes: 1 addition & 1 deletion sdet/tools/setup-tools/action.yaml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ runs:
- name: setup bun
if: "${{ inputs.setup_bun == 'true' }}"
uses: kitabisa/composite-actions/sdet/tools/bun@v2

- name: setup github cli
if: "${{ inputs.setup_gh_cli == 'true' }}"
uses: kitabisa/composite-actions/sdet/tools/gh_cli@v2