Skip to content

Commit

Permalink
chore: Add editorconfig-checker check
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Dec 18, 2023
1 parent eb35f63 commit 07ef06e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .ecrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Exclude": [
"^completions/"
]
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ charset = utf-8
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
indent_size = 4
indent_style = space

[*.sh]
indent_size = 1
indent_style = tab

[{*.yaml,*.yml}]
indent_size = 2
indent_style = space
9 changes: 8 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
ACTIONLINT_VERSION: 1.6.26
AGE_VERSION: 1.1.1
CHOCOLATEY_VERSION: 2.2.2
EDITORCONFIG_CHECKER_VERSION: 2.7.2
GO_VERSION: 1.21.5
GOFUMPT_VERSION: 0.5.0
GOLANGCI_LINT_VERSION: 1.55.2
Expand Down Expand Up @@ -319,6 +320,12 @@ jobs:
- uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
with:
ignore_paths: completions
- name: editorconfig-checker
run: |
GOOS="$(go env GOOS)"
GOARCH="$(go env GOARCH)"
curl -sSfL "https://github.com/editorconfig-checker/editorconfig-checker/releases/download/${EDITORCONFIG_CHECKER_VERSION}/ec-${GOOS}-${GOARCH}.tar.gz" | tar -xzf -
"bin/ec-${GOOS}-${GOARCH}"
- name: lint-whitespace
run: |
go run ./internal/cmds/lint-whitespace
Expand All @@ -334,7 +341,7 @@ jobs:
run: |
go run ./internal/cmds/lint-commit-messages HEAD~1..HEAD
- name: lint-commit-messages
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
run: |
go run ./internal/cmds/lint-commit-messages ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }}..${{ github.event.pull_request.head.sha }}
lint:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/COMMIT
/bin/actionlint
/bin/chezmoi
/bin/editorconfig-checker
/bin/find-typos
/bin/gofumpt
/bin/golines
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
GO?=go
GOOS=$(shell ${GO} env GOOS)
GOARCH=$(shell ${GO} env GOARCH)
ACTIONLINT_VERSION=$(shell awk '/ACTIONLINT_VERSION:/ { print $$2 }' .github/workflows/main.yml)
EDITORCONFIG_CHECKER_VERSION=$(shell awk '/EDITORCONFIG_CHECKER_VERSION:/ { print $$2 }' .github/workflows/main.yml)
FIND_TYPOS_VERSION=$(shell awk '/FIND_TYPOS_VERSION:/ { print $$2 }' .github/workflows/main.yml)
GOFUMPT_VERSION=$(shell awk '/GOFUMPT_VERSION:/ { print $$2 }' .github/workflows/main.yml)
GOLANGCI_LINT_VERSION=$(shell awk '/GOLANGCI_LINT_VERSION:/ { print $$2 }' .github/workflows/main.yml)
Expand Down Expand Up @@ -110,8 +113,9 @@ generate:
${GO} generate

.PHONY: lint
lint: ensure-actionlint ensure-find-typos ensure-golangci-lint
lint: ensure-actionlint ensure-editorconfig-checker ensure-find-typos ensure-golangci-lint
./bin/actionlint
./bin/editorconfig-checker
./bin/golangci-lint run
${GO} run ./internal/cmds/lint-whitespace
find . -name \*.txtar | xargs ${GO} run ./internal/cmds/lint-txtar
Expand Down Expand Up @@ -142,6 +146,13 @@ ensure-actionlint:
GOBIN=$(shell pwd)/bin ${GO} install "github.com/rhysd/actionlint/cmd/actionlint@v${ACTIONLINT_VERSION}" ; \
fi

.PHONY: ensure-editorconfig-checker
ensure-editorconfig-checker:
if [ ! -x bin/editorconfig-checker ] || ( ./bin/editorconfig-checker --version | grep -Fqv "v${EDITORCONFIG_CHECKER_VERSION}" ) ; then \
curl -sSfL "https://github.com/editorconfig-checker/editorconfig-checker/releases/download/${EDITORCONFIG_CHECKER_VERSION}/ec-${GOOS}-${GOARCH}.tar.gz" | tar -xzf - ; \
mv "bin/ec-${GOOS}-${GOARCH}" bin/editorconfig-checker ; \
fi

.PHONY: ensure-find-typos
ensure-find-typos:
if [ ! -x bin/find-typos ] ; then \
Expand Down
6 changes: 3 additions & 3 deletions assets/scripts/install-local-bin.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions assets/scripts/install.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/cmds/generate-install.sh/install.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ usage() {
${this}: download chezmoi and optionally run chezmoi
Usage: ${this} [-b bindir] [-d] [-t tag] [chezmoi-args]
-b sets the installation directory, default is ${BINDIR}.
-d enables debug logging.
-t sets the tag, default is ${TAG}.
-b sets the installation directory, default is ${BINDIR}.
-d enables debug logging.
-t sets the tag, default is ${TAG}.
If chezmoi-args are given, after install chezmoi is executed with chezmoi-args.
EOF
exit 2
Expand Down

0 comments on commit 07ef06e

Please sign in to comment.