From c750d15f42c135e66848ab5e2e221cdbc2c56db3 Mon Sep 17 00:00:00 2001 From: "Hasko, Vladimir" Date: Mon, 9 Feb 2026 13:29:42 +0000 Subject: [PATCH] addding openapi for AS Reviewed-by: Gode, Sebastian Co-authored-by: Hasko, Vladimir Co-committed-by: Hasko, Vladimir --- .gitea/workflows/yaml-lint.yml | 123 +++++++++++++++++++++++++++++++++ .spectral.yaml | 11 +++ .yamllint | 17 +++++ 3 files changed, 151 insertions(+) create mode 100644 .gitea/workflows/yaml-lint.yml create mode 100644 .spectral.yaml create mode 100644 .yamllint diff --git a/.gitea/workflows/yaml-lint.yml b/.gitea/workflows/yaml-lint.yml new file mode 100644 index 000000000..98997006e --- /dev/null +++ b/.gitea/workflows/yaml-lint.yml @@ -0,0 +1,123 @@ +# .gitea/workflows/yaml-lint.yml +name: YAML Lint + +on: + push: + branches: + - main + pull_request: + branches: + - main + paths: + - '.gitea/workflows/yaml-lint.yml' + - 'docs/*/openapi/*.yaml' + - 'docs/*/openapi/*.yml' + +jobs: + yaml-lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Dump Gitea env + run: | + env | sort | grep GITEA + + - name: Get base branch name + id: base + run: | + base_ref=$(jq -r '.pull_request.base.ref' "$GITEA_PATH") + echo "base_ref=$base_ref" + echo "${{ gitea.base_ref }}" + BASE_SHA="${{ gitea.event.pull_request.base.sha }}" + echo "Base SHA: $BASE_SHA" + + - name: Get changed files other method + id: changed-files + run: | + BASE_SHA="${{ gitea.event.pull_request.base.sha }}" + echo "Base SHA: $BASE_SHA" + git fetch origin $BASE_SHA + echo "changed_files=$(git diff --name-only ${BASE_SHA}...HEAD | grep -E '\.(yml|yaml)$' | xargs)" >> $GITHUB_OUTPUT + + - name: List changed files + run: | + for file in ${{ steps.changed-files.outputs.changed_files }}; do + echo "$file was changed" + done + + - name: Check presence of non-unicode characters + continue-on-error: true + run: | + for file in ${{ steps.changed-files.outputs.changed_files }}; do + if LC_ALL=C grep --color='auto' -P -n "[^\x00-\x7F]" $file &>/dev/null; then + echo "$file contains non-unicode characters!" + LC_ALL=C grep --color='auto' -P -n "[^\x00-\x7F]" $file + failed_job=true + fi + done + if [ "$failed_job" = true ] ; then + exit 1 + fi + + - name: Install yamllint + run: | + sudo apt-get update + sudo apt-get install -y yamllint + + - name: Run yamllint on changed YAML files + continue-on-error: true + run: | + set -e + + files="${{ steps.changed-files.outputs.changed_files }}" + if [ -z "$files" ]; then + echo "No YAML files changed" + exit 0 + fi + + echo "Linting changed files:" + printf '%s\n' $files + + for file in $files; do + echo "$file is being checked for yamllint issues." + yamllint -f parsable $file || \ + { failed_check=true ; echo "$file: detected yamllint errors!"; } + done + if [ "$failed_check" = true ]; then + exit 1 + fi + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install Spectral + run: npm install -g @stoplight/spectral-cli + + - name: Run Spectral + run: | + set -e + + files="${{ steps.changed-files.outputs.changed_files }}" + if [ -z "$files" ]; then + echo "No YAML files changed" + exit 0 + fi + + echo "Spectral check on changed files:" + printf '%s\n' $files + + for file in $files; do + echo "$file is being checked for yamllint issues." + spectral lint $file --ruleset .spectral.yaml || \ + { failed_check=true ; echo "$file: detected spectral errors!"; } + done + if [ "$failed_check" = true ]; then + exit 1 + fi diff --git a/.spectral.yaml b/.spectral.yaml new file mode 100644 index 000000000..31c1a6304 --- /dev/null +++ b/.spectral.yaml @@ -0,0 +1,11 @@ +rules: + path-starts-with-slash-no-spaces: + description: Path must start with / and contain no spaces + message: "Path '{{property}}' must start with '/' and must not contain spaces" + severity: error + given: $.paths + then: + field: "@key" + function: pattern + functionOptions: + match: "^\\/[^\\s]*$" diff --git a/.yamllint b/.yamllint new file mode 100644 index 000000000..58ed79270 --- /dev/null +++ b/.yamllint @@ -0,0 +1,17 @@ +# .yamllint +extends: default + +yaml-files: + - '*.yaml' + - '*.yml' + +rules: + line-length: + max: 120 + level: warning + indentation: + spaces: 2 # number of spaces per indent level + indent-sequences: consistent # or true/false/whatever + level: error + document-start: + level: warning