Skip to content

Commit fa77268

Browse files
authored
Update validate-structure.yml
1 parent 2c2ce56 commit fa77268

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

.github/workflows/validate-structure.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Validate Folder Structure
1+
name: Validate Folder Structure
22

33
on:
44
pull_request_target:
@@ -33,8 +33,9 @@ jobs:
3333
run: |
3434
git remote remove pr >/dev/null 2>&1 || true
3535
git remote add pr "$PR_REMOTE_URL"
36-
if git fetch pr "$PR_HEAD_REF":pr-head --depth=1; then
36+
if git fetch pr "$PR_HEAD_REF":pr-head --no-tags; then
3737
git checkout pr-head
38+
git fetch origin "${{ github.event.pull_request.base.ref }}" --depth=0
3839
echo "fetched=true" >> "$GITHUB_OUTPUT"
3940
else
4041
echo "::warning::Unable to fetch fork repository. Skipping structure validation."
@@ -49,11 +50,35 @@ jobs:
4950
- name: Validate folder layout
5051
if: ${{ steps.fetch_head.outputs.fetched == 'true' }}
5152
id: validate
52-
continue-on-error: true
53-
run: node "$RUNNER_TEMP/validate-structure.js" origin/${{ github.event.pull_request.base.ref }}...HEAD
53+
run: |
54+
set -euo pipefail
55+
56+
tmp_output=$(mktemp)
57+
tmp_error=$(mktemp)
58+
59+
set +e
60+
node "$RUNNER_TEMP/validate-structure.js" origin/${{ github.event.pull_request.base.ref }}...HEAD >"$tmp_output" 2>"$tmp_error"
61+
status=$?
62+
set -e
63+
64+
cat "$tmp_output"
65+
cat "$tmp_error" >&2
66+
67+
if grep -q 'Folder structure violations found' "$tmp_output" "$tmp_error"; then
68+
echo "status=failed" >> "$GITHUB_OUTPUT"
69+
exit 0
70+
fi
71+
72+
if [ $status -ne 0 ]; then
73+
echo "::warning::Structure validation skipped because the diff could not be evaluated (exit code $status)."
74+
echo "status=skipped" >> "$GITHUB_OUTPUT"
75+
exit 0
76+
fi
77+
78+
echo "status=passed" >> "$GITHUB_OUTPUT"
5479
5580
- name: Close pull request on failure
56-
if: ${{ steps.validate.outcome == 'failure' }}
81+
if: ${{ steps.validate.outputs.status == 'failed' }}
5782
uses: actions/github-script@v6
5883
with:
5984
github-token: ${{ github.token }}
@@ -77,5 +102,5 @@ jobs:
77102
});
78103
79104
- name: Mark job as failed if validation failed
80-
if: ${{ steps.validate.outcome == 'failure' }}
105+
if: ${{ steps.validate.outputs.status == 'failed' }}
81106
run: exit 1

0 commit comments

Comments
 (0)