commit message is not conventional #23
Workflow file for this run
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
name: CI | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
lint-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check that commits only modify files (no add or remove) | |
run: | | |
if git diff --name-status origin/main HEAD | grep -E '^[AD]\s+'; then | |
echo "Error: Not allowed to add or remove files in this repo." | |
exit 1 | |
fi | |
- name: Validate commit messages format | |
run: | | |
git log origin/main..HEAD --oneline --no-merges | while read line; do | |
commit_msg=$(echo "$line" | cut -d' ' -f2-) | |
echo "Checking commit: $commit_msg" | |
if [[ ! "$commit_msg" =~ ^(feat|fix|chore|docs|refactor|test)(\(.+\))?:\ .+ ]]; then | |
echo "❌ Invalid commit message: '$COMMIT_MSG'. Must follow 'type(scope): message' format." | |
exit 1 | |
fi | |
echo "✔ Commit message is valid." | |
done | |
- name: Validate branch naming format | |
run: | | |
branch_name=$(echo "${{ github.ref }}" | sed 's|refs/heads/||') | |
echo "Branch name is: $branch_name" | |
if [[ ! "$branch_name" =~ ^(feature|fix|chore|docs)/.+$ ]]; then | |
echo "❌ Invalid branch name: '$branch_name'. Must follow 'feature/*', 'fix/*', etc." | |
exit 1 | |
fi | |
echo "✔ Branch name is valid." | |
- name: Determine Changes | |
id: changes | |
run: | | |
git fetch origin main | |
export CHANGED_FILES=$(git diff --name-only origin/main HEAD) | |
echo "CHANGED_FILES=${CHANGED_FILES}" >> $GITHUB_ENV | |
echo "JS_CHANGED=$(echo \"$CHANGED_FILES\" | grep -E '\.js$|\.jsx$|javascript/')" >> $GITHUB_ENV | |
echo "ZIG_CHANGED=$(echo \"$CHANGED_FILES\" | grep -E '\.zig$|zig/')" >> $GITHUB_ENV | |
- name: Setup Node.js | |
if: env.JS_CHANGED != '' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '17' | |
- name: JS tests | |
if: env.JS_CHANGED != '' | |
run: | | |
cd javascript | |
npm install | |
npm run lint | |
npm test | |
- name: Install Zig using Snap | |
if: env.ZIG_CHANGED != '' | |
run: sudo snap install zig --classic --beta | |
- name: Run tests Zig | |
if: env.ZIG_CHANGED != '' | |
run: zig test zig/index.zig | |