This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (132 loc) · 5.79 KB
/
linter-conan-v2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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@v4
- name: Get changed files
uses: ./.github/actions/pr_changed_files
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@v5
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@v4
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@v4
- name: Get changed files
id: changed-files
uses: ./.github/actions/pr_changed_files
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@v5
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@v4
- name: Get changed files
id: changed-files
uses: ./.github/actions/pr_changed_files
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@v5
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