mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-08-10 16:30:29 +00:00

* [linter] Fix linter v2 running on test_v1_package conanfiles * Update .github/workflows/linter-conan-v2.yml * Update .github/workflows/linter-conan-v2.yml * remove skip for testing * remove other skip to make it fail * it works! * update docs
150 lines
5.9 KiB
YAML
150 lines
5.9 KiB
YAML
name: "[linter] Conan v2 migration"
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
env:
|
|
PYTHONPATH: ${{github.workspace}}
|
|
PYVER: "3.8"
|
|
SCORE_THRESHOLD: "9.5"
|
|
REQUIREMENTS: "pylint==2.14"
|
|
|
|
jobs:
|
|
test_linter:
|
|
name: Test linter changes (v2 migration)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2
|
|
- name: Get changed files
|
|
uses: tj-actions/changed-files@v20
|
|
id: changed_files
|
|
with:
|
|
files: |
|
|
linter/**
|
|
- name: Get Conan v1 version
|
|
id: parse_conan_v1_version
|
|
if: steps.changed_files.outputs.any_changed == 'true'
|
|
uses: mikefarah/yq@master
|
|
with:
|
|
cmd: yq '.conan.version' '.c3i/config_v1.yml'
|
|
- uses: actions/setup-python@v3
|
|
if: steps.changed_files.outputs.any_changed == 'true'
|
|
with:
|
|
python-version: ${{ env.PYVER }}
|
|
- name: Install requirements
|
|
if: steps.changed_files.outputs.any_changed == 'true'
|
|
run: |
|
|
pip install ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v1_version.outputs.result }}
|
|
|
|
- name: Execute linter over all recipes in the repository
|
|
id: linter_recipes
|
|
if: steps.changed_files.outputs.any_changed == 'true'
|
|
run: |
|
|
pylint --rcfile=linter/pylintrc_recipe recipes/*/*/conanfile.py --output-format=json --output=recipes.json --score=y --fail-under=${{ env.SCORE_THRESHOLD }}
|
|
|
|
- name: Execute linter over all test_package/recipes in the repository
|
|
id: linter_test_package
|
|
if: steps.changed_files.outputs.any_changed == 'true'
|
|
run: |
|
|
pylint --rcfile=linter/pylintrc_testpackage recipes/*/*/test_*/conanfile.py --ignore-paths="recipes/[^/]*/[^/]*/test_v1[^/]*/conanfile.py" --output-format=json --output=test_package.json --score=y --fail-under=${{ env.SCORE_THRESHOLD }}
|
|
|
|
- name: Archive production artifacts
|
|
if: steps.changed_files.outputs.any_changed == 'true' && always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: linter-output
|
|
path: |
|
|
recipes.json
|
|
test_package.json
|
|
|
|
- name: Create report (recipes)
|
|
if: steps.changed_files.outputs.any_changed == 'true' && steps.linter_recipes.outcome != 'skipped' && always()
|
|
run: |
|
|
echo '## Linter summary (recipes)' >> $GITHUB_STEP_SUMMARY
|
|
jq 'map( select(.type=="error")) | group_by (.message)[] | {message: .[0].message, length: length}' recipes.json > recipes2.json
|
|
jq -r '" * \(.message): \(.length)"' recipes2.json >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Create report (test_package)
|
|
if: steps.changed_files.outputs.any_changed == 'true' && steps.linter_test_package.outcome != 'skipped' && always()
|
|
run: |
|
|
echo '## Linter summary (test_package)' >> $GITHUB_STEP_SUMMARY
|
|
jq 'map( select(.type=="error")) | group_by (.message)[] | {message: .[0].message, length: length}' test_package.json > test_package2.json
|
|
jq -r '" * \(.message): \(.length)"' test_package2.json >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Create report
|
|
if: steps.changed_files.outputs.any_changed == 'true' && always()
|
|
run: |
|
|
echo '> Note.- Check uploaded artifacts for a full report.' >> $GITHUB_STEP_SUMMARY
|
|
|
|
conanfile_recipe:
|
|
name: Lint changed conanfile.py (v2 migration)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@v20
|
|
with:
|
|
files: |
|
|
recipes/*/*/conanfile.py
|
|
- name: Get Conan v1 version
|
|
id: parse_conan_v1_version
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
uses: mikefarah/yq@master
|
|
with:
|
|
cmd: yq '.conan.version' '.c3i/config_v1.yml'
|
|
- uses: actions/setup-python@v3
|
|
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 ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v1_version.outputs.result }}
|
|
- name: Run linter
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
run: |
|
|
echo "::add-matcher::linter/recipe_linter.json"
|
|
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
|
pylint --rcfile=linter/pylintrc_recipe --output-format=parseable ${file}
|
|
done
|
|
|
|
conanfile_test_package:
|
|
name: Lint changed test_package/conanfile.py (v2 migration)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@v20
|
|
with:
|
|
files: |
|
|
recipes/*/*/test_*/conanfile.py
|
|
- name: Get Conan v1 version
|
|
id: parse_conan_v1_version
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
uses: mikefarah/yq@master
|
|
with:
|
|
cmd: yq '.conan.version' '.c3i/config_v1.yml'
|
|
- uses: actions/setup-python@v3
|
|
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 ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v1_version.outputs.result }}
|
|
- name: Run linter
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
run: |
|
|
echo "::add-matcher::linter/recipe_linter.json"
|
|
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
|
pylint --rcfile=linter/pylintrc_testpackage --ignore-paths="recipes/[^/]*/[^/]*/test_v1[^/]*/conanfile.py" --output-format=parseable ${file}
|
|
done
|