-
Notifications
You must be signed in to change notification settings - Fork 15
100 lines (93 loc) · 3.04 KB
/
lint_code.yaml
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
---
name: Lint code
# Run workflow on pushes to matching branches
on: # yamllint disable-line rule:truthy
push:
branches: [develop, python-migration]
pull_request:
branches: [develop, python-migration]
jobs:
lint_json:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install requirements
shell: bash
run: npm install -g jsonlint mustache
- name: Lint JSON
shell: bash
run: |
echo "{}" > mustache_config.json
find . -name "*.json" | xargs -n 1 mustache mustache_config.json | jsonlint --quiet --compact
lint_markdown:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install requirements
shell: bash
run: sudo gem install mdl
- name: Lint Markdown
run: mdl --style .mdlstyle.rb .
lint_powershell:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install requirements
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer
- name: Lint PowerShell
shell: pwsh
run: Invoke-ScriptAnalyzer -Path . -Settings .PSScriptAnalyzerSettings.psd1 -Recurse -EnableExit -ReportSummary
lint_python:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install hatch
run: pip install hatch
- name: Lint Python
run: hatch run lint:all
lint_shell:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install requirements
shell: bash
run: sudo apt install shellcheck
- name: Lint shell
shell: bash
run: find . -name "*.sh" | xargs shellcheck --format gcc --severity error
lint_yaml:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install requirements
shell: bash
run: |
npm install -g mustache
- name: Expand mustache templates
shell: bash
run: |
echo '{"array": ["dummy"], "variable": "dummy"}' > .mustache_config.json
for yamlfile in $(find . -name "*.yml" -o -name "*.yaml"); do
sed "s|{{\([/#]\)[^}]*}}|{{\1array}}|g" $yamlfile > expanded.tmp # replace mustache arrays
sed -i "s|{{[^#/].\{1,\}}}|{{variable}}|g" expanded.tmp # replace mustache variables
mustache .mustache_config.json expanded.tmp > $yamlfile # perform mustache expansion overwriting original file
done
rm expanded.tmp
- name: Lint YAML
uses: karancode/yamllint-github-action@dd59165b84d90d37fc919c3c7dd84c7e37cd6bfb # this is 2.0.0
with:
yamllint_strict: true
yamllint_comment: false