Skip to content

Commit

Permalink
Merge pull request #18 from cytopia/release-0.4
Browse files Browse the repository at this point in the history
Release 0.4
  • Loading branch information
cytopia authored Jun 12, 2020
2 parents 5017c1b + 1a74b46 commit 85bfa8b
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 11 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ _test-req:
@docker run --rm $(IMAGE) file-trailing-space --info
@docker run --rm $(IMAGE) file-utf8 --info
@docker run --rm $(IMAGE) file-utf8-bom --info
@docker run --rm $(IMAGE) git-conflicts --info

_test-run-succ:
@echo "------------------------------------------------------------"
Expand All @@ -57,6 +58,7 @@ _test-run-succ:
@docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-trailing-space --path .
@docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-utf8 --path .
@docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-utf8-bom --path .
@docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) git-conflicts --path .

_test-run-fail:
@echo "------------------------------------------------------------"
Expand Down Expand Up @@ -89,6 +91,9 @@ _test-run-fail:
@if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-utf8-bom --path .; then \
exit 1; \
fi
@if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) git-conflicts --path .; then \
exit 1; \
fi

tag:
docker tag $(IMAGE) $(IMAGE):$(TAG)
Expand Down
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
> [goimports][gimp-git-lnk] ****
> [golint][glint-git-lnk] ****
> [jsonlint][jlint-git-lnk] ****
> [linkcheck][linkcheck-git-lnk] ****
> [mypy][mypy-git-lnk] ****
> [phpcbf][pcbf-git-lnk] ****
> [phpcs][pcs-git-lnk] ****
> [phplint][plint-git-lnk] ****
> [php-cs-fixer][pcsf-git-lnk] ****
> [pycodestyle][pycs-git-lnk] ****
> [pydocstyle][pyds-git-lnk] ****
> [pylint][pylint-git-lnk] ****
> [terraform-docs][tfdocs-git-lnk] ****
> [terragrunt][tg-git-lnk] ****
Expand Down Expand Up @@ -78,6 +81,7 @@ Tiny Alpine-based Docker image for the very basics of CI against your code files
| File | [file-trailing-space](data/file-trailing-space) || Scan files and check if they contain trailing whitespaces. |
| File | [file-utf8](data/file-utf8) || Scan files and check if they have a non UTF-8 encoding. |
| File | [file-utf8-bom](data/file-utf8-bom) || Scan files and check if they contain BOM (Byte Order Mark): `U+FEFF`. |
| Git | [git-conflicts](data/git-conflicts) | | Scan files and check if they contain git conflicts. |

> <sub>Tools extracted from https://github.com/cytopia/awesome-ci</sub>
Expand Down Expand Up @@ -126,6 +130,7 @@ $ docker run --rm -v $(pwd):/data cytopia/file-lint
# file-trailing-space Scans if files contain trailing whitespace #
# file-utf8 Scans if files are utf8 encoded #
# file-utf8-bom Scans if files contain byte order mark #
# git-conflicts Scans if files contain git conflicts #
# #
# #
# Example: #
Expand Down Expand Up @@ -314,6 +319,12 @@ FILE_UTF8_BOM_EXTENSION=""
FILE_UTF8_BOM_IGNORE=".git,*.svn"
FILE_UTF8_BOM_TEXT=1
FILE_UTF8_BOM_SIZE=1

