forked from home-assistant/wheels-custom-integrations
-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (146 loc) · 5.28 KB
/
ci.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint:
runs-on: ubuntu-latest
name: Lint
outputs:
requirements: ${{ steps.requirements.outputs.exist }}
apk: ${{ steps.apk.outputs.packages }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
- name: Lint with JQ
uses: home-assistant/actions/helpers/jq@master
- name: Get changed files
id: changed_files
uses: jitterbit/get-changed-files@v1
- name: Check integration files
id: integrations
run: |
for component in components/*; do
if [[ "${{ steps.changed_files.outputs.all }}" =~ $component ]]; then
if [ "${component##*.}" != "json" ];then
echo "::error::${component} does not end with '.json'"
exit 1
fi
manifestlink=$(jq --raw-output ".manifest" "${component}")
echo "Process: ${component} -> ${manifestlink}"
manifest=$(curl -sSL -f "${manifestlink}" | jq -e --raw-output .)
if [[ "$?" != 0 ]]; then
echo "Unable to read the manifest file at ${manifestlink}"
echo "The URL might be wrong or is not a raw URL."
exit 1
fi
echo "${manifest}" | jq -e --raw-output '.requirements[0]'
if [[ "$?" != 0 ]]; then
echo "The integration in $component, does not seem to have any Python requirements."
echo "Adding it to this repository has no use, since there are nothing to build for it."
exit 1
fi
echo "${manifest}" | jq -e --raw-output '.requirements[]' >> requirements_raw.txt
fi
done
- name: Check if requirements.txt has content
id: requirements
run: |
if [[ -f ./requirements_raw.txt ]]; then
sort -u ./requirements_raw.txt > ./requirements.txt
cat ./requirements.txt
echo "::set-output name=exist::true"
fi
- name: Get constraints
if: steps.requirements.outputs.exist == 'true'
run: wget -O constraints.txt https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt
- name: Upload requirements.txt
if: steps.requirements.outputs.exist == 'true'
uses: actions/upload-artifact@v3.1.0
with:
name: requirements
path: ./requirements.txt
- name: Upload constraints.txt
if: steps.requirements.outputs.exist == 'true'
uses: actions/upload-artifact@v3.1.0
with:
name: constraints
path: ./constraints.txt
- name: Setup tempio
uses: home-assistant/tempio@main
- name: Generate APK list
id: apk
run: |
tempio -conf requirements.json -template templates/builder.template -out apk.list
packages=$(cat apk.list)
echo "::set-output name=packages::${packages}"
integration:
needs: lint
runs-on: ubuntu-latest
name: Validate integration
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
- uses: lots0logs/gh-action-get-changed-files@2.1.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build the container
run: |
cp ${HOME}/files.json validate_integrations/files.json
docker build -t validate -f validate_integrations/Dockerfile .
- name: Validate integrations
run: docker run --rm validate
requirements:
needs: integration
runs-on: ubuntu-latest
name: Validate Python requirements
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
- uses: lots0logs/gh-action-get-changed-files@2.1.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build the container
run: |
cp ${HOME}/files.json validate_requirements/files.json
docker build -t validate -f validate_requirements/Dockerfile .
- name: Validate requirements
run: docker run --rm -e CRYPTOGRAPHY_DONT_BUILD_RUST=1 validate
wheels:
needs: [lint, requirements]
if: needs.lint.outputs.requirements == 'true'
runs-on: ubuntu-latest
name: Verify that we can build wheels
strategy:
matrix:
arch: ["aarch64", "armhf", "armv7", "amd64", "i386"]
alpine: ["3.12"]
python: ["3.8"]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
- name: Download requirements.txt
uses: actions/download-artifact@v2
with:
name: requirements
- name: Download constraints.txt
uses: actions/download-artifact@v2
with:
name: constraints
- name: Build wheels
uses: home-assistant/wheels@master
with:
tag: ${{ matrix.python }}-alpine${{ matrix.alpine }}
arch: ${{ matrix.arch }}
wheels-host: ${{ secrets.WHEELS_HOST }}
apk: ${{ needs.lint.outputs.apk }}
pip: "Cython;numpy"
skip-binary: aiohttp
test: True
single: True
constraints: "constraints.txt"
requirements: "requirements.txt"