Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test Pluto
name: Build and test Pluto

on:
push:
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/find_trailing_whitespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Check trailing whitespaces

on:
push:
branches: [master]
paths-ignore:
- '**.png'
pull_request:
branches: [master]
paths-ignore:
- '**.png'


jobs:
check-trailing-whitespace:
name: Check trailing whitespaces
runs-on: [self-hosted]
steps:
- uses: actions/checkout@v2

# Choose the git commit to diff against for the purposes of diff-check.
# Since this workflow is triggered on both pushes and pull requests, we
# have to determine if the pull request target branch is set (which it
# will only be on the PR triggered flow). If it's not, then compare
# against the last commit.
- name: choose-commit
if: ${{ always() }}
env:
# Base ref is the target branch, in text form (not hash)
PR_BASE: ${{ github.base_ref }}
run: |
# Determine diff commit name.
if [[ -z "$PR_BASE" ]]; then
DIFF_COMMIT_NAME="HEAD^"
else
DIFF_COMMIT_NAME="$PR_BASE"
fi
echo "DIFF_COMMIT_NAME=$DIFF_COMMIT_NAME" >> $GITHUB_ENV

# Since we did a shallow fetch for this repo, we must fetch the commit
# upon which we be diff'ing. The last step set the ref name in the
# $DIFF_COMMIT_NAME environment variable. When running the fetch, resolve
# it to the commit hash and pass that hash along to subsequent steps.
- name: git fetch base commit
continue-on-error: true
run: |
if [[ ! "$DIFF_COMMIT_NAME" == *"HEAD"* ]]; then
git fetch --recurse-submodules=no origin $DIFF_COMMIT_NAME
DIFF_COMMIT_SHA=$( git rev-parse origin/$DIFF_COMMIT_NAME )
else
DIFF_COMMIT_SHA=$( git rev-parse $DIFF_COMMIT_NAME )
fi
echo "DIFF_COMMIT=$DIFF_COMMIT_SHA" >> $GITHUB_ENV

# Run 'git diff --check', comparing against the target commit hash. If
# diff check fixed anything, fail and output a patch.
- name: diff-check
shell: bash
working-directory: ${{github.workspace}}
run: |
git diff --ignore-submodules --check $DIFF_COMMIT
echo "git diff --check found no whitespace problems"
exit 0

# Cancel workflows when new commit is pushed to a branch other than master.
concurrency:
# Use github.run_id on master branch.
# Use github.event.pull_request.number on pull requests, so it's unique per pull request.
# Use github.ref on other branches, so it's unique per branch.
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.pull_request.number || github.ref }}
cancel-in-progress: true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ test](https://github.com/bondhugula/pluto/actions/workflows/build_and_test.yml/b

[![Check format with clang-format](https://github.com/bondhugula/pluto/actions/workflows/clang_format.yml/badge.svg)](https://github.com/bondhugula/pluto/actions/workflows/clang_format.yml)

[![Find trailing whitespace](https://github.com/bondhugula/pluto/actions/workflows/find_trailing_whitespace.yml/badge.svg)](https://github.com/bondhugula/pluto/actions/workflows/find_trailing_whitespace.yml)

## License

Pluto and libpluto are available under the MIT LICENSE. Please see the file
Expand Down