-
-
Notifications
You must be signed in to change notification settings - Fork 120
203 lines (191 loc) · 6.85 KB
/
ci_main.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: CI Main
on:
push:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
# This job is used to detect duplicate runs and skip one of them
# (For example when pushing a commit to an open pull request)
# See: https://github.com/fkirc/skip-duplicate-actions?tab=readme-ov-file#skip-concurrent-workflow-runs
pre_job:
runs-on: ubuntu-22.04
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- name: Print event details
run: |
echo "This run was triggered by $GITHUB_EVENT_NAME event."
cat $GITHUB_EVENT_PATH | jq .
- name: Detect duplicate runs
id: skip_check
uses: fkirc/[email protected]
with:
concurrent_skipping: 'same_content_newer'
skip_after_successful_duplicate: 'true'
- name: Clone Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Perform version check
run: |
./scripts/check_version.sh
# This job detects changes in the diff and set some ouput variables accordingly.
# It is use to conditionaly run different jobs and steps of the pipeline
changes:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-22.04
permissions:
pull-requests: read
outputs:
common: ${{ steps.filter.outputs.common }}
linux: ${{ steps.filter.outputs.linux }}
windows: ${{ steps.filter.outputs.windows }}
macos: ${{ steps.filter.outputs.macos }}
python: ${{ steps.filter.outputs.python }}
rust: ${{ steps.filter.outputs.rust }}
docs: ${{ steps.filter.outputs.docs }}
miscs: ${{ steps.filter.outputs.miscs }}
changes: ${{ steps.filter.outputs.changes }}
steps:
- name: Clone Repository
uses: actions/checkout@v4
- name: Detect file changes
uses: dorny/paths-filter@v3
id: filter
with:
list-files: shell
filters: |
miscs:
- '.github/workflows/**'
- '.github/actions/**'
- 'examples/simpleble/**'
- 'cmake/**'
common: &common
- 'simpleble/include/**'
- 'simpleble/src/builders/**'
- 'simpleble/src/external/**'
- 'simpleble/src/frontends/**'
- 'simpleble/src/backends/common/**'
- 'external/**'
windows: &windows
- *common
- 'simpleble/src/backends/windows/**'
linux: &linux
- *common
- 'simpleble/src/backends/linux/**'
- 'simpledbus/**'
- 'examples/simpledbus/**'
- 'simplebluez/**'
- 'examples/simplebluez/**'
macos: &macos
- *common
- 'simpleble/src/backends/macos/**'
python:
- 'simpleble/src/backends/plain/**'
- 'simpleble/src/frontends/**'
- 'simplepyble/**'
- 'setup.py'
rust:
- *linux
- *macos
- 'simplersble/**'
- 'Cargo.lock'
- 'Cargo.toml'
docs:
- 'docs/**'
- '**/*.md'
- '**/*.rst'
# This job is used to dynamically generate the build matrix of 'build' job in 'ci_linux.yml'.
# The output variable 'values' is a list of strings: 'simpledbus', 'simplebluez' and 'simpleble'.
# This is not inside pre-job because 'changes' variable is set by dorny/paths-filter to ALL the filters
# that match, so we need to have a job with only these three filters.
# Note that the filters are defined in a way that makes each of them depend on the previous one.
# If in main branch, all libraries are listed in the output even if there are no matching changes.
libraries:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-22.04
permissions:
pull-requests: read
outputs:
values: ${{ github.ref == 'refs/heads/main' && '["simpledbus","simplebluez","simpleble"]' || steps.filter.outputs.changes }}
steps:
- name: Clone Repository
uses: actions/checkout@v4
- name: Detect file changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
simpledbus: &simpledbus
- 'simpledbus/**'
simplebluez: &simplebluez
- *simpledbus
- 'simplebluez/**'
simpleble: &simpleble
- *simplebluez
- 'simpleble/**'
lint:
needs: pre_job
if: |
needs.pre_job.outputs.should_skip != 'true'
uses: ./.github/workflows/ci_lint.yml
docs:
needs: [pre_job, changes]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.docs == 'true' || github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_docs.yml
windows:
needs: [pre_job, changes]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.windows == 'true' ||
needs.changes.outputs.miscs == 'true' ||
github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_windows.yml
linux:
needs: [pre_job, changes, libraries]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.linux == 'true' ||
needs.changes.outputs.miscs == 'true' ||
github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_linux.yml
with:
libraries: ${{ needs.libraries.outputs.values }}
macos:
needs: [pre_job, changes]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.macos == 'true' ||
needs.changes.outputs.miscs == 'true' ||
github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_macos.yml
python:
needs: [pre_job, changes]
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.python == 'true' || github.ref == 'refs/heads/main')
uses: ./.github/workflows/ci_python.yml
secrets: inherit
release-python:
needs: [pre_job, changes, windows, linux, macos, python]
# Note that Python is released on every commit in main branch with relevant
# changes (python, linux, windows, or macos filters). While cpp binaries are
# only published on manual releases.
if: |
needs.pre_job.outputs.should_skip != 'true' &&
(needs.changes.outputs.python == 'true' ||
needs.changes.outputs.windows == 'true' ||
needs.changes.outputs.linux == 'true' ||
needs.changes.outputs.macos == 'true') &&
github.ref == 'refs/heads/main'
uses: ./.github/workflows/ci_python_publish.yml
with:
tag: ${{ github.ref }}
secrets: inherit