mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-08-07 03:05:07 +00:00

* linter: reduce spam for notification from actions + lower error level * linter: there should not be an error code * linter: add missing return statements
119 lines
4.1 KiB
YAML
119 lines
4.1 KiB
YAML
name: "[linter] YAML files"
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
env:
|
|
PYTHONPATH: ${{github.workspace}}
|
|
PYVER: "3.8"
|
|
CONFIG_FILES_PATH: "recipes/*/config.yml"
|
|
CONANDATA_FILES_PATH: "recipes/*/*/conandata.yml"
|
|
|
|
jobs:
|
|
test_linter:
|
|
# A job to run when the linter changes. We want to know in advance how many files will be broken
|
|
name: Test linter changes (YAML files)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Get changed files
|
|
uses: ./.github/actions/pr_changed_files
|
|
id: changed_files
|
|
with:
|
|
files: |
|
|
linter/**
|
|
|
|
- uses: actions/setup-python@v4
|
|
if: steps.changed_files.outputs.any_changed == 'true'
|
|
with:
|
|
python-version: ${{ env.PYVER }}
|
|
|
|
- name: Install dependencies
|
|
if: steps.changed_files.outputs.any_changed == 'true'
|
|
run: pip install yamllint strictyaml argparse
|
|
|
|
- name: Run linter (config.yml)
|
|
if: steps.changed_files.outputs.any_changed == 'true' && always()
|
|
run: |
|
|
echo "::add-matcher::linter/yamllint_matcher.json"
|
|
yamllint --config-file linter/yamllint_rules.yml -f standard ${{ env.CONFIG_FILES_PATH }}
|
|
echo "::remove-matcher owner=yamllint_matcher::"
|
|
|
|
- name: Run schema check (config.yml)
|
|
if: steps.changed_files.outputs.any_changed == 'true' && always()
|
|
run: |
|
|
for file in ${{ env.CONFIG_FILES_PATH }}; do
|
|
python3 linter/config_yaml_linter.py ${file}
|
|
done
|
|
|
|
- name: Run linter (conandata.yml)
|
|
if: steps.changed_files.outputs.any_changed == 'true' && always()
|
|
run: |
|
|
echo "::add-matcher::linter/yamllint_matcher.json"
|
|
yamllint --config-file linter/yamllint_rules.yml -f standard ${{ env.CONANDATA_FILES_PATH }}
|
|
echo "::remove-matcher owner=yamllint_matcher::"
|
|
|
|
- name: Run schema check (conandata.yml)
|
|
if: steps.changed_files.outputs.any_changed == 'true' && always()
|
|
run: |
|
|
for file in ${{ env.CONANDATA_FILES_PATH }}; do
|
|
python3 linter/conandata_yaml_linter.py ${file}
|
|
done
|
|
|
|
lint_pr_files:
|
|
# Lint files modified in the pull_request
|
|
name: Lint changed files (YAML files)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ env.PYVER }}
|
|
|
|
- name: Install dependencies
|
|
run: pip install yamllint strictyaml argparse
|
|
|
|
## Work on config.yml files
|
|
- name: Get changed files (config)
|
|
id: changed_files_config
|
|
if: always()
|
|
uses: ./.github/actions/pr_changed_files
|
|
with:
|
|
files: |
|
|
${{ env.CONFIG_FILES_PATH }}
|
|
|
|
- name: Run linter (config.yml)
|
|
if: steps.changed_files_config.outputs.any_changed == 'true' && always()
|
|
run: |
|
|
echo "::add-matcher::linter/yamllint_matcher.json"
|
|
for file in ${{ steps.changed_files_config.outputs.all_changed_files }}; do
|
|
yamllint --config-file linter/yamllint_rules.yml -f standard ${file}
|
|
done
|
|
echo "::remove-matcher owner=yamllint_matcher::"
|
|
|
|
for file in ${{ steps.changed_files_conandata.outputs.all_changed_files }}; do
|
|
python3 linter/config_yaml_linter.py ${file}
|
|
done
|
|
|
|
## Work on conandata.yml files
|
|
- name: Get changed files (conandata)
|
|
id: changed_files_conandata
|
|
if: always()
|
|
uses: ./.github/actions/pr_changed_files
|
|
with:
|
|
files: |
|
|
${{ env.CONANDATA_FILES_PATH }}
|
|
|
|
- name: Run linter (conandata.yml)
|
|
if: steps.changed_files_conandata.outputs.any_changed == 'true' && always()
|
|
run: |
|
|
echo "::add-matcher::linter/yamllint_matcher.json"
|
|
for file in ${{ steps.changed_files_conandata.outputs.all_changed_files }}; do
|
|
yamllint --config-file linter/yamllint_rules.yml -f standard ${file}
|
|
done
|
|
echo "::remove-matcher owner=yamllint_matcher::"
|
|
|
|
for file in ${{ steps.changed_files_conandata.outputs.all_changed_files }}; do
|
|
python3 linter/conandata_yaml_linter.py ${file}
|
|
done
|