From c9dec13f35cf84621e4dbd45a5d5228da1ece8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 7 Dec 2022 14:35:49 +0100 Subject: [PATCH] Enhancement: Lint YAML files (#548) * Enhancement: Lint YAML files * Fix: Consistently quote strings in YAML files * Fix: Remove extra empty lines * Fix: Ignore truthy rule for 'on' * Fix: Use explicit null --- .gitattributes | 1 + .github/stale.yml | 6 +- .github/workflows/bc-check.yml | 19 +++--- .github/workflows/branch-alias.yml | 48 +++++++-------- .github/workflows/code-coverage.yml | 46 +++++++-------- .github/workflows/coding-standards.yml | 66 +++++++++++++-------- .github/workflows/static-analysis.yml | 81 +++++++++++++------------- .github/workflows/tests.yml | 68 ++++++++++----------- .yamllint.yaml | 67 +++++++++++++++++++++ 9 files changed, 242 insertions(+), 160 deletions(-) create mode 100644 .yamllint.yaml diff --git a/.gitattributes b/.gitattributes index 85331d3511..5ee738da79 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,7 @@ /.gitattributes export-ignore /.gitignore export-ignore /.php-cs-fixer.dist.php export-ignore +/.yamllint.yaml export-ignore /codecov.yml export-ignore /Makefile export-ignore /phpstan-baseline.neon export-ignore diff --git a/.github/stale.yml b/.github/stale.yml index 682c292e9a..38bea83155 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,10 +1,10 @@ daysUntilStale: 14 daysUntilClose: 7 exemptLabels: - - pinned - - security + - "pinned" + - "security" # Label to use when marking an issue as stale -staleLabel: lifecycle/stale +staleLabel: "lifecycle/stale" # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had diff --git a/.github/workflows/bc-check.yml b/.github/workflows/bc-check.yml index 437086ef28..aa88363fa7 100644 --- a/.github/workflows/bc-check.yml +++ b/.github/workflows/bc-check.yml @@ -1,21 +1,20 @@ - -on: - pull_request: +on: # yamllint disable-line rule:truthy + pull_request: ~ push: branches: - "main" - "[0-9].*" -name: BC Check +name: "BC Check" jobs: roave-bc-check: - name: Roave BC Check - runs-on: ubuntu-latest + name: "Roave BC Check" + runs-on: "ubuntu-latest" steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: "Checkout code" + uses: "actions/checkout@v3" - - name: Roave BC Check - uses: docker://nyholm/roave-bc-check-ga + - name: "Roave BC Check" + uses: "docker://nyholm/roave-bc-check-ga" diff --git a/.github/workflows/branch-alias.yml b/.github/workflows/branch-alias.yml index baa66cdc95..dcd71f1107 100644 --- a/.github/workflows/branch-alias.yml +++ b/.github/workflows/branch-alias.yml @@ -1,28 +1,28 @@ -name: Update branch alias +name: "Update branch alias" -on: +on: # yamllint disable-line rule:truthy push: - tags: ['*'] + tags: ["*"] jobs: branch-alias: - name: Update branch alias - runs-on: ubuntu-latest + name: "Update branch alias" + runs-on: "ubuntu-latest" steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" with: - php-version: 7.4 - coverage: none + php-version: "7.4" + coverage: "none" - - name: Checkout code - uses: actions/checkout@v3 + - name: "Checkout code" + uses: "actions/checkout@v3" with: - ref: main + ref: "main" - - name: Find branch alias - id: find_alias + - name: "Find branch alias" + id: "find_alias" run: | TAG=$(echo $GITHUB_REF | cut -d'/' -f 3) echo "Last tag was $TAG" @@ -30,7 +30,7 @@ jobs: ARR[1]=$((${ARR[1]}+1)) echo "name=alias::${ARR[0]}.${ARR[1]}" >> $GITHUB_OUTPUT - - name: Update branch alias + - name: "Update branch alias" run: | CURRENT_ALIAS=$(composer config extra.branch-alias.dev-main | cut -d'-' -f 1) @@ -53,15 +53,15 @@ jobs: composer config extra.branch-alias.dev-main ${{ steps.find_alias.outputs.alias }}-dev - - name: Create Pull Request - uses: peter-evans/create-pull-request@v4 + - name: "Create Pull Request" + uses: "peter-evans/create-pull-request@v4" with: - base: main - branch: branch-alias-update - author: GitHub - committer: GitHub - commit-message: Updating branch alias to ${{ steps.find_alias.outputs.alias }} - title: Update branch alias - labels: pinned, do not merge + base: "main" + branch: "branch-alias-update" + author: "GitHub " + committer: "GitHub " + commit-message: "Updating branch alias to ${{ steps.find_alias.outputs.alias }}" + title: "Update branch alias" + labels: "pinned, do not merge" body: | Since we just tagged a new version, we need to update composer.json branch alias. This should not be merged until there are new features, as it would prevent patch releases. diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index e0b61d8ed8..ede5bbdadf 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -1,57 +1,57 @@ -on: - pull_request: +on: # yamllint disable-line rule:truthy + pull_request: ~ push: branches: - "main" - "[0-9].*" -name: Code Coverage +name: "Code Coverage" jobs: code-coverage: - name: Code Coverage + name: "Code Coverage" strategy: matrix: php-version: - - '8.0' + - "8.0" - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: "Checkout code" + uses: "actions/checkout@v3" - - name: Install PHP with extensions - uses: shivammathur/setup-php@v2 + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@v2" with: - coverage: pcov - extensions: intl - php-version: ${{ matrix.php-version }} + coverage: "pcov" + extensions: "intl" + php-version: "${{ matrix.php-version }}" - - name: Determine composer cache directory - id: composer-cache - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: "Determine composer cache directory" + id: "composer-cache" + run: "echo \"directory=$(composer config cache-dir)\" >> $GITHUB_OUTPUT" - - name: Cache dependencies installed with composer - uses: actions/cache@v3 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v3" with: - path: ${{ steps.composer-cache.outputs.directory }} - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + path: "${{ steps.composer-cache.outputs.directory }}" + key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}" restore-keys: | composer-${{ runner.os }}-${{ matrix.php-version }}- composer-${{ runner.os }}- composer- - - name: Download dependencies + - name: "Download dependencies" run: | composer update --no-interaction --no-progress --optimize-autoloader vendor/bin/simple-phpunit install - - name: Collect code coverage with PHPUnit + - name: "Collect code coverage with PHPUnit" run: | vendor/bin/simple-phpunit --coverage-clover=.build/logs/clover.xml - - name: Send code coverage report to codecov.io + - name: "Send code coverage report to codecov.io" run: | bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index bd8910280d..fbff43227d 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -1,63 +1,79 @@ -on: +on: # yamllint disable-line rule:truthy pull_request: ~ push: branches: - "main" - "[0-9].*" -name: Coding Standards +name: "Coding Standards" jobs: php-cs-fixer: - name: php-cs-fixer + name: "php-cs-fixer" - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: matrix: php-version: - - 7.1 + - "7.1" steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: "Checkout code" + uses: "actions/checkout@v3" - - name: Set up PHP - uses: shivammathur/setup-php@v2 + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" with: - coverage: none - extensions: intl - php-version: ${{ matrix.php-version }} + coverage: "none" + extensions: "intl" + php-version: "${{ matrix.php-version }}" - - name: Determine composer cache directory - id: composer-cache - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: "Determine composer cache directory" + id: "composer-cache" + run: "echo \"directory=$(composer config cache-dir)\" >> $GITHUB_OUTPUT" - - name: Cache dependencies installed with composer - uses: actions/cache@v3 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v3" with: - path: ${{ steps.composer-cache.outputs.directory }} - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + path: "${{ steps.composer-cache.outputs.directory }}" + key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}" restore-keys: | composer-${{ runner.os }}-${{ matrix.php-version }}- composer-${{ runner.os }}- composer- - - name: Download dependencies + - name: "Download dependencies" run: | composer update --no-interaction --no-progress --optimize-autoloader composer bin php-cs-fixer install --no-interaction --no-progress --optimize-autoloader - - name: Cache cache file for php-cs-fixer - uses: actions/cache@v3 + - name: "Cache cache file for php-cs-fixer" + uses: "actions/cache@v3" with: - path: .php_cs.cache - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + path: ".php_cs.cache" + key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}" restore-keys: | composer-${{ runner.os }}-${{ matrix.php-version }}- composer-${{ runner.os }}- composer- - - name: Run php-cs-fixer + - name: "Run php-cs-fixer" run: | vendor/bin/php-cs-fixer fix --diff --dry-run --verbose + + yamllint: + name: "yamllint" + + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Lint YAML files" + uses: "ibiqlik/action-yamllint@v3.1.1" + with: + config_file: ".yamllint.yaml" + file_or_dir: "." + strict: true diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 4921e502c0..ddc9730067 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,94 +1,93 @@ - -on: +on: # yamllint disable-line rule:truthy pull_request: ~ push: branches: - "main" - "[0-9].*" -name: Static analysis +name: "Static analysis" jobs: phpstan: - name: PHPStan - runs-on: ubuntu-latest + name: "PHPStan" + runs-on: "ubuntu-latest" strategy: matrix: - php-version: [7.4] + php-version: ["7.4"] steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: "Checkout code" + uses: "actions/checkout@v3" - - name: Set up PHP - uses: shivammathur/setup-php@v2 + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" with: - coverage: none - extensions: intl - php-version: ${{ matrix.php-version }} + coverage: "none" + extensions: "intl" + php-version: "${{ matrix.php-version }}" - - name: Determine composer cache directory - id: composer-cache - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: "Determine composer cache directory" + id: "composer-cache" + run: "echo \"directory=$(composer config cache-dir)\" >> $GITHUB_OUTPUT" - - name: Cache dependencies installed with composer - uses: actions/cache@v3 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v3" with: - path: ${{ steps.composer-cache.outputs.directory }} - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + path: "${{ steps.composer-cache.outputs.directory }}" + key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}" restore-keys: | composer-${{ runner.os }}-${{ matrix.php-version }}- composer-${{ runner.os }}- composer- - - name: Download dependencies + - name: "Download dependencies" run: | composer update --no-interaction --no-progress --optimize-autoloader composer bin phpstan install --no-interaction --no-progress --optimize-autoloader - - name: Run PHPStan + - name: "Run PHPStan" run: | vendor/bin/phpstan --no-progress psalm: - name: Psalm - runs-on: ubuntu-latest + name: "Psalm" + runs-on: "ubuntu-latest" strategy: matrix: - php-version: [7.4] + php-version: ["7.4"] steps: - - name: Checkout - uses: actions/checkout@v3 + - name: "Checkout" + uses: "actions/checkout@v3" - - name: Install PHP with extensions - uses: shivammathur/setup-php@v2 + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@v2" with: - coverage: none - extensions: intl - php-version: ${{ matrix.php-version }} + coverage: "none" + extensions: "intl" + php-version: "${{ matrix.php-version }}" - - name: Determine composer cache directory - id: composer-cache - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: "Determine composer cache directory" + id: "composer-cache" + run: "echo \"directory=$(composer config cache-dir)\" >> $GITHUB_OUTPUT" - - name: Cache dependencies installed with composer - uses: actions/cache@v3 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v3" with: - path: ${{ steps.composer-cache.outputs.directory }} - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + path: "${{ steps.composer-cache.outputs.directory }}" + key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}" restore-keys: | composer-${{ runner.os }}-${{ matrix.php-version }}- composer-${{ runner.os }}- composer- - - name: Download dependencies + - name: "Download dependencies" run: | composer update --no-interaction --no-progress --optimize-autoloader composer bin psalm install --no-interaction --no-progress --optimize-autoloader - - name: Run Psalm + - name: "Run Psalm" run: | vendor/bin/psalm --no-progress --output-format=github --shepherd diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 679db06763..7f435c4aaf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,64 +1,64 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions -on: - pull_request: +on: # yamllint disable-line rule:truthy + pull_request: ~ push: branches: - "main" - "[0-9].*" -name: Tests +name: "Tests" jobs: phpunit: - name: PHPUnit on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }} + name: "PHPUnit on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }}" strategy: matrix: operating-system: - - 'ubuntu-latest' + - "ubuntu-latest" php-version: - - '7.1' - - '7.2' - - '7.3' - - '7.4' - - '8.0' - - '8.1' + - "7.1" + - "7.2" + - "7.3" + - "7.4" + - "8.0" + - "8.1" - runs-on: ${{ matrix.operating-system }} + runs-on: "${{ matrix.operating-system }}" steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: "Checkout code" + uses: "actions/checkout@v3" - - name: Install PHP with extensions - uses: shivammathur/setup-php@v2 + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@v2" with: - coverage: none - extensions: intl - php-version: ${{ matrix.php-version }} + coverage: "none" + extensions: "intl" + php-version: "${{ matrix.php-version }}" - - name: Determine composer cache directory - id: composer-cache - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: "Determine composer cache directory" + id: "composer-cache" + run: "echo \"directory=$(composer config cache-dir)\" >> $GITHUB_OUTPUT" - - name: Cache dependencies installed with composer - uses: actions/cache@v3 + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v3" with: - path: ${{ steps.composer-cache.outputs.directory }} - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }} + path: "${{ steps.composer-cache.outputs.directory }}" + key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}" restore-keys: | composer-${{ runner.os }}-${{ matrix.php-version }}- composer-${{ runner.os }}- composer- - - name: Download dependencies - run: composer update --no-interaction --no-progress --optimize-autoloader + - name: "Download dependencies" + run: "composer update --no-interaction --no-progress --optimize-autoloader" - - name: Run tests - if: ${{ '8.1' != matrix.php-version }} - run: ./vendor/bin/simple-phpunit + - name: "Run tests" + if: "${{ '8.1' != matrix.php-version }}" + run: "./vendor/bin/simple-phpunit" - - name: Run tests for php 8.1 - if: ${{ '8.1' == matrix.php-version }} - run: SYMFONY_PHPUNIT_VERSION=9.5 ./vendor/bin/simple-phpunit + - name: "Run tests for php 8.1" + if: "${{ '8.1' == matrix.php-version }}" + run: "SYMFONY_PHPUNIT_VERSION=9.5 ./vendor/bin/simple-phpunit" diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000000..8409d5e3bf --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,67 @@ +extends: "default" + +ignore: | + .build/ + vendor/ + vendor-bin/ + roave-bc-check.yaml + +rules: + braces: + max-spaces-inside-empty: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: 0 + min-spaces-inside: 1 + brackets: + max-spaces-inside-empty: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 0 + min-spaces-inside: 0 + colons: + max-spaces-after: 1 + max-spaces-before: 0 + commas: + max-spaces-after: 1 + max-spaces-before: 0 + min-spaces-after: 1 + comments: + ignore-shebangs: true + min-spaces-from-content: 1 + require-starting-space: true + comments-indentation: "enable" + document-end: + present: false + document-start: + present: false + indentation: + check-multi-line-strings: false + indent-sequences: true + spaces: 2 + empty-lines: + max-end: 0 + max-start: 0 + max: 1 + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + hyphens: + max-spaces-after: 2 + key-duplicates: "enable" + key-ordering: "disable" + line-length: "disable" + new-line-at-end-of-file: "enable" + new-lines: + type: "unix" + octal-values: + forbid-implicit-octal: true + quoted-strings: + quote-type: "double" + trailing-spaces: "enable" + truthy: + allowed-values: + - "false" + - "true" + +yaml-files: + - "*.yaml" + - "*.yml"