Skip to content

Commit

Permalink
Merge pull request #70 from bskinn/68-ci-format-check
Browse files Browse the repository at this point in the history
Add formatting check to CI
  • Loading branch information
bskinn authored Mar 29, 2024
2 parents 1a8b8a9 + d9dccf5 commit 6f1b7af
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/check_formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: check-formatting

on: push

jobs:
format:
name: Check Code Autoformatting
runs-on: ubuntu-latest

steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Set up Node w/caching
uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: 'package-lock.json'

- name: Install deps
run: npm install

- name: Run formatting
run: npm run format

- name: Check for dirty working tree
run: scripts/check-dirty-tree.sh
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ serves to distinguish between multiple releases created on the same day.

- Relocated dev helper scripts to `scripts/` folder.

- Added CI workflow to check formatting, TOCs, Mermaid on pull

### Features at CHANGELOG Creation

Expand Down
29 changes: 29 additions & 0 deletions scripts/check-dirty-tree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /bin/bash

#####################################################################
# Per https://sharats.me/posts/shell-script-best-practices/ (partial)
# set -o errexit # We don't want this because we're trapping errors
set -o nounset
set -o pipefail

if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
#####################################################################

git status | grep modified:

RESULT=$?

if [ $RESULT = 0 ]
then
# grep found something modified, reject
exit 1
elif [ $RESULT = 1 ]
then
# grep didn't find anything, we're ok
exit 0
else
# Some other error
exit $RESULT
fi

0 comments on commit 6f1b7af

Please sign in to comment.