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