Skip to content

Commit 5048136

Browse files
committed
chore(ci): Add yaml and action formatter/linter to CI
Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent 353b888 commit 5048136

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

.github/actionlint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# actionlint configuration
2+
# https://github.com/rhysd/actionlint/blob/main/docs/config.md

.github/workflows/validate.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,22 @@ jobs:
6969
- name: Run style and unused
7070
if: ${{ matrix.go_version == '1.22' }}
7171
run: make style unused
72+
73+
lint:
74+
name: Lint
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
79+
80+
- name: Set up Go
81+
uses: actions/[email protected]
82+
with:
83+
go-version: stable
84+
check-latest: true
85+
86+
- name: Lint YAML files
87+
run: make lint-yaml
88+
89+
- name: Lint GitHub Actions workflows
90+
run: make lint-actions

.yamlfmt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# yamlfmt configuration
2+
# https://github.com/google/yamlfmt
3+
4+
doublestar: true
5+
6+
exclude:
7+
- "**/testdata/**"
8+
- "**/*testdata*/**"
9+
10+
gitignore_excludes: true
11+
12+
formatter:
13+
type: basic
14+
indent: 2
15+
include_document_start: false
16+
retain_line_breaks: true
17+
max_line_length: 0

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,30 @@ test-exp:
6666
test-exp-short:
6767
cd exp && $(GOTEST) -short $(GOOPTS) $(pkgs)
6868

69+
YAMLFMT := $(FIRST_GOPATH)/bin/yamlfmt
70+
ACTIONLINT := $(FIRST_GOPATH)/bin/actionlint
71+
72+
$(YAMLFMT):
73+
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
74+
75+
$(ACTIONLINT):
76+
go install github.com/rhysd/actionlint/cmd/actionlint@latest
77+
78+
.PHONY: format-yaml
79+
format-yaml: $(YAMLFMT)
80+
@echo ">> formatting YAML files"
81+
$(YAMLFMT) -dstar '**/*.yml' '**/*.yaml'
82+
83+
.PHONY: lint-yaml
84+
lint-yaml: $(YAMLFMT)
85+
@echo ">> linting YAML files"
86+
$(YAMLFMT) -lint -dstar '**/*.yml' '**/*.yaml'
87+
88+
.PHONY: lint-actions
89+
lint-actions: $(ACTIONLINT)
90+
@echo ">> linting GitHub Actions workflows"
91+
$(ACTIONLINT)
92+
6993
.PHONY: check-crlf
7094
check-crlf:
7195
@echo ">> checking for CRLF line endings"

0 commit comments

Comments
 (0)