generated from xkeshav/astro-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
260 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.