-
-
Notifications
You must be signed in to change notification settings - Fork 133
128 lines (108 loc) · 3.56 KB
/
actions.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
name: "Actions"
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
lint:
name: pre-commit
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout the repository
uses: actions/checkout@v4
- name: 📦 Set up Python
uses: actions/[email protected]
- name: ✅ Run pre-commit
uses: pre-commit/[email protected]
directory:
needs: lint
name: Validate directory for ${{ matrix.target.name }}
runs-on: ubuntu-latest
strategy:
matrix:
target:
- { name: "Current Directory", path: "$PWD" }
- { name: "Dev setup", path: "$PWD/config" }
- { name: "Container", path: "/tmp/config" }
- { name: "Venv", path: "$HOME/.homeassistant" }
- {
name: "Supervised local",
path: "/usr/share/hassio/homeassistant",
}
steps:
- name: 📦 Checkout the repository
uses: actions/checkout@v4
- name: 🐒 Workaround for action runner limitation
if: matrix.target.name == 'Container'
run: sed -i 's/"\/config"/"\/tmp\/config"/' get
- name: ❌ Test no Home Assistant configuration directory
run: |
set +e
bash ./get
if [ "$?" != 1 ];then
exit 1
fi
set -e
- name: ✍🏻 Create .HA_VERSION file
run: |
mkdir -p ${{ matrix.target.path }}
echo "3000.1.1" > ${{ matrix.target.path }}/.HA_VERSION
- name: 🏃♀️ Run the downloader
run: bash ./get
- name: 👀 Verify content
run: |
if [ ! -f "${{ matrix.target.path }}/custom_components/hacs/manifest.json" ]; then
exit 1
fi
if [ -f "${{ matrix.target.path }}/custom_components/hacs.zip" ]; then
exit 1
fi
version:
needs: lint
name: Validate version ${{ matrix.version.current }}-${{ matrix.version.target }} (${{ matrix.version.result }})
runs-on: ubuntu-latest
strategy:
matrix:
version:
- { current: "2023.1.1", target: "2023.1.1", result: 0 }
- { current: "2023.1.1", target: "2023.1.1b4", result: 0 }
- { current: "2022.1.1", target: "2023.1.1", result: 1 }
- { current: "2022.1.1", target: "2023.1.3", result: 1 }
- { current: "2023.12.0", target: "2023.1.3", result: 1 }
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Create .HA_VERSION file
run: echo "${{ matrix.version.current }}" > .HA_VERSION
- name: Create fake const.py file
run: echo 'MINIMUM_HA_VERSION = "${{ matrix.version.target }}"' > const.py
- name: Patch script so we can actually check
run: sed -i 's|/custom_components/hacs/const.py|/const.py|' get
- name: Run the script and check result
run: |
set +e
bash ./get
if [ "$?" != ${{ matrix.version.result }} ];then
exit 1
fi
set -e
- name: 👀 Verify content exists
if: matrix.version.result == 0
run: |
if [ ! -f "./custom_components/hacs/manifest.json" ]; then
exit 1
fi
- name: 👀 Verify content is missing
if: matrix.version.result == 1
run: |
if [ -f "./custom_components/hacs/manifest.json" ]; then
exit 1
fi
- name: 👀 Verify cleanup
run: |
if [ -f "${{ matrix.target.path }}/custom_components/hacs.zip" ]; then
exit 1
fi