Added generic message.

This commit is contained in:
shubham-mermaid
2025-06-20 18:55:45 +05:30
parent 222d7170f7
commit 7dd8ddc3eb
2 changed files with 28 additions and 26 deletions

View File

@@ -1,5 +0,0 @@
---
'mermaid': minor
---
chore:Added workflow file for validating pnpm-lock file

View File

@@ -23,25 +23,34 @@ jobs:
node-version: 20
- name: Validate pnpm-lock.yaml entries
id: validate # give this step an ID so we can reference its outputs
run: |
forbidden=(
'tarball:' # no tarball fields
'packages/mermaid/src/vitepress' # no vitepress paths
)
issues=()
for pat in "${forbidden[@]}"; do
if grep -qF "$pat" pnpm-lock.yaml; then
echo "❌ Forbidden pattern \"$pat\" found in pnpm-lock.yaml"
exit 1
# 1) No tarball references
if grep -qF 'tarball:' pnpm-lock.yaml; then
issues+=("• Tarball references found (forbidden)")
fi
done
- name: Ensure pnpm-lock.yaml only when package.json changes
run: |
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} > changed_files.txt
if grep -q '^pnpm-lock.yaml$' changed_files.txt && \
! grep -q 'package.json' changed_files.txt; then
echo "❌ pnpm-lock.yaml was changed without any package.json"
# 2) No unwanted vitepress paths
if grep -qF 'packages/mermaid/src/vitepress' pnpm-lock.yaml; then
issues+=("• Disallowed path 'packages/mermaid/src/vitepress' present")
fi
# 3) Lockfile only changes when package.json changes
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} > changed.txt
if grep -q '^pnpm-lock.yaml$' changed.txt && ! grep -q 'package.json' changed.txt; then
issues+=("• pnpm-lock.yaml changed without any package.json modification")
fi
# If any issues, output them and fail
if [ ${#issues[@]} -gt 0 ]; then
# Use the new GITHUB_OUTPUT approach to set a multiline output
{
echo "errors<<EOF"
printf '%s\n' "${issues[@]}"
echo "EOF"
} >> $GITHUB_OUTPUT
exit 1
fi
@@ -54,11 +63,9 @@ jobs:
body: |
## 🔍 Lockfile Validation Failed
One or more issues were found in `pnpm-lock.yaml`:
- Tarball references are not allowed.
- `packages/mermaid/src/vitepress` path must not appear in the lockfile.
- `pnpm-lock.yaml` should only change when `package.json` changes.
The following issue(s) were detected in `pnpm-lock.yaml`:
${{ steps.validate.outputs.errors }}
Please fix these issues and push an update.
Please address these and push an update.
_Posted automatically by GitHub Actions_