Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 20 additions & 5 deletions .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,32 @@ jobs:
with:
bun-version: latest

- name: Install commitlint
- name: Check for commitlint config and install dependencies
id: commitlint-config
run: |
if [ -f .commitlintrc.json ] || [ -f .commitlintrc.js ] || [ -f .commitlintrc.yml ] || [ -f .commitlintrc.yaml ] || grep -q '"commitlint"' "package.json" 2>/dev/null; then
echo "has-config=true" >> $GITHUB_OUTPUT
else
echo "has-config=false" >> $GITHUB_OUTPUT
fi

- name: Install dependencies if config exists
if: steps.commitlint-config.outputs.has-config == 'true'
run: |
bun i -g @commitlint/cli
bun i

- name: Install commitlint globally if no config
if: steps.commitlint-config.outputs.has-config == 'false'
run: |
bun i -g @commitlint/cli
bun i -D @commitlint/config-conventional

- name: Create commitlint config if missing
if: steps.commitlint-config.outputs.has-config == 'false'
run: |
if [ ! -f .commitlintrc.json ] && [ ! -f .commitlintrc.js ] && [ ! -f .commitlintrc.yml ] && [ ! -f .commitlintrc.yaml ] && ! grep -q '"commitlint"' "package.json" 2>/dev/null; then
echo "extends:" > .commitlintrc.yml
echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml
fi
echo "extends:" > .commitlintrc.yml
echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml

- name: Check PR title
if: github.event_name == 'pull_request'
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
- uses: actions/checkout@v4

- name: Check for Prettier config
id: prettier-config
run: |
CONFIG_FILES=".prettierrc .prettierrc.json .prettierrc.js .prettierrc.yaml .prettierrc.yml .prettierrc.toml prettier.config.js prettier.config.mjs"
HAS_CONFIG=false
Expand All @@ -21,14 +22,16 @@ jobs:
fi
done

if [ "$HAS_CONFIG" = false ] && ! grep -q '"prettier"' "package.json" 2>/dev/null; then
if [ "$HAS_CONFIG" = false ]; then
echo "::error file=.prettierrc::No Prettier configuration file found."
echo "A Prettier config file is required to ensure consistent formatting across all developers."
echo "Without a shared config, each developer's local Prettier settings will differ, causing unnecessary formatting changes in commits."
echo "Please create a .prettierrc file in your repository root."
exit 1
fi

echo "has-config=true" >> $GITHUB_OUTPUT

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
Expand All @@ -37,5 +40,9 @@ jobs:
- name: Install Prettier
run: bun i -g prettier

- name: Install Dependencies
if: steps.prettier-config.outputs.has-config == 'true'
run: bun i

- name: Check formatting
run: prettier --check .