Skip to content

Commit

Permalink
ci: add fix-yamllint rule in Makefile
Browse files Browse the repository at this point in the history
Two rules have been specified for yamlfmt here:
* Automatically add the header `---` to YAML files.
* Preserve line breaks.

ref:
https://github.com/google/yamlfmt/blob/main/docs/config-file.md#configuration-1

Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
  • Loading branch information
tao12345666333 committed May 30, 2023
1 parent bd5d0a5 commit be4f886
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 47 deletions.
6 changes: 1 addition & 5 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ exemptAssignees: false
staleLabel: stale

# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed after 21 days if no further activity
occurs. Thank you for your contributions.
markComment: This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.
Expand Down
23 changes: 2 additions & 21 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [main, release-3.4, release-3.5, release-3.6]
Expand All @@ -20,9 +19,7 @@ on:
branches: [main]
schedule:
- cron: '20 14 * * 5'

permissions: read-all

jobs:
analyze:
name: Analyze
Expand All @@ -31,44 +28,28 @@ jobs:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ['go']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

language: ['go']
steps:
- name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@0225834cc549ee0ca93cb085b92954821a145866 # v2.3.5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

languages: ${{ matrix.language }}
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@0225834cc549ee0ca93cb085b92954821a145866 # v2.3.5

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0225834cc549ee0ca93cb085b92954821a145866 # v2.3.5
14 changes: 7 additions & 7 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ issues:
linters: [ineffassign]
linters:
disable-all: true
enable: # please keep this alphabetized
enable: # please keep this alphabetized
# Don't use soon to deprecated[1] linters that lead to false
# https://github.com/golangci/golangci-lint/issues/1841
# - deadcode
Expand All @@ -23,15 +23,15 @@ linters:
- staticcheck
- stylecheck
- unused
- unconvert # Remove unnecessary type conversions
linters-settings: # please keep this alphabetized
- unconvert # Remove unnecessary type conversions
linters-settings: # please keep this alphabetized
goimports:
local-prefixes: go.etcd.io # Put imports beginning with prefix after 3rd-party packages.
local-prefixes: go.etcd.io # Put imports beginning with prefix after 3rd-party packages.
staticcheck:
checks:
- all
- -SA1019 # TODO(fix) Using a deprecated function, variable, constant or field
- -SA2002 # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn’t allowed
- -SA1019 # TODO(fix) Using a deprecated function, variable, constant or field
- -SA2002 # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn’t allowed
stylecheck:
checks:
- ST1019 # Importing the same package multiple times.
- ST1019 # Importing the same package multiple times.
4 changes: 4 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
formatter:
type: basic
include_document_start: true
retain_line_breaks: true
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fuzz:
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
verify-govet verify-license-header verify-receiver-name verify-mod-tidy verify-shellcheck \
verify-shellws verify-proto-annotations verify-genproto verify-goimport verify-yamllint
fix: fix-bom fix-lint
fix: fix-bom fix-lint fix-yamllint
./scripts/fix.sh

.PHONY: verify-gofmt
Expand Down Expand Up @@ -136,6 +136,13 @@ verify-goimport:
verify-yamllint:
yamllint .

.PHONY: fix-yamllint
fix-yamllint:
ifeq (, $(shell which yamlfmt))
$(shell go install github.com/google/yamlfmt/cmd/yamlfmt@latest)
endif
yamlfmt .

# Cleanup

clean:
Expand Down
17 changes: 4 additions & 13 deletions contrib/mixin/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ tests:
job: etcd
severity: warning
exp_annotations:
description: 'etcd cluster "etcd": 4 leader changes within the last
15 minutes. Frequent elections may be a sign of insufficient resources,
high network latency, or disruptions by other components and should
be investigated.'
description: 'etcd cluster "etcd": 4 leader changes within the last 15 minutes. Frequent elections may be a sign of insufficient resources, high network latency, or disruptions by other components and should be investigated.'
summary: etcd cluster has high number of leader changes.
- interval: 1m
input_series:
Expand Down Expand Up @@ -134,10 +131,7 @@ tests:
job: etcd
severity: warning
exp_annotations:
description: 'etcd cluster "etcd": Predicting running out of disk space
in the next four hours, based on write observations within the past
four hours on etcd instance 10.10.10.0, please check as it might be
disruptive.'
description: 'etcd cluster "etcd": Predicting running out of disk space in the next four hours, based on write observations within the past four hours on etcd instance 10.10.10.0, please check as it might be disruptive.'
summary: etcd cluster database growing very fast.
- interval: 1m
input_series:
Expand All @@ -158,9 +152,6 @@ tests:
job: etcd
severity: warning
exp_annotations:
description: 'etcd cluster "etcd": database size in use on instance
10.10.10.0 is 30% of the actual allocated disk space, please run defragmentation
(e.g. etcdctl defrag) to retrieve the unused fragmented disk space.'
description: 'etcd cluster "etcd": database size in use on instance 10.10.10.0 is 30% of the actual allocated disk space, please run defragmentation (e.g. etcdctl defrag) to retrieve the unused fragmented disk space.'
runbook_url: https://etcd.io/docs/v3.5/op-guide/maintenance/#defragmentation
summary: etcd database size in use is less than 50% of the actual allocated
storage.
summary: etcd database size in use is less than 50% of the actual allocated storage.

0 comments on commit be4f886

Please sign in to comment.