-
Notifications
You must be signed in to change notification settings - Fork 15
178 lines (155 loc) · 5.92 KB
/
ci.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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: ["**"]
workflow_call:
workflow_dispatch:
jobs:
build-zenoh-c:
name: Build Zenoh-C
runs-on: ubuntu-latest
env:
Zenoh_C_Repo: https://github.com/eclipse-zenoh/zenoh-c.git
Zenoh_C_Cache_PFX: libzenohc
outputs:
Zenoh_C_Cache: ${{ env.Zenoh_C_Cache_PFX }}-${{ steps.zenoh-c-head.outputs.Zenoh_C_HEAD }}
steps:
- name: Check remote head hash
id: zenoh-c-head
shell: bash
run: '{ echo -n "Zenoh_C_HEAD="; git ls-remote "$Zenoh_C_Repo" HEAD | cut -f1; } | tee -a "$GITHUB_OUTPUT"'
- name: Cache compiled zenoh-c library
id: cache-libzenohc
uses: actions/cache@v4
with:
key: ${{ env.Zenoh_C_Cache_PFX }}-${{ steps.zenoh-c-head.outputs.Zenoh_C_HEAD }}
path: |
~/local
- name: Install Rust toolchain
if: ${{ steps.cache-libzenohc.outputs.cache-hit != 'true' }}
run: rustup component add rustfmt clippy
# NOTE: Checks out the head revision we found using ls-remote above
# to avoid race conditions resulting in mismatch between cache
# and contents of repo.
- name: Clone Zenoh-C
if: ${{ steps.cache-libzenohc.outputs.cache-hit != 'true' }}
env:
Zenoh_C_HEAD: ${{ steps.zenoh-c-head.outputs.Zenoh_C_HEAD }}
shell: bash
run: |
pwd
git clone "$Zenoh_C_Repo"
cd zenoh-c && git checkout "$Zenoh_C_HEAD"
- name: Build and install Zenoh-C
if: ${{ steps.cache-libzenohc.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p zenoh-c/build && cd zenoh-c/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local
cmake --build . --target install --config Release -- -j
build-up-cpp:
name: Build up-cpp
runs-on: ubuntu-latest
env:
UP_CPP_Repo: https://github.com/eclipse-uprotocol/up-cpp.git
UP_CPP_Cache_PFX: up-cpp-conan2
outputs:
UP_CPP_Cache: ${{ env.UP_CPP_Cache_PFX }}-${{ steps.up-cpp-head.outputs.UP_CPP_HEAD }}
steps:
- name: Check remote head hash
id: up-cpp-head
shell: bash
run: '{ echo -n "UP_CPP_HEAD="; git ls-remote "$UP_CPP_Repo" HEAD | cut -f1; } | tee -a "$GITHUB_OUTPUT"'
- name: Cache conan artifacts
id: cache-conan2
uses: actions/cache@v4
with:
key: ${{ env.UP_CPP_Cache_PFX }}-${{ steps.up-cpp-head.outputs.UP_CPP_HEAD }}
path: |
~/.conan2
- name: Install Conan
if: ${{ steps.cache-conan2.outputs.cache-hit != 'true' }}
id: conan
uses: turtlebrowser/get-conan@main
- name: Create default Conan profile
if: ${{ steps.cache-conan2.outputs.cache-hit != 'true' }}
run: conan profile detect
# NOTE: Checks out the head revision we found using ls-remote above
# to avoid race conditions resulting in mismatch between cache
# and contents of repo.
- name: Clone up-cpp repo
if: ${{ steps.cache-conan2.outputs.cache-hit != 'true' }}
shell: bash
env:
UP_CPP_HEAD: ${{ steps.up-cpp-head.outputs.UP_CPP_HEAD }}
run: |
git clone "$UP_CPP_Repo"
cd up-cpp && git checkout "$UP_CPP_HEAD"
git submodule update --init --recursive
- name: Create up-cpp Conan package
if: ${{ steps.cache-conan2.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd up-cpp
conan create . --build=missing
- name: Clean up conan build files
if: ${{ steps.cache-conan2.outputs.cache-hit != 'true' }}
run: conan cache clean '*'
build-up-client-zenoh-cpp:
name: Build up-client-zenoh-cpp
needs: [ build-zenoh-c, build-up-cpp ]
runs-on: ubuntu-latest
env:
Zenoh_C_Cache: ${{ needs.build-zenoh-c.outputs.Zenoh_C_Cache }}
UP_CPP_Cache: ${{ needs.build-up-cpp.outputs.UP_CPP_Cache }}
steps:
# Note: will never update here since it will always match from previous job
- name: Get cached zenoh-c library
uses: actions/cache@v4
with:
key: ${{ env.Zenoh_C_Cache }}
path: |
~/local
# Note: will never update here since it will always match from previous job
- name: Get cached up-cpp conan artifacts
uses: actions/cache@v4
with:
key: ${{ env.UP_CPP_Cache }}
path: |
~/.conan2
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
- uses: actions/checkout@v4
- name: Build and install up-client-zenoh-cpp
shell: bash
run: |
export CMAKE_PREFIX_PATH="$HOME/local"
export CMAKE_ZENOH_INCLUDE_PATH="$HOME/local/include"
mkdir build
cd build
conan install ../ -o build_unbundled=True -o zenoh_package=False
cmake ../ -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local
cmake --build . --target install --config Release -- -j
- name: Upload test binaries
uses: actions/upload-artifact@v4
with:
name: tests_up-client-zenoh-cpp
path: |
build/bin
retention-days: 1
# NOTE: In GitHub repository settings, the "Require status checks to pass
# before merging" branch protection rule ensures that commits are only merged
# from branches where specific status checks have passed. These checks are
# specified manually as a list of workflow job names. Thus we use this extra
# job to signal whether all CI checks have passed.
ci:
name: CI status checks
runs-on: ubuntu-latest
needs: [ build-zenoh-c, build-up-cpp, build-up-client-zenoh-cpp ]
if: always()
steps:
- name: Check whether all jobs pass
run: echo '${{ toJson(needs) }}' | jq -e 'all(.result == "success")'