forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (101 loc) · 4.13 KB
/
linter-yaml.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
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_config.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