# git-conflicts
GIT_CONFLICTS_EXTENSION=""
GIT_CONFLICTS_IGNORE=".git,*.svn"
GIT_CONFLICTS_TEXT=1
GIT_CONFLICTS_SIZE=1
```

### Example Makefile
Expand All @@ -322,9 +333,7 @@ ifneq (,)
.error This Makefile requires GNU Make.
endif

.PHONY: lint _lint-cr _lint-crlf _lint-trailing-single-newline _lint-trailing-space _lint-utf8 _lint-utf8-bom

CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
.PHONY: lint _lint-cr _lint-crlf _lint-trailing-single-newline _lint-trailing-space _lint-utf8 _lint-utf8-bom _lint-git-conflicts

FL_VERSION = latest
FL_IGNORE_PATHS = .git/,.github/
Expand All @@ -336,24 +345,29 @@ lint:
@$(MAKE) --no-print-directory _lint-trailing-space
@$(MAKE) --no-print-directory _lint-utf8
@$(MAKE) --no-print-directory _lint-utf8-bom
@$(MAKE) --no-print-directory _lint-git-conflicts

_lint-cr:
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORE_PATHS)' --path .
@docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORE_PATHS)' --path .

_lint-crlf:
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORE_PATHS)' --path .
@docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORE_PATHS)' --path .

_lint-trailing-single-newline:
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORE_PATHS)' --path .
@docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORE_PATHS)' --path .

_lint-trailing-space:
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORE_PATHS)' --path .
@docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORE_PATHS)' --path .

_lint-utf8:
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORE_PATHS)' --path .
@docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORE_PATHS)' --path .

_lint-utf8-bom:
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORE_PATHS)' --path .
@docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORE_PATHS)' --path .

_lint-git-conflicts:
@docker run --rm -v $(PWD):/data cytopia/file-lint:$(FL_VERSION) git-conflicts --text --ignore '$(FL_IGNORE_PATHS)' --path .

```


Expand All @@ -368,6 +382,7 @@ linter below for reproducible local or remote CI tests:
|--------|-----------|------|-------------|
| [awesome-ci][aci-git-lnk] | [![aci-hub-img]][aci-hub-lnk] | Basic | Tools for git, file and static source code analysis |
| [file-lint][flint-git-lnk] | [![flint-hub-img]][flint-hub-lnk] | Basic | Baisc source code analysis |
| [linkcheck][linkcheck-git-lnk] | [![linkcheck-hub-img]][flint-hub-lnk] | Basic | Search for URLs in files and validate their HTTP status code |
| [ansible][ansible-git-lnk] | [![ansible-hub-img]][ansible-hub-lnk] | Ansible | Multiple versions and flavours of Ansible |
| [ansible-lint][alint-git-lnk] | [![alint-hub-img]][alint-hub-lnk] | Ansible | Lint Ansible |
| [gofmt][gfmt-git-lnk] | [![gfmt-hub-img]][gfmt-hub-lnk] | Go | Format Go source code **<sup>[1]</sup>** |
Expand All @@ -381,7 +396,9 @@ linter below for reproducible local or remote CI tests:
| [phplint][plint-git-lnk] | [![plint-hub-img]][plint-hub-lnk] | PHP | PHP Code Linter **<sup>[1]</sup>** |
| [php-cs-fixer][pcsf-git-lnk] | [![pcsf-hub-img]][pcsf-hub-lnk] | PHP | PHP Coding Standards Fixer |
| [black][black-git-lnk] | [![black-hub-img]][black-hub-lnk] | Python | The uncompromising Python code formatter |
| [mypy][mypy-git-lnk] | [![mypy-hub-img]][mypy-hub-lnk] | Python | Static source code analysis |
| [pycodestyle][pycs-git-lnk] | [![pycs-hub-img]][pycs-hub-lnk] | Python | Python style guide checker |
| [pydocstyle][pyds-git-lnk] | [![pyds-hub-img]][pyds-hub-lnk] | Python | Python docstyle checker |
| [pylint][pylint-git-lnk] | [![pylint-hub-img]][pylint-hub-lnk] | Python | Python source code, bug and quality checker |
| [terraform-docs][tfdocs-git-lnk] | [![tfdocs-hub-img]][tfdocs-hub-lnk] | Terraform | Terraform doc generator (TF 0.12 ready) **<sup>[1]</sup>** |
| [terragrunt][tg-git-lnk] | [![tg-hub-img]][tg-hub-lnk] | Terraform | Terragrunt and Terraform |
Expand All @@ -399,6 +416,10 @@ linter below for reproducible local or remote CI tests:
[flint-hub-img]: https://img.shields.io/docker/pulls/cytopia/file-lint.svg
[flint-hub-lnk]: https://hub.docker.com/r/cytopia/file-lint

[linkcheck-git-lnk]: https://github.com/cytopia/docker-linkcheck
[linkcheck-hub-img]: https://img.shields.io/docker/pulls/cytopia/linkcheck.svg
[linkcheck-hub-lnk]: https://hub.docker.com/r/cytopia/linkcheck

