From 87119bbd139e4540185bc030fd1c96be10eae533 Mon Sep 17 00:00:00 2001 From: Brian Bugh Date: Fri, 22 Nov 2019 12:45:15 -0600 Subject: [PATCH] Init --- .github/workflows/test.yml | 16 ++++++ .gitignore | 93 +++++++++++++++++++++++++++++++ Dockerfile | 8 +++ LICENSE | 22 ++++++++ README.md | 5 ++ action.yml | 9 +++ lib/entrypoint.sh | 14 +++++ lib/git-grep-problem-matcher.json | 15 +++++ 8 files changed, 182 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 action.yml create mode 100755 lib/entrypoint.sh create mode 100644 lib/git-grep-problem-matcher.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a6c6ff4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: "Self-test" +on: + pull_request: + push: + branches: + - master + - 'releases/*' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: ./ + env: + ENVIRONMENT: test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ffdd18c --- /dev/null +++ b/.gitignore @@ -0,0 +1,93 @@ +__tests__/runner/* + +# comment out in distribution branches +node_modules/ + +# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7f0eaee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine/git:1.0.7 + +LABEL com.github.actions.name="FIXME check" +LABEL com.github.actions.description="Check your code for `FIXME` labels" +LABEL com.github.actions.icon="code" +LABEL com.github.actions.color="yellow" + +ENTRYPOINT ["lib/entrypoint.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5710126 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ + +The MIT License (MIT) + +Copyright (c) 2018 Brian Bugh, GitHub, Inc. and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..be2adfd --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# action-fixme-alert + +Checks the code base for any `FIXME:` (with the colon) and fails the check if any are found. + +Useful if you want to make sure that you don't miss any changes in the code base before merging a PR. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..69290de --- /dev/null +++ b/action.yml @@ -0,0 +1,9 @@ +name: 'FIXME alert' +description: 'Check for `FIXME` and fail if any are found, with annotations.' +author: '@bbugh' +branding: + icon: 'list' + color: 'orange' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh new file mode 100755 index 0000000..9504604 --- /dev/null +++ b/lib/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +echo "::add-matcher::lib/git-grep-problem-matcher.json" + +tag="FIXME" +result=$(git grep --no-color -n -e "${tag}:") + +echo "${result}" + +if [ -n "${result}" ] && [ "${ENVIRONMENT}" != "test" ]; then + exit 1 +fi diff --git a/lib/git-grep-problem-matcher.json b/lib/git-grep-problem-matcher.json new file mode 100644 index 0000000..4b432be --- /dev/null +++ b/lib/git-grep-problem-matcher.json @@ -0,0 +1,15 @@ +{ + "problemMatcher": [ + { + "owner": "git", + "pattern": [ + { + "regexp": "^(.*?):(\\d+):\\s*(.*?)$", + "file": 1, + "line": 2, + "message": 3 + } + ] + } + ] +}