Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce yaml linter #362

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ max_line_length = 100
[Makefile]
indent_style = tab

[scripts/*, *.sh]
[{scripts/*, *.sh}]
max_line_length = 80
indent_style = space
indent_size = 2
Expand All @@ -20,3 +20,7 @@ binary_next_line = true
switch_case_indent = true
space_redirects = true
keep_padding = true

[*.{yaml,yml}]
indent_style = space
indent_size = 2
5 changes: 3 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
Expand All @@ -6,10 +7,10 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: "/"
directory: /
schedule:
interval: weekly
2 changes: 2 additions & 0 deletions .github/probots.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
---

enabled:
- cla
30 changes: 15 additions & 15 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: Analysis

on:
Expand All @@ -6,32 +8,33 @@ on:
pull_request:
branches: [ master ]
schedule:
- cron: '13 7 * * 6'
- cron: 13 7 * * 6

jobs:
linting:
runs-on: ubuntu-latest

steps:
-
name: checkout
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: golangci-lint
- name: golangci-lint
uses: golangci/golangci-lint-action@5c56cd6c9dc07901af25baab6f2b0d9f3b7c3018
with:
version: v1.42.1
version: v1.43.0

-
name: shellcheck
- name: shellcheck
uses: azohra/shell-linter@6bbeaa868df09c34ddc008e6030cfe89c03394a1
with:
path: scripts/*
path: scripts/test-*
severity: error

- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yml

vulnerabilities:
runs-on: ubuntu-latest
Expand All @@ -40,18 +43,15 @@ jobs:
security-events: write

steps:
-
name: checkout
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: initialize
- name: initialize
uses: github/codeql-action/init@v1
with:
languages: go

-
name: codeql analyze
- name: codeql analyze
uses: github/codeql-action/analyze@v1
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---

name: Release

on:
push:
tags: [ 'v*.*.*' ]
tags: [ v*.*.* ]

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -34,7 +36,8 @@ jobs:
-
name: Verify tag signature
run: |
# NOTE: Solve the problem with Github action checkout https://github.com/actions/checkout/issues/290
# NOTE: Solve the problem with Github action checkout
# https://github.com/actions/checkout/issues/290
git fetch --tags --force
version=${GITHUB_REF#refs/tags/*}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: Test

on:
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

linters:
disable-all: true
enable:
Expand Down
47 changes: 23 additions & 24 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

project_name: toxiproxy

env:
Expand Down Expand Up @@ -33,6 +35,7 @@ builds:
ignore:
- goos: windows
goarch: arm64

- goarch: arm

ldflags:
Expand All @@ -43,15 +46,15 @@ builds:
goarch:
- arm
goarm:
- 6
- 7
- "6"
- "7"
ignore:
- goos: windows
goarch: arm
binary: toxiproxy-server-{{.Os}}-{{.Arch}}v{{.Arm}}

- &build_client
<<: *build_default
<<: *build_default
id: client
main: ./cmd/cli
binary: toxiproxy-cli-{{.Os}}-{{.Arch}}
Expand All @@ -61,8 +64,8 @@ builds:
goarch:
- arm
goarm:
- 6
- 7
- "6"
- "7"
ignore:
- goos: windows
goarch: arm
Expand All @@ -86,8 +89,7 @@ snapshot:
name_template: "{{ incpatch .Version }}-next"

nfpms:
-
id: packages
- id: packages
package_name: toxiproxy
homepage: https://github.com/Shopify/toxiproxy
maintainer: Shopify Opensource <opensource@shopify.com>
Expand All @@ -101,10 +103,10 @@ nfpms:
- apk
- deb
- rpm
# NOTE: Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd.
# contents:
# - src: share/toxiproxy.conf
# dst: /etc/init/toxiproxy.conf
# NOTE: Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd.
# contents:
# - src: share/toxiproxy.conf
# dst: /etc/init/toxiproxy.conf

dockers:
- &docker
Expand Down Expand Up @@ -149,7 +151,7 @@ dockers:
- --label=org.opencontainers.image.licenses=MIT
- <<: *docker
goarch: arm
goarm: 7
goarm: "7"
image_templates:
- ghcr.io/shopify/toxiproxy:{{ .Version }}-armv7
- ghcr.io/shopify/toxiproxy:v{{ .Major }}-armv7
Expand All @@ -167,7 +169,7 @@ dockers:
- --label=org.opencontainers.image.licenses=MIT
- <<: *docker
goarch: arm
goarm: 6
goarm: "6"
image_templates:
- ghcr.io/shopify/toxiproxy:{{ .Version }}-armv6
- ghcr.io/shopify/toxiproxy:v{{ .Major }}-armv6
Expand All @@ -185,15 +187,13 @@ dockers:
- --label=org.opencontainers.image.licenses=MIT

docker_manifests:
-
name_template: ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}
- name_template: ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-arm64
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-armv6
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-armv7
-
name_template: ghcr.io/shopify/{{ .ProjectName }}:latest
- name_template: ghcr.io/shopify/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/shopify/{{ .ProjectName }}:{{ .Version }}-arm64
Expand All @@ -204,20 +204,19 @@ changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^Merge'
- "^docs:"
- "^test:"
- ^Merge

archives:
-
id: archive_binaries
- id: archive_binaries
format: binary
name_template: "{{ .Binary }}"
builds:
- server
- client
-
id: archive_default

- id: archive_default
format: tar.gz
builds:
- pkg-server
Expand Down
32 changes: 32 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

yaml-files:
- "*.yaml"
- "*.yml"

ignore: |
vendor/**/*
dist/*.yaml

rules:
comments:
require-starting-space: true
comments-indentation: enable
document-start:
present: true
indentation:
spaces: 2
indent-sequences: true
check-multi-line-strings: true
line-length:
max: 100
level: warning
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: false
key-duplicates: enable
new-lines:
type: unix
trailing-spaces: enable
quoted-strings:
quote-type: double
required: only-when-needed
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Rename `testing/` and `bin/` folders (#354, @strech)
* Added verbose error on proxy upstream dialing (#355, @f-dg)
* Improve server startup message (#358, @areveny)
* Introduce yaml linter. (#362, @miry)

# [2.3.0] - 2021-12-23

Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ fmt:
go fmt ./...
goimports -w **/*.go
golangci-lint run --fix
shfmt -l -s -w -kp -i 2 scripts/* Dockerfile Makefile
shfmt -l -s -w -kp -i 2 scripts/test-*

.PHONY: lint
lint:
golangci-lint run
shellcheck scripts/*
shfmt -l -s -d -kp -i 2 scripts/*
shellcheck scripts/test-*
shfmt -l -s -d -kp -i 2 scripts/test-*
yamllint .

.PHONY: build
build: dist clean
Expand Down
7 changes: 6 additions & 1 deletion dev.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
---

name: toxiproxy

type: go

up:
- homebrew:
- gnu-tar
- goreleaser
- golangci-lint
- goreleaser
- shellcheck
- shfmt
- yamllint
- go:
version: 1.17
modules: true
4 changes: 2 additions & 2 deletions scripts/test-release
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ $server --version | grep -o -e "toxiproxy-server version ${VERSION}"
goreleaser build --rm-dist --single-target --skip-validate --id client
bineries=(./dist/toxiproxy-cli-*)
cli="${bineries[0]}"
$cli --help 2>&1 \
| grep -o -e "toxiproxy-cli - Simulate network and system conditions"
$cli --help 2>&1 |
grep -o -e "toxiproxy-cli - Simulate network and system conditions"
$cli --version | grep -o -e "toxiproxy-cli version ${VERSION}"