[jlint-git-lnk]: https://github.com/cytopia/docker-jsonlint
[jlint-hub-img]: https://img.shields.io/docker/pulls/cytopia/jsonlint.svg
[jlint-hub-lnk]: https://hub.docker.com/r/cytopia/jsonlint
Expand Down Expand Up @@ -451,10 +472,18 @@ linter below for reproducible local or remote CI tests:
[black-hub-img]: https://img.shields.io/docker/pulls/cytopia/black.svg
[black-hub-lnk]: https://hub.docker.com/r/cytopia/black

[mypy-git-lnk]: https://github.com/cytopia/docker-mypy
[mypy-hub-img]: https://img.shields.io/docker/pulls/cytopia/mypy.svg
[mypy-hub-lnk]: https://hub.docker.com/r/cytopia/mypy

[pycs-git-lnk]: https://github.com/cytopia/docker-pycodestyle
[pycs-hub-img]: https://img.shields.io/docker/pulls/cytopia/pycodestyle.svg
[pycs-hub-lnk]: https://hub.docker.com/r/cytopia/pycodestyle

[pyds-git-lnk]: https://github.com/cytopia/docker-pydocstyle
[pyds-hub-img]: https://img.shields.io/docker/pulls/cytopia/pydocstyle.svg
[pyds-hub-lnk]: https://hub.docker.com/r/cytopia/pydocstyle

[pylint-git-lnk]: https://github.com/cytopia/docker-pylint
[pylint-hub-img]: https://img.shields.io/docker/pulls/cytopia/pylint.svg
[pylint-hub-lnk]: https://hub.docker.com/r/cytopia/pylint
Expand Down
4 changes: 2 additions & 2 deletions data/awesome-ci-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -u
#
# Version
#
MY_VERSION="0.16"
MY_DATE="2019-06-15"
MY_VERSION="0.17"
MY_DATE="2020-06-13"

#
# Credits
Expand Down
55 changes: 55 additions & 0 deletions data/git-conflicts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -u

############################################################
# Adjust for each check
############################################################

# Name and messages
MY_NAME="git-conflicts"
MY_DESC="Scans recursively for files containing git conflicts."
MY_FINISH_OK="No files with git conflicts found."
MY_FINISH_ERR="Found files with git conflicts."

# Configuration file prefix
MY_CONF_PRE="GIT_CONFLICTS_"

# Custom required binaries
REQUIRED_CUST_BINS=""

# Binaries required for fixing
REQUIRED_FIX_BINS=""

# Enable custom options (cmd arguments)
# that can be parsed to the actual check binary?
ENABLE_CUST_OPS=0

# When not specifying --custom,
# always use this as the default options
# to parse to the check binary.
DEFAULT_CUST_OPS=""

# How to add your check here:
# ---------------------------
# $1 This comes from xargs and represents
# the current file to work on:
# xargs sh '${MY_CHECK}' --
#
# __CUSTOM_OPT_PLACEHOLDER__
# This will be replaced either with custom options
# or with the default options.
MY_REG="^(<<<<<<<|>>>>>>>)[[:space:]]."
MY_CHECK="grep --color=always -inHE \"${MY_REG}\" \"\$1\" || true"

# Can this check fix the problems?
ENABLE_FIX=0

# Command to be displayed for --info
MY_INFO="grep -V | grep -E '([0-9]+\.+)+'"


############################################################
# Source library
############################################################

. /usr/bin/awesome-ci-lib.sh
1 change: 1 addition & 0 deletions data/usage
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ echo "# file-trailing-single-newline Scans if files contain single trailing new
echo "# file-trailing-space Scans if files contain trailing whitespace #"
echo "# file-utf8 Scans if files are utf8 encoded #"
echo "# file-utf8-bom Scans if files contain byte order mark #"
echo "# git-conflicts Scans if files contain git conflicts #"
echo "# #"
echo "# #"
echo "# Example: #"
Expand Down
8 changes: 8 additions & 0 deletions tests/ok/git-conflicts_ok
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
No git conflicts found
The following are all non-valid delimiter
>>>>>>>
>>>>>>>branch-a
>>>>>>> branch-a

<<<<<<<
<<<<<<<HEAD
<<<<<<< HEAD

0 comments on commit 85bfa8b

Please sign in to comment.