Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
build: replace find command to git ls-files and grep command
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Jan 12, 2020
1 parent 0234011 commit 6d07b29
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .cmdx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ tasks:
- name: shellcheck
description: shellcheck
usage: shellcheck
script: 'find . -name "*.sh" -print0 | xargs -0 shellcheck env.sh.tmpl'
script: bash scripts/shellcheck.sh
- name: shfmt
description: shfmt
usage: shfmt
script: 'find . -name "*.sh" -print0 | xargs -0 shfmt -l -w env.sh.tmpl'
script: 'git ls-files | grep -E ".*\.sh$" | xargs shfmt -l -w env.sh.tmpl'
- name: yamllint
description: yamllint
usage: yamllint
script: 'find . \( -name "*.yml" -o -name "*.yaml" \) -print0 | xargs -0 yamllint -c .yamllint.yml'
script: bash scripts/yamllint.sh
- name: jsonlint
description: jsonlint
usage: jsonlint
Expand Down
14 changes: 10 additions & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
kind: pipeline
name: durl
steps:
- name: list files
image: plugins/git
commands:
- git ls-files > list.txt
- name: durl
image: quay.io/suzuki_shunsuke/durl:1.0.0
commands:
- sh scripts/durl.sh
- cat list.txt | durl check
---
kind: pipeline
name: shell scripts
Expand All @@ -15,19 +19,21 @@ steps:
- name: shellcheck
image: koalaman/shellcheck-alpine:v0.7.0
commands:
- 'find . -name "*.sh" -print0 | xargs -0 shellcheck env.sh.tmpl'
- apk add git
- sh scripts/shellcheck.sh
- name: shfmt
image: mvdan/shfmt:v3.0.0
commands:
- 'find . -name "*.sh" -print0 | xargs -0 shfmt -l -w env.sh.tmpl'
- 'shfmt -d . env.sh.tmpl'
---
kind: pipeline
name: yamllint
steps:
- name: yamllint
image: quay.io/suzuki_shunsuke/yamllint:1.20.0__1
commands:
- 'find . \( -name "*.yml" -o -name "*.yaml" \) -print0 | xargs -0 yamllint -c .yamllint.yml'
- apk add git
- sh scripts/yamllint.sh
---
kind: pipeline
name: jsonlint
Expand Down
7 changes: 1 addition & 6 deletions scripts/durl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ set -o pipefail

cd "$(dirname "$0")/.."

find . \
-type d -name .git -prune -o \
-type d -name .terraform -prune -o \
-type d -name dist -prune -o \
-type f -print |
durl check
git ls-files | durl check
7 changes: 3 additions & 4 deletions scripts/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -eu
set -o pipefail

find . \
-type d -name .git -prune -o \
-type f -name "*.go" -print0 |
xargs -0 gofmt -l -s -w
cd "$(dirname "$0")/.."

git ls-files | grep -E ".*\.go$" | xargs gofmt -l -s -w
7 changes: 1 addition & 6 deletions scripts/jsonlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@ while read -r f; do
if ! jsonlint -q "$f" > /dev/null 2>&1; then
ee jsonlint "$f"
fi
done < <(
find . \
-type d -name .git -prune -o \
-type d -name .terraform -prune -o \
-type f -name "*.json" -print
)
done < <(git ls-files | grep -E ".*\.json")
8 changes: 8 additions & 0 deletions scripts/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

cd "$(dirname "$0")/.."

git ls-files | grep -E ".*\.sh$" | xargs shellcheck env.sh.tmpl
8 changes: 8 additions & 0 deletions scripts/yamllint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

cd "$(dirname "$0")/.."

git ls-files | grep -E ".*\.ya?ml$" | xargs yamllint -c .yamllint.yml

0 comments on commit 6d07b29

Please sign in to comment.