-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (151 loc) · 4.26 KB
/
Copy pathmain.yaml
File metadata and controls
165 lines (151 loc) · 4.26 KB
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
name: Main
on:
push:
branches:
- main
pull_request:
jobs:
check-workflows:
name: Check workflows
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download actionlint
id: download-actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/e7d448ef7507c20fc4c88a95d0c448b848cd6127/scripts/download-actionlint.bash) 1.7.8
shell: bash
- name: Check workflow files
run: ${{ steps.download-actionlint.outputs.executable }} -color
shell: bash
prepare:
name: Prepare
runs-on: ubuntu-latest
needs:
- check-workflows
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up environment
uses: ./.github/actions/setup-environment
with:
python-version: 3.14
cache-dependencies: 'true'
test:
name: Test
runs-on: ubuntu-latest
needs:
- prepare
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up environment
uses: ./.github/actions/setup-environment
with:
python-version: 3.14
- name: Test
run: poetry poe test
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
use_oidc: true
report_type: coverage
- name: Upload test results
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
use_oidc: true
report_type: test_results
lint:
name: Lint
runs-on: ubuntu-latest
needs:
- prepare
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up environment
uses: ./.github/actions/setup-environment
with:
python-version: 3.14
- name: Lint
run: poetry run pre-commit run -a --show-diff-on-failure
check-integration:
name: Check integration
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Check HACS compatibility
uses: hacs/action@22.5.0
with:
category: integration
- name: Check Hassfest
uses: home-assistant/actions/hassfest@87c064c607f3c5cc673a24258d0c98d23033bfc3
all-jobs-complete:
name: All jobs complete
runs-on: ubuntu-latest
needs:
- test
- lint
- check-integration
outputs:
passed: ${{ steps.set-output.outputs.passed }}
steps:
- name: Set output
id: set-output
run: |
echo "passed=true" >> "$GITHUB_OUTPUT"
all-jobs-pass:
name: All jobs pass
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- all-jobs-complete
steps:
- name: Check if all jobs passed
env:
PASSED: ${{ needs.all-jobs-complete.outputs.passed }}
run: |
if [ "$PASSED" != "true" ]; then
exit 1
fi
echo "All jobs passed."
is-release:
name: Check if release
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'hass-free-sleep') }}
needs:
- all-jobs-pass
outputs:
is-release: ${{ steps.check-release.outputs.is-release }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Check if release
id: check-release
env:
BEFORE: ${{ github.event.before }}
run: |
git fetch origin "$BEFORE"
MANIFEST_FILE="./custom_components/free_sleep/manifest.json"
VERSION_BEFORE="$(git show "$BEFORE":"$MANIFEST_FILE" | jq --raw-output .version)"
VERSION_AFTER="$(jq --raw-output .version "$MANIFEST_FILE")"
if [ "$VERSION_BEFORE" != "$VERSION_AFTER" ]; then
echo "is-release=true" >> "$GITHUB_OUTPUT"
else
echo "is-release=false" >> "$GITHUB_OUTPUT"
fi
publish-release:
name: Publish release
if: ${{ needs.is-release.outputs.is-release == 'true' }}
needs:
- is-release
uses: ./.github/workflows/publish-release.yaml
permissions:
contents: write