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

Yaml linter #3358

Merged
merged 14 commits into from
Sep 6, 2023
Merged
23 changes: 7 additions & 16 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -11,27 +12,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

changelog:
exclude:
labels:
- duplicate
- question
- invalid
- wontfix
labels: [duplicate, question, invalid, wontfix]
categories:
- title: Breaking changes
labels:
- kind/breaking
labels: [kind/breaking]
- title: Implemented enhancements
labels:
- kind/feature
labels: [kind/feature]
- title: Fixed bugs
labels:
- kind/bug
labels: [kind/bug]
- title: Security fixes
labels:
- area/security
labels: [area/security]
- title: Other
labels:
- "*"
labels: ['*']
35 changes: 16 additions & 19 deletions .github/workflows/close.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,31 +19,27 @@
# For more information, see:
# https://github.com/actions/stale
name: Close Old

on:
workflow_dispatch:
schedule:
- cron: '0 1 1,15 * *'

- cron: 0 1 1,15 * *
jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write


steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 30
close-issue-message: >
We are closing this as there was no activity in this issue for last 90 days. Please reopen if you’d like to discuss anything further.
only-labels: 'obsolete'
exempt-issue-labels: awaiting-maintainer
ascending: true
days-before-close: 0
close-issue-reason: "not_planned"
stale-issue-label: 'wontfix'
enable-statistics: true
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 30
close-issue-message: >
We are closing this as there was no activity in this issue for last 90
days. Please reopen if you’d like to discuss anything further.
only-labels: obsolete
exempt-issue-labels: awaiting-maintainer
ascending: true
days-before-close: 0
close-issue-reason: not_planned
stale-issue-label: wontfix
enable-statistics: true
9 changes: 3 additions & 6 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,12 +15,8 @@
#
# This workflow utilizes https://github.com/actions/github-script in GitHub Actions to apply labels to pull requests.
#

name: Label PR

on:
- pull_request_target

on: [pull_request_target]
jobs:
label:
runs-on: ubuntu-latest
Expand All @@ -30,7 +27,7 @@ jobs:
- name: Label PR
uses: actions/github-script@v4
with:
script: |
script: |-
const keywords = {
"breaking": "kind/breaking",
"bug": "kind/bug",
Expand Down
37 changes: 17 additions & 20 deletions .github/workflows/obsolete.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -16,33 +17,29 @@
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues obsolete

on:
schedule:
- cron: '0 2 1,15 * *'
- cron: 0 2 1,15 * *
workflow_dispatch:


jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
name: Track Obsolete Issues

steps:
- name: Track stale issues and check if obsolete
uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 30
stale-issue-message: >
This issue is marked as obsolete due to inactivity for last 60 days.
To avoid issue getting closed in next 30 days, please add a comment or add 'awaiting-maintainer' label. Thank you for your contributions
stale-issue-label: 'obsolete'
only-labels: 'stale'
exempt-issue-labels: awaiting-maintainer
remove-stale-when-updated: true
ascending: true
enable-statistics: true
- name: Track stale issues and check if obsolete
uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 30
stale-issue-message: >
This issue is marked as obsolete due to inactivity for last 60 days. To
avoid issue getting closed in next 30 days, please add a comment or add
'awaiting-maintainer' label. Thank you for your contributions
stale-issue-label: obsolete
only-labels: stale
exempt-issue-labels: awaiting-maintainer
remove-stale-when-updated: true
ascending: true
enable-statistics: true
12 changes: 5 additions & 7 deletions .github/workflows/pr_update.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,13 +17,10 @@
# `main`. `update-pr-branch` will pick the oldest PR (by creation date) that is approved
# with auto-merge enabled and update it to the latest `main`, forming a best-effort queue
# of approved PRs.

name: PR update

on:
push:
branches:
- "main"
branches: [main]
jobs:
autoupdate:
runs-on: ubuntu-latest
Expand All @@ -31,8 +29,8 @@ jobs:
uses: adRise/update-pr-branch@v0.6.0
with:
token: ${{ secrets.AGONES_BOT }}
base: "main"
base: main
required_approval_count: 1
require_passed_checks: true
sort: "created"
direction: "asc"
sort: created
direction: asc
36 changes: 17 additions & 19 deletions .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -15,32 +16,29 @@
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale

name: Mark stale
on:
workflow_dispatch:
schedule:
- cron: '0 10 1,15 * *'

- cron: 0 10 1,15 * *
jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
name: stale issues

steps:
- name: Stale issues
uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 30
days-before-issue-close: 60
stale-issue-message: >
'This issue is marked as Stale due to inactivity for more than 30 days.
To avoid being marked as 'stale' please add 'awaiting-maintainer' label or add a comment. Thank you for your contributions '
stale-issue-label: 'stale'
exempt-issue-labels: 'awaiting-maintainer, obsolete'
ascending: true
enable-statistics: true
- name: Stale issues
uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 30
days-before-issue-close: 60
stale-issue-message: >
'This issue is marked as Stale due to inactivity for more than 30 days. To
avoid being marked as 'stale' please add 'awaiting-maintainer' label or
add a comment. Thank you for your contributions '
stale-issue-label: stale
exempt-issue-labels: awaiting-maintainer, obsolete
ascending: true
enable-statistics: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

.*
!/.yamllint
!.gitignore
!.helmignore
!.gitattributes
Expand Down
24 changes: 6 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# This file contains all available configuration options
# with their default values.

# options for analysis running
run:
# default concurrency is a available CPU number
Expand Down Expand Up @@ -31,9 +31,7 @@ run:
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files:

modules-download-mode: vendor

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
Expand All @@ -44,7 +42,6 @@ output:

# print linter name in the end of issue text, default is true
print-linter-name: true

linters:
enable:
- bodyclose
Expand All @@ -62,7 +59,6 @@ linters:
- staticcheck
- unconvert
- unparam

linters-settings:
govet:
disable-all: false
Expand All @@ -71,32 +67,24 @@ linters-settings:
# extremely noisy, also against common Go style in most cases
- shadow
gocritic:
enabled-tags:
- performance
- opinionated
- diagnostic
disabled-checks:
- paramTypeCombine
- unnamedResult
- unnecessaryDefer
settings: # settings passed to gocritic
enabled-tags: [performance, opinionated, diagnostic]
disabled-checks: [paramTypeCombine, unnamedResult, unnecessaryDefer]
settings: # settings passed to gocritic
hugeParam:
sizeThreshold: 512
rangeValCopy:
sizeThreshold: 512
skipTestFuncs: true

issues:
# This turns off the default excludes - which was causing the linter
# to miss things like erroneous comments
exclude-use-default: false
exclude:
- Using the variable on range scope .* in function literal
exclude: [Using the variable on range scope .* in function literal]
exclude-rules:
# Skip fieldalignment checks on:
# - tests: memory footprint doesn't matter
# - cmd/: we assume these are one-off config entries
# - pkg/apis: Keep strong convention on TypeMeta/ObjectMeta/Spec/Status
- path: '(.+)_test\.go|^test/|^cmd/.*|^pkg/apis/.*'
- path: (.+)_test\.go|^test/|^cmd/.*|^pkg/apis/.*
# fieldalignment is in the `govet` linter, so exclude based on text instead of all of govet
text: '^fieldalignment: .*'
6 changes: 6 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: default

rules:
truthy: disable
Copy link
Collaborator

@zmerlynn zmerlynn Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a lot of violations of truthy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of our GitHub Actions workflow scripts use the on keyword, and we cannot replace it with true. Therefore, I've disabled that specific check.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the GitHub Actions parser is looking for on and not true? Huh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right..

line-length:
max: 1500
4 changes: 3 additions & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ build-extensions-binary-linux-arm64: $(ensure-build-image)
lint: LINT_TIMEOUT ?= 15m
lint: $(ensure-build-image)
docker run -t -e "TERM=xterm-256color" -e "$(gomod_on)" --rm $(common_mounts) -w $(workdir_path) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
"golangci-lint run ./examples/... && golangci-lint run --timeout $(LINT_TIMEOUT) ./..."
"golangci-lint run ./examples/... && \
golangci-lint run --timeout $(LINT_TIMEOUT) ./... && \
find ../ -name '*.yml' -o -name '*.yaml' | grep -v -e './install/' -e './sdks' -e './test/sdk' -e './site/node_modules' -e './vendor' -e './site/themes/docsy' -e './build/.gomod' | xargs yamllint"

# Extract licenses from source tree
build-licenses:
Expand Down
Loading
Loading