Skip to content

Commit

Permalink
Introduce yamllint
Browse files Browse the repository at this point in the history
Add yamllint and update the yml files accordingly.
  • Loading branch information
miry committed Jan 24, 2022
1 parent 526c8aa commit e7176f4
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 53 deletions.
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 .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

linters:
disable-all: true
enable:
Expand Down
55 changes: 28 additions & 27 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 @@ -31,7 +33,8 @@ builds:
- arm64

ignore:
- goos: windows
-
goos: windows
goarch: arm64
- goarch: arm

Expand All @@ -43,15 +46,16 @@ builds:
goarch:
- arm
goarm:
- 6
- 7
- "6"
- "7"
ignore:
- goos: windows
-
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,10 +65,11 @@ builds:
goarch:
- arm
goarm:
- 6
- 7
- "6"
- "7"
ignore:
- goos: windows
-
goos: windows
goarch: arm
binary: toxiproxy-cli-{{.Os}}-{{.Arch}}v{{.Arm}}

Expand All @@ -86,8 +91,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 +105,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 +153,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 +171,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 +189,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 +206,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
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}"

0 comments on commit e7176f4

Please sign in to comment.