Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
underwoo committed Mar 12, 2020
0 parents commit b85c3cf
Show file tree
Hide file tree
Showing 7 changed files with 841 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Dockefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:latest

LABEL maintainer="underwoo"

RUN apt-get update && \
apt-get install -y shellcheck \
&& rm -rf /var/lib/apt/lists/*

COPY lint.sh lint.sh
COPY whitespace_check.sh whitespace_check.sh
COPY ftn_tab_check.sh ftn_tab_check.sh

ENTRYPOINT ["/lint.sh"]
675 changes: 675 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Simple Lint GitHub Action

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

This project runs simple lint-like actions on files in a git repository. The
current list of lint actions are:

* check for trailing whitespace
* check Fortran files for use of tab characters

## Example

```yaml
# This workflow will check files in the repository for trailing whitespace and
# Fortran files that use tabs

name: Simple Lint

on: [push, pull_request]

jobs:
lint:
steps:
- uses: actions/checkout@v2
- name: Whitespace Lint
id: wslint
uses: underwoo/simple-lint@v1
with:
failure: false
- if: ! ${{ steps.wslint.outputs.lintSuccess }}
run: exit 1
```
21 changes: 21 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Fortran Lint"
description: "Simple Fortran Lint, currently checks for trailing whitespace and Tab characters"
inputs:
failure:
description: "Cause action to fail if lint errors found"
required: false
default: true
outputs:
lintSuccess:
description: "indicates if the the lint processes passed (true) or failed (false)"
runs:
using: "docker"
image: "Dockerfile"
args: ["${{ inputs.failure }}"]
branding:
icon: "shield"
color: "blue"



# find . -type f -exec file {} \; | grep '\(Bourne-Again\|POSIX\|Korn\) shell' | awk -F : '{print $1}'
30 changes: 30 additions & 0 deletions ftn_tab_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Copyright (C) 2020 Seth Underwood
#
# This file is part of Simple Lint.
#
# Simple Lint is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simple Lint is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar. If not, see <https://www.gnu.org/licenses/>.

# Find all Fortran files (using the file extensions listed below) and check
# if they files use a tab character. Print the files that do contain a
# tab character to standard out.
# File extensions use:
# * .f .F
# * .f90 .F90
# * .inc .INC
# * .fh .FH
# * .for .FOR
find -O3 . -iregex ".*\.\(f\(90\)?\|inc\|fh\|for\)$" \
-exec grep -l $'\t' {} \;
48 changes: 48 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

# Copyright (C) 2020 Seth Underwood
#
# This file is part of Simple Lint.
#
# Simple Lint is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simple Lint is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar. If not, see <https://www.gnu.org/licenses/>.

# Check for files that have trailing whitespace
/whitespace_check.sh | tee /tmp/ws.out
ws_nfiles=$(wc -l /tmp/ws.out | awk '{print $1}')
if test $ws_nfiles -gt 0
then
echo "::error::${ws_nfiles} file(s) contain(s) trailing whitespace"
cat /tmp/ws.out
fi

# Check for Fortran files with tabs
/ftn_tab_check.sh | tee /tmp/ftab.out
ftab_nfiles=$(wc -l /tmp/ftab.out | awk '{print $1}')
if test $ftab_nfiles -gt 0
then
echo "::error::${ftab_nfiles} Fortran file(s) contain(s) tab characters"
cat /tmp/ftab.out
fi

# Prepare action output, and exit non-zero if requested to fail
if test $ws_nfiles -gt 0 || test $ftab_nfiles -gt 0
then
echo "::set-output name=lintSuccess::false"
if test "$0" = "true"
then
exit 1
fi
else
echo "::set-output name=lintSuccess::true"
fi
22 changes: 22 additions & 0 deletions whitespace_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Copyright (C) 2020 Seth Underwood
#
# This file is part of Simple Lint.
#
# Simple Lint is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simple Lint is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar. If not, see <https://www.gnu.org/licenses/>.

# Find all files in the working directory, ignoring the `.git` directory that
# have trailing whitespace, and prints them to standard out.
find . -type f -not -path "./.git/*" -exec egrep -l " +$" {} \;

0 comments on commit b85c3cf

Please sign in to comment.