Add `yamllint` (#26965)

So that https://github.com/go-gitea/gitea/pull/26964 does not happen
again. Merge this after that PR. Config is based on
[node's](https://github.com/nodejs/node/blob/main/.yamllint.yaml).

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.com>
This commit is contained in:
silverwind 2023-09-08 04:24:06 +02:00 committed by GitHub
parent f9abb6ade2
commit 3c0c279658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 281 additions and 187 deletions

View File

@ -154,7 +154,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: plugins/docker:latest image: plugins/docker:latest
@ -176,7 +176,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
--- ---
kind: pipeline kind: pipeline
@ -220,7 +220,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: plugins/docker:latest image: plugins/docker:latest
@ -241,7 +241,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
--- ---
kind: pipeline kind: pipeline
@ -289,7 +289,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: plugins/docker:latest image: plugins/docker:latest
@ -311,7 +311,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
--- ---
kind: pipeline kind: pipeline
@ -355,7 +355,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: plugins/docker:latest image: plugins/docker:latest
@ -376,7 +376,7 @@ steps:
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
--- ---
kind: pipeline kind: pipeline
@ -413,7 +413,7 @@ steps:
trigger: trigger:
ref: ref:
- "refs/tags/**" - "refs/tags/**"
paths: paths:
exclude: exclude:
- "docs/**" - "docs/**"

View File

@ -156,7 +156,7 @@ rules:
import/no-restricted-paths: [0] import/no-restricted-paths: [0]
import/no-self-import: [2] import/no-self-import: [2]
import/no-unassigned-import: [0] import/no-unassigned-import: [0]
import/no-unresolved: [2, {commonjs: true, ignore: [\?.+$, ^vitest/]}] import/no-unresolved: [2, {commonjs: true, ignore: ["\\?.+$", ^vitest/]}]
import/no-unused-modules: [2, {unusedExports: true}] import/no-unused-modules: [2, {unusedExports: true}]
import/no-useless-path-segments: [2, {commonjs: true}] import/no-useless-path-segments: [2, {commonjs: true}]
import/no-webpack-loader-syntax: [2] import/no-webpack-loader-syntax: [2]

View File

@ -2,90 +2,90 @@ name: Bug Report
description: Found something you weren't expecting? Report it here! description: Found something you weren't expecting? Report it here!
labels: ["kind/bug"] labels: ["kind/bug"]
body: body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue. NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue.
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
1. Please speak English, this is the language all maintainers can speak and write. 1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord 2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Make sure you are using the latest release and 3. Make sure you are using the latest release and
take a moment to check that your issue hasn't been reported before. take a moment to check that your issue hasn't been reported before.
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq) 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq)
5. It's really important to provide pertinent details and logs (https://docs.gitea.com/help/support), 5. It's really important to provide pertinent details and logs (https://docs.gitea.com/help/support),
incomplete details will be handled as an invalid report. incomplete details will be handled as an invalid report.
- type: textarea - type: textarea
id: description id: description
attributes: attributes:
label: Description label: Description
description: | description: |
Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below) Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below)
If you are using a proxy or a CDN (e.g. Cloudflare) in front of Gitea, please disable the proxy/CDN fully and access Gitea directly to confirm the issue still persists without those services. If you are using a proxy or a CDN (e.g. Cloudflare) in front of Gitea, please disable the proxy/CDN fully and access Gitea directly to confirm the issue still persists without those services.
- type: input - type: input
id: gitea-ver id: gitea-ver
attributes: attributes:
label: Gitea Version label: Gitea Version
description: Gitea version (or commit reference) of your instance description: Gitea version (or commit reference) of your instance
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
id: can-reproduce id: can-reproduce
attributes: attributes:
label: Can you reproduce the bug on the Gitea demo site? label: Can you reproduce the bug on the Gitea demo site?
description: | description: |
If so, please provide a URL in the Description field If so, please provide a URL in the Description field
URL of Gitea demo: https://try.gitea.io URL of Gitea demo: https://try.gitea.io
options: options:
- "Yes" - "Yes"
- "No" - "No"
validations: validations:
required: true required: true
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
It's really important to provide pertinent logs It's really important to provide pertinent logs
Please read https://docs.gitea.com/administration/logging-config#collecting-logs-for-help Please read https://docs.gitea.com/administration/logging-config#collecting-logs-for-help
In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini
- type: input - type: input
id: logs id: logs
attributes: attributes:
label: Log Gist label: Log Gist
description: Please provide a gist URL of your logs, with any sensitive information (e.g. API keys) removed/hidden description: Please provide a gist URL of your logs, with any sensitive information (e.g. API keys) removed/hidden
- type: textarea - type: textarea
id: screenshots id: screenshots
attributes: attributes:
label: Screenshots label: Screenshots
description: If this issue involves the Web Interface, please provide one or more screenshots description: If this issue involves the Web Interface, please provide one or more screenshots
- type: input - type: input
id: git-ver id: git-ver
attributes: attributes:
label: Git Version label: Git Version
description: The version of git running on the server description: The version of git running on the server
- type: input - type: input
id: os-ver id: os-ver
attributes: attributes:
label: Operating System label: Operating System
description: The operating system you are using to run Gitea description: The operating system you are using to run Gitea
- type: textarea - type: textarea
id: run-info id: run-info
attributes: attributes:
label: How are you running Gitea? label: How are you running Gitea?
description: | description: |
Please include information on whether you built Gitea yourself, used one of our downloads, are using https://try.gitea.io or are using some other package Please include information on whether you built Gitea yourself, used one of our downloads, are using https://try.gitea.io or are using some other package
Please also tell us how you are running Gitea, e.g. if it is being run from docker, a command-line, systemd etc. Please also tell us how you are running Gitea, e.g. if it is being run from docker, a command-line, systemd etc.
If you are using a package or systemd tell us what distribution you are using If you are using a package or systemd tell us what distribution you are using
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
id: database id: database
attributes: attributes:
label: Database label: Database
description: What database system are you running? description: What database system are you running?
options: options:
- PostgreSQL - PostgreSQL
- MySQL/MariaDB - MySQL/MariaDB
- MSSQL - MSSQL
- SQLite - SQLite

