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
68 changes: 48 additions & 20 deletions .github/actions/base/prettier/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,33 @@ runs:
echo "files=$files" >> "$GITHUB_OUTPUT"
fi

- name: Install Prettier
- name: Install dependencies
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ -f package.json ]; then
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
elif [ "${{ inputs.package-manager }}" = "npm" ]; then
npm ci
else
bun i --frozen-lockfile
fi
else
echo "No package.json found, skipping dependency installation."
fi

- name: Install Prettier (fallback)
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ -x "./node_modules/.bin/prettier" ]; then
echo "Using project-local Prettier."
exit 0
fi

if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm add -g prettier
elif [ "${{ inputs.package-manager }}" = "npm" ]; then
Expand All @@ -62,10 +84,21 @@ runs:
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
run_prettier() {
if [ -x "./node_modules/.bin/prettier" ]; then
./node_modules/.bin/prettier "$@"
elif command -v prettier >/dev/null 2>&1; then
prettier "$@"
else
echo "::error::Prettier not found locally or globally." >&2
exit 1
fi
}

probe_file=".prettier-config-probe.tmp"
touch "$probe_file"

if prettier --find-config-path "$probe_file" >/dev/null 2>&1; then
if run_prettier --find-config-path "$probe_file" >/dev/null 2>&1; then
echo "has-config=true" >> "$GITHUB_OUTPUT"
else
echo "has-config=false" >> "$GITHUB_OUTPUT"
Expand All @@ -79,23 +112,6 @@ runs:

rm -f "$probe_file"

- name: Install dependencies
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ -f package.json ]; then
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
elif [ "${{ inputs.package-manager }}" = "npm" ]; then
npm ci
else
bun i --frozen-lockfile
fi
else
echo "No package.json found, skipping dependency installation."
fi

- name: Skip when no files changed
if: steps.resolved-files.outputs.any-changed != 'true'
shell: bash
Expand All @@ -106,4 +122,16 @@ runs:
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: prettier --check --ignore-unknown ${{ steps.resolved-files.outputs.files }}
run: |
run_prettier() {
if [ -x "./node_modules/.bin/prettier" ]; then
./node_modules/.bin/prettier "$@"
elif command -v prettier >/dev/null 2>&1; then
prettier "$@"
else
echo "::error::Prettier not found locally or globally." >&2
exit 1
fi
}

run_prettier --check --ignore-unknown ${{ steps.resolved-files.outputs.files }}
5 changes: 3 additions & 2 deletions ACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
- Intended as the first step before calling local-path actions from that checkout.

> [!WARNING]
> Keep `base/checkout` backward compatible. Workflows reference the action as `.../base/checkout@main`, so any breaking change merged to this repo’s `main` will immediately break consumers.

Check warning on line 28 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 189 exceeds 80 characters
>
> This also applies to the `ref` input: existing workflows often pass `ref: main` (a branch name) for the _target_ repo checkout, so don’t change `ref` semantics in a way that would require a commit SHA.

Check warning on line 30 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 203 exceeds 80 characters

### `base/setup-runtime`

Expand All @@ -42,7 +42,7 @@
- Validates allowed `package-manager` values.
- For `bun`: installs Bun runtime.
- For `pnpm`/`npm`: installs Node.js.
- For `pnpm`: installs pnpm using `package.json#packageManager` when present, otherwise falls back to `latest`.

Check warning on line 45 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 111 exceeds 80 characters
- Respects `HOLDEX_WORKING_DIR` env var for `package.json` detection when set.

### `base/prettier`
Expand All @@ -58,10 +58,11 @@

- Discovers changed files itself if `changed-files` is not provided.
- Skips execution if no changed files exist.
- Installs Prettier globally using selected package manager.
- Verifies a resolvable Prettier config exists.
- Runs dependency install in repo context when `package.json` exists:
- `bun i --frozen-lockfile`, `pnpm install --frozen-lockfile`, or `npm ci`.
- Uses project-local Prettier (`./node_modules/.bin/prettier`) when available after dependency install.

Check warning on line 63 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 103 exceeds 80 characters
- Installs Prettier globally as a fallback only when no local binary is found.
- Verifies a resolvable Prettier config exists.
- Runs `prettier --check --ignore-unknown` on changed files.
- Respects `HOLDEX_WORKING_DIR` env var: all steps run in that directory when set.

Expand All @@ -80,7 +81,7 @@
- Filters/uses markdown-only changed files.
- Skips execution if no markdown files changed.
- Installs `rumdl` globally using selected package manager.
- Runs `rumdl check --output-format github --fail-on error` on changed markdown files.

Check warning on line 84 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 86 exceeds 80 characters
- Respects `HOLDEX_WORKING_DIR` env var: all steps run in that directory when set.

### `base/commit-check`
Expand All @@ -98,7 +99,7 @@
- Detects commitlint configuration from standard config files or `package.json`.
- If config exists, installs dependencies in repo context:
- `bun i --frozen-lockfile`, `pnpm install --frozen-lockfile`, or `npm ci`.
- If config does not exist, installs `@commitlint/config-conventional` and creates fallback `.commitlintrc.yml`.

Check warning on line 102 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 112 exceeds 80 characters
- Validates PR title via `commitlint`.
- Respects `HOLDEX_WORKING_DIR` env var: all steps run in that directory when set.

Expand Down
Loading