generated from home-assistant/addons-example
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (107 loc) · 3.84 KB
/
lint-addons.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
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
name: Lint Addons
on:
push:
tags:
- v*
branches:
- main
pull_request:
env:
PYTHON_VERSION: ^3.9.0
permissions:
contents: read
jobs:
find:
name: Find add-ons
runs-on: ubuntu-latest
outputs:
addons: ${{ steps.addons.outputs.addons_list }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v3.3.0
- name: 🔍 Find add-on directories
id: addons
uses: home-assistant/actions/helpers/find-addons@master
lint:
name: Lint add-on ${{ matrix.path }}
runs-on: ubuntu-latest
needs: find
strategy:
matrix:
path: ${{ fromJson(needs.find.outputs.addons) }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v3.3.0
- name: 🚀 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2.11
with:
path: "./${{ matrix.path }}"
pre-commit:
name: Pre-commit
runs-on: "ubuntu-latest"
steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name:
uses: actions/setup-go@v3
with:
go-version-file: go.work
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Python modules
run: |
pip install --constraint=.github/workflows/constraints.txt pre-commit
- name: Run pre-commit on all files
run: |
pre-commit run --all-files --show-diff-on-failure --color=always
golangci:
name: golangci-lint add-on ${{ matrix.path }}
runs-on: ubuntu-latest
needs: find
# Use a matrix strategy because golangci doesn't seem to support go.work
# correctly. https://github.com/golangci/golangci-lint/issues/2654
strategy:
matrix:
path: ${{ fromJson(needs.find.outputs.addons) }}
steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
- name: Check if the add-on is go-based
id: check_is_go
run: |
if [[ -f "./${{ matrix.path }}/go.mod" ]]; then
echo "is_go=true" >> "${GITHUB_OUTPUT}"
else
echo "is_go=false" >> "${GITHUB_OUTPUT}"
fi
- name: Set up Go
if: steps.check_is_go.outputs.is_go == 'true'
uses: actions/setup-go@v3
with:
go-version-file: go.work
- name: golangci-lint
if: steps.check_is_go.outputs.is_go == 'true'
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
# Optional: working directory, useful for monorepos
working-directory: ${{ matrix.path }}
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# Can't set this yet, because working-directory is not compatible with only-new-issues
# only-new-issues: true
# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true