View File

@ -2,23 +2,23 @@ name: Feature Request
description: Got an idea for a feature that Gitea doesn't have currently? Submit your idea here! description: Got an idea for a feature that Gitea doesn't have currently? Submit your idea here!
labels: ["kind/proposal"] labels: ["kind/proposal"]
body: body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
1. Please speak English, this is the language all maintainers can speak and write. 1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord 2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Please take a moment to check that your feature hasn't already been suggested. 3. Please take a moment to check that your feature hasn't already been suggested.
- type: textarea - type: textarea
id: description id: description
attributes: attributes:
label: Feature Description label: Feature Description
placeholder: | placeholder: |
I think it would be great if Gitea had... I think it would be great if Gitea had...
validations: validations:
required: true required: true
- type: textarea - type: textarea
id: screenshots id: screenshots
attributes: attributes:
label: Screenshots label: Screenshots
description: If you can, provide screenshots of an implementation on another site e.g. GitHub description: If you can, provide screenshots of an implementation on another site e.g. GitHub

View File

@ -2,65 +2,65 @@ name: Web Interface Bug Report
description: Something doesn't look quite as it should? Report it here! description: Something doesn't look quite as it should? Report it here!
labels: ["kind/bug", "kind/ui"] labels: ["kind/bug", "kind/ui"]
body: body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue. NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue.
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
1. Please speak English, this is the language all maintainers can speak and write. 1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord 2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Please take a moment to check that your issue doesn't already exist. 3. Please take a moment to check that your issue doesn't already exist.
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq) 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq)
5. Please give all relevant information below for bug reports, because 5. Please give all relevant information below for bug reports, because
incomplete details will be handled as an invalid report. incomplete details will be handled as an invalid report.
6. In particular it's really important to provide pertinent logs. If you are certain that this is a javascript 6. In particular it's really important to provide pertinent logs. If you are certain that this is a javascript
error, show us the javascript console. If the error appears to relate to Gitea the server you must also give us error, show us the javascript console. If the error appears to relate to Gitea the server you must also give us
DEBUG level logs. (See https://docs.gitea.com/administration/logging-config#collecting-logs-for-help) DEBUG level logs. (See https://docs.gitea.com/administration/logging-config#collecting-logs-for-help)
- type: textarea - type: textarea
id: description id: description
attributes: attributes:
label: Description label: Description
description: | description: |
Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below) Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below)
If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services. If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services.
- type: textarea - type: textarea
id: screenshots id: screenshots
attributes: attributes:
label: Screenshots label: Screenshots
description: Please provide at least 1 screenshot showing the issue. description: Please provide at least 1 screenshot showing the issue.
validations: validations:
required: true required: true
- type: input - type: input
id: gitea-ver id: gitea-ver
attributes: attributes:
label: Gitea Version label: Gitea Version
description: Gitea version (or commit reference) your instance is running description: Gitea version (or commit reference) your instance is running
validations: validations:
required: true required: true
- type: dropdown - type: dropdown
id: can-reproduce id: can-reproduce
attributes: attributes:
label: Can you reproduce the bug on the Gitea demo site? label: Can you reproduce the bug on the Gitea demo site?
description: | description: |
If so, please provide a URL in the Description field If so, please provide a URL in the Description field
URL of Gitea demo: https://try.gitea.io URL of Gitea demo: https://try.gitea.io
options: options:
- "Yes" - "Yes"
- "No" - "No"
validations: validations:
required: true required: true
- type: input - type: input
id: os-ver id: os-ver
attributes: attributes:
label: Operating System label: Operating System
description: The operating system you are using to access Gitea description: The operating system you are using to access Gitea
- type: input - type: input
id: browser-ver id: browser-ver
attributes: attributes:
label: Browser Version label: Browser Version
description: The browser and version that you are using to access Gitea description: The browser and version that you are using to access Gitea
validations: validations:
required: true required: true

