Skip to content

Commit

Permalink
YAML linter (googleforgames#3358)
Browse files Browse the repository at this point in the history
Adds a YAML linter to CI, using https://yamllint.readthedocs.io/
  • Loading branch information
Kalaiselvi84 authored Sep 6, 2023
1 parent 61056b0 commit 130beb1
Show file tree
Hide file tree
Showing 85 changed files with 1,252 additions and 1,371 deletions.
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/[email protected]
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: .*'
18 changes: 18 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
extends: default

rules:
truthy: disable
line-length:
max: 1500

ignore:
- /build/.gomod/
- /install/
- /sdks/
- /test/sdk/
- /test/terraform/vendor/
- /site/node_modules/
- /site/themes/docsy/
- /site/vendor/
- /vendor/
6 changes: 4 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,14 @@ build-extensions-binary-linux-arm64: $(ensure-build-image)
-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/extensions/bin/extensions.linux.arm64 \
$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/extensions

# Lint the go source code.
# Lint the go source code and yaml files.
# use LINT_TIMEOUT to manipulate the linter timeout
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) ./... && \
yamllint ."

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

0 comments on commit 130beb1

Please sign in to comment.