Skip to content
Draft
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
16 changes: 13 additions & 3 deletions .github/workflows/o2-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ jobs:
- name: Run tests
id: linter
run: |
# Diff against the common ancestor of the source (head) branch and the target (base) branch.
echo "Diffing ${{ env.BRANCH_HEAD }} against ${{ env.BRANCH_BASE }}."
readarray -t files < <(git diff --diff-filter d --name-only origin/${{ env.BRANCH_BASE }}...)
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "Diffing ${{ github.event.before }} against ${{ github.sha }}."
if [[ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]]; then
# New branch push: lint files introduced by the pushed commit.
readarray -t files < <(git show --diff-filter d --name-only --pretty=format: ${{ github.sha }})
else
readarray -t files < <(git diff --diff-filter d --name-only ${{ github.event.before }} ${{ github.sha }})
fi
else
# Diff against the common ancestor of the source (head) branch and the target (base) branch.
echo "Diffing ${{ env.BRANCH_HEAD }} against ${{ env.BRANCH_BASE }}."
readarray -t files < <(git diff --diff-filter d --name-only origin/${{ env.BRANCH_BASE }}...)
fi
if [ ${#files[@]} -eq 0 ]; then
echo "::notice::No files to lint."
echo "linter_ran=0" >> "$GITHUB_OUTPUT"
Expand Down