1
.github/labeler.yml vendored
View File

@ -22,3 +22,4 @@ kind/lint:
- ".markdownlint.yaml" - ".markdownlint.yaml"
- ".spectral.yaml" - ".spectral.yaml"
- ".stylelintrc.yaml" - ".stylelintrc.yaml"
- ".yamllint.yaml"

View File

@ -17,6 +17,8 @@ on:
value: ${{ jobs.detect.outputs.docker }} value: ${{ jobs.detect.outputs.docker }}
swagger: swagger:
value: ${{ jobs.detect.outputs.swagger }} value: ${{ jobs.detect.outputs.swagger }}
yaml:
value: ${{ jobs.detect.outputs.yaml }}
jobs: jobs:
detect: detect:
@ -30,6 +32,7 @@ jobs:
templates: ${{ steps.changes.outputs.templates }} templates: ${{ steps.changes.outputs.templates }}
docker: ${{ steps.changes.outputs.docker }} docker: ${{ steps.changes.outputs.docker }}
swagger: ${{ steps.changes.outputs.swagger }} swagger: ${{ steps.changes.outputs.swagger }}
yaml: ${{ steps.changes.outputs.yaml }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: dorny/paths-filter@v2 - uses: dorny/paths-filter@v2
@ -82,3 +85,8 @@ jobs:
- "package.json" - "package.json"
- "package-lock.json" - "package-lock.json"
- ".spectral.yaml" - ".spectral.yaml"
yaml:
- "**/*.yml"
- "**/*.yaml"
- ".yamllint.yaml"

View File

@ -39,6 +39,19 @@ jobs:
- run: make deps-py - run: make deps-py
- run: make lint-templates - run: make lint-templates
lint-yaml:
if: needs.files-changed.outputs.yaml == 'true'
needs: files-changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install poetry
- run: make deps-py
- run: make lint-yaml
lint-swagger: lint-swagger:
if: needs.files-changed.outputs.swagger == 'true' if: needs.files-changed.outputs.swagger == 'true'
needs: files-changed needs: files-changed

View File

@ -88,7 +88,7 @@ jobs:
mysql: mysql:
image: mysql:5.7 image: mysql:5.7
env: env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: test MYSQL_DATABASE: test
ports: ports:
- "3306:3306" - "3306:3306"
@ -160,7 +160,7 @@ jobs:
mysql: mysql:
image: mysql:5.7 image: mysql:5.7
env: env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: test MYSQL_DATABASE: test
ports: ports:
- "3306:3306" - "3306:3306"
@ -205,7 +205,7 @@ jobs:
mysql8: mysql8:
image: mysql:8 image: mysql:8
env: env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: testgitea MYSQL_DATABASE: testgitea
ports: ports:
- "3306:3306" - "3306:3306"

48
.yamllint.yaml Normal file
View File

@ -0,0 +1,48 @@
extends: default
rules:
braces:
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0
brackets:
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: 0
max-spaces-inside-empty: 0
comments:
require-starting-space: true
ignore-shebangs: true
min-spaces-from-content: 1
comments-indentation:
level: error
document-start:
level: error
present: false
ignore: |
/.drone.yml
document-end:
present: false
empty-lines:
max: 1
indentation:
spaces: 2
line-length: disable
truthy:
allowed-values: ["true", "false", "on", "off"]
ignore: |
.venv
node_modules
/models/fixtures
/models/migrations/fixtures

View File

@ -218,6 +218,7 @@ help:
@echo " - lint-md lint markdown files" @echo " - lint-md lint markdown files"
@echo " - lint-swagger lint swagger files" @echo " - lint-swagger lint swagger files"
@echo " - lint-templates lint template files" @echo " - lint-templates lint template files"
@echo " - lint-yaml lint yaml files"
@echo " - checks run various consistency checks" @echo " - checks run various consistency checks"
@echo " - checks-frontend check frontend files" @echo " - checks-frontend check frontend files"
@echo " - checks-backend check backend files" @echo " - checks-backend check backend files"
@ -427,6 +428,10 @@ lint-actions:
lint-templates: .venv lint-templates: .venv
@poetry run djlint $(shell find templates -type f -iname '*.tmpl') @poetry run djlint $(shell find templates -type f -iname '*.tmpl')
.PHONY: lint-yaml
lint-yaml: .venv
@poetry run yamllint .
.PHONY: watch .PHONY: watch
watch: watch:
@bash build/watch.sh @bash build/watch.sh

22
poetry.lock generated
View File

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. # This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
[[package]] [[package]]
name = "click" name = "click"
@ -325,7 +325,25 @@ notebook = ["ipywidgets (>=6)"]
slack = ["slack-sdk"] slack = ["slack-sdk"]
telegram = ["requests"] telegram = ["requests"]
[[package]]
name = "yamllint"
version = "1.32.0"
description = "A linter for YAML files."
optional = false
python-versions = ">=3.7"
files = [
{file = "yamllint-1.32.0-py3-none-any.whl", hash = "sha256:d97a66e48da820829d96077d76b8dfbe6c6140f106e558dae87e81ac4e6b30b7"},
{file = "yamllint-1.32.0.tar.gz", hash = "sha256:d01dde008c65de5b235188ab3110bebc59d18e5c65fc8a58267cd211cd9df34a"},
]
[package.dependencies]
pathspec = ">=0.5.3"
pyyaml = "*"
[package.extras]
dev = ["doc8", "flake8", "flake8-import-order", "rstcheck[sphinx]", "sphinx"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "1b154f70c35b75d47c843959af9df0e7343f3bb579835825ca889ec9350afc41" content-hash = "4017ac7637dcc0703b37f8dc640d3e11e67e60c7b14660838135cff38ad91656"

View File

@ -9,6 +9,7 @@ python = "^3.8"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
djlint = "1.32.1" djlint = "1.32.1"
yamllint = "^1.32.0"
[tool.djlint] [tool.djlint]
profile="golang" profile="golang"