Skip to content

Commit

Permalink
feat: Create initial bash-based action
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasper Hesthaven committed Sep 22, 2020
0 parents commit 62224c2
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .ecrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Verbose": false,
"Debug": false,
"IgnoreDefaults": false,
"SpacesAftertabs": false,
"NoColor": false,
"exclude": ["testfiles"],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false,
"IndentSize": false,
"MaxLineLength": false
}
}
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
charset = utf-8
end_of_line = crlf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
curly_bracket_next_line = false
spaces_around_operators = false
spaces_around_brackets = both

[*.md]
trim_trailing_whitespace = false
indent_size = 2

[*{.yml,.ecrc,.nix}]
indent_size = 2
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

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 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.

For more information, please refer to <http://unlicense.org/>
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# setup-editorconfig-checker

This action downloads [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) by version number and adds it to your path, enabling you to check if your files consider your .editorconfig-rules, regardless of filetype.

# Usage

See [action.yml](action.yml)

Basic:

```yaml
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install editorconfig-checker
- uses: kasperhesthaven/editorconfig-checker@v1
with:
version: "2.1.0" # Defaults to latest if not set

- name: Lint
- run: editorconfig-checker
```
41 changes: 41 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Setup editorconfig-checker"
description: "Downloads the editorconfig-checker binary by version number and adds it to your PATH"
author: "Kasper Hesthaven"
branding:
icon: play
color: green
inputs:
version:
description: "Version to download, e.g., 2.1.0 or 2.0.4. (default: latest)"
required: false
command-name:
description: "Set editorconfig-checker command name, e.g., 'ec'. (default: editorconfig-checker)"
required: false
default: "editorconfig-checker"
runs:
using: "composite"
steps:
- name: Assign latest version if version not provided
run: |
if [ -z ${{ inputs.version }} ]; then
echo "::set-env name=VERSION::$(curl --silent "https://api.github.com/repos/editorconfig-checker/editorconfig-checker/releases/latest" | jq -r .tag_name)"
else
echo "::set-env name=VERSION::${{ inputs.version }}"
fi
shell: bash

- name: Assign lowercase runner env
run: |
echo "::set-env name=OS::$(uname -s | tr '[:upper:]' '[:lower:]')"
echo "::set-env name=ARCH::amd64"
shell: bash

- name: Download & add to path as editorconfig-checker
run: |
mkdir /home/runner/editorconfig-checker & cd "$_"
echo "Downloading editorconfig-checker version $VERSION for $OS-$ARCH from https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$VERSION/ec-$OS-$ARCH.tar.gz"
curl -L https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$VERSION/ec-$OS-$ARCH.tar.gz | tar zx --strip-components 1
mv ec-$OS-$ARCH ${{ inputs.command-name }}
echo "Adding editorconfig-checker to path as ${{ inputs.command-name }}"
echo "::add-path::$(pwd)"
shell: bash

0 comments on commit 62224c2

Please # to comment.