Skip to content
Merged
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
39 changes: 32 additions & 7 deletions .github/workflows/license-eyes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,40 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Fetch base branch for diff
if: github.event_name == 'pull_request_target'
Comment thread
hello-stephen marked this conversation as resolved.
run: git fetch --no-tags --depth=1 origin ${{ github.base_ref }}

- name: Get changed files
if: github.event_name == 'pull_request_target'
id: changed-files
uses: tj-actions/changed-files@v45
with:
separator: "\n"
run: |
base_sha=$(git rev-parse FETCH_HEAD)
if ! all=$(git diff --name-only "${base_sha}...HEAD" 2>/dev/null); then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still fails in the runner's shallow-checkout layout. With the exact sequence used here:\n\n\n\n\n\nthere is often no merge base, and I reproduced that on this PR head locally in the Actions workspace (). So the PR path still cannot reliably compute changed files. This needs either enough history to guarantee a merge base, or a changed-files mechanism that does not depend on a shallow three-dot diff.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still fails in the runner's shallow-checkout layout. With the exact sequence used here:

git fetch --no-tags --depth=1 origin ${{ github.base_ref }}
base_sha=$(git rev-parse FETCH_HEAD)
git diff --name-only "${base_sha}...HEAD"

there is often no merge base, and I reproduced that on this PR head in the Actions workspace (fatal: ... no merge base). So the PR path still cannot reliably compute changed files. This needs either enough history to guarantee a merge base, or a changed-files mechanism that does not depend on a shallow three-dot diff.

echo "config_file=.licenserc.yaml" >> "$GITHUB_OUTPUT"
exit 0
fi
if echo "$all" | grep -qxF '.licenserc.yaml'; then
echo "config_file=.licenserc.yaml" >> "$GITHUB_OUTPUT"
exit 0
fi
acmr=$(git diff --name-only --diff-filter=ACMR "${base_sha}...HEAD")
if [ -z "$acmr" ]; then
exit 0
fi
{
echo "added_modified<<EOF"
echo "$acmr"
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo "config_file=.licenserc-incremental.yaml" >> "$GITHUB_OUTPUT"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config_file is set to .licenserc-incremental.yaml unconditionally here, even when git diff --diff-filter=ACMR returned no files. In a delete-only PR, Generate incremental licenserc is skipped, the incremental file is never created, and Check License still tries to read it. Please only set the incremental config when added_modified is non-empty, or skip the license step entirely for delete-only PRs.


- name: Generate incremental licenserc
if: github.event_name == 'pull_request_target' && steps.changed-files.outputs.all_changed_files != ''
if: >-
github.event_name == 'pull_request_target' &&
steps.changed-files.outputs.added_modified != ''
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
CHANGED_FILES: ${{ steps.changed-files.outputs.added_modified }}
run: |
python3 - <<'EOF'
import yaml, os
Expand All @@ -76,9 +99,11 @@ jobs:
EOF

- name: Check License
if: github.event_name != 'pull_request_target' || steps.changed-files.outputs.all_changed_files != ''
if: >-
github.event_name != 'pull_request_target' ||
steps.changed-files.outputs.config_file != ''
uses: apache/skywalking-eyes@v0.8.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config: ${{ github.event_name == 'pull_request_target' && '.licenserc-incremental.yaml' || '.licenserc.yaml' }}
config: ${{ steps.changed-files.outputs.config_file || '.licenserc.yaml' }}
Loading