Skip to content

Commit

Permalink
[main]: added githooks and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
xkeshav committed Jan 10, 2025
1 parent 5309838 commit 2200581
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 110 deletions.
46 changes: 46 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# Step 1: Validate branch naming convention
BRANCH_NAME=$(git symbolic-ref --short HEAD)
echo "Current branch: $BRANCH_NAME"

# Define the branches to exclude
EXCLUDED_BRANCHES="develop main release refactor"

# Check if the current branch is in the excluded list
for EXCLUDED_BRANCH in $EXCLUDED_BRANCHES; do
if [ "$BRANCH_NAME" = "$EXCLUDED_BRANCH" ]; then
echo "Skipping pre-commit checks for branch: $BRANCH_NAME"
exit 0
fi
done

# Pre-commit checks (e.g., linting, testing, etc.)
echo "Running pre-commit checks for branch: $BRANCH_NAME"

echo "$BRANCH_NAME" | grep -Eq '^(feature|bugfix|hotfix|task)/[A-Za-z]+-[0-9]+'
if [ $? -ne 0 ]; then
echo "Error: Branch name '$BRANCH_NAME' is invalid."
echo "Use a valid branch naming convention, e.g., feature/XYZ-123-description."
exit 1
fi

# Step 2: Run poetry linting tools
echo "Running poetry linting tools..."
if ! poetry run flake8 .; then
echo "flake8 failed. Aborting commit."
exit 1
fi

if ! poetry run black --check .; then
echo "black failed. Aborting commit."
exit 1
fi

if ! poetry run mypy .; then
echo "mypy failed. Aborting commit."
exit 1
fi

echo "Pre-commit checks passed!"
exit 0
17 changes: 17 additions & 0 deletions .githooks/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# This script prepends the branch name to the commit message
# Skip certain branches (configurable)
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP="master develop release refactor"
fi

BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"

BRANCH_EXCLUDED=$(printf "%s\n" $BRANCHES_TO_SKIP | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "\[$BRANCH_NAME\]" "$1")

if [ -n "$BRANCH_NAME" ] && ! [ $BRANCH_EXCLUDED -eq 1 ] && ! [ $BRANCH_IN_COMMIT -ge 1 ]; then
sed -i.bak -e "1s/^/[$BRANCH_NAME]: /" "$1"
fi
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Bug Report
description: File a bug report to help us improve.
title: "🐛 RZB-25000X:"
labels: ["bug", "invalid"]
assignees: ["xkeshav"]
labels: ["bug"]
assignees: ["recursivezero"]

body:
- type: markdown
Expand Down
17 changes: 0 additions & 17 deletions .github/actions/md-lint/.markdownlint.json

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/lint-n-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint and Build
run-name: Lint and Build when push or raise PR

on:
push:
branches: ["main", "develop", "feature/*", "!task/*"]

pull_request_target:
branches:
- main
- develop

jobs:
lint-and-build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Set up Node.js
- name: Set up Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20 # Replace with your desired Node.js version
cache: "npm" # Cache npm dependencies for faster builds

# Step 3: Install dependencies
- name: Install dependencies
run: npm install

# Step 4: Run linting
- name: Run lint
run: npm run lint

# Step 5: Run build
- name: Run build
run: npm run build
12 changes: 11 additions & 1 deletion .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
name: markdown-lint
run-name: learning github action from workflow
run-name: Linting markdown files
on:
push:
branches:
- main
- develop
paths:
- "**.md" # Match any .md file in any directory
- "**.mdx"
pull_request:
branches:
- main
- develop
paths:
- "**.md"
- "**.mdx"
jobs:
markdown-lint:
runs-on: ubuntu-latest
Expand Down
31 changes: 2 additions & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

## [0.0.1] - 2024-01-01
## [1.0.0] - 2025-10-01

Added
Created Repo from template

Basic Astro setup
React and Tailwind
Lint and workspace file

Changed

## [1.0.0] - 2024-10-07

- Added New Repo

## [1.1.1] - 2024-10-21

- launched with server nd db connection

## [1.2.0] - 2024-10-22

Changed

- build on client side

## [1.3.0] - 2024-12-22

Added

- Product Detail page
- Zipped page
- Share button on product detail page

### [Unreleased]

Expand Down
3 changes: 2 additions & 1 deletion abcd.code-workspace
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"folders": [
{
"name": "abcd",
"path": "."
}
],
Expand Down Expand Up @@ -114,7 +115,7 @@
"files.autoSave": "onFocusChange",
"files.eol": "\r\n",
"files.exclude": {
".git/**": true
"**/.git": false
},
"files.readonlyExclude": {
"dist/**": true
Expand Down
Loading

0 comments on commit 2200581

Please sign in to comment.