-
Notifications
You must be signed in to change notification settings - Fork 4
182 lines (162 loc) · 7.62 KB
/
sync-lockfiles.yml
File metadata and controls
182 lines (162 loc) · 7.62 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Sync Cargo lockfiles
on:
workflow_call:
inputs:
branch:
type: string
description: The branch to sync across all depedant repositories. Defaults to the default branch on each repository
required: false
toolchain:
type: string
description: The rust toolchain to use. Defaults to 1.93.0
required: false
workflow_dispatch:
inputs:
branch:
type: string
description: The branch to sync across all depedant repositories. Defaults to the default branch on each repository
required: false
toolchain:
type: string
description: The rust toolchain to use. Defaults to 1.93.0
required: false
defaults:
run:
shell: bash
jobs:
fetch:
name: Fetch Zenoh's lockfile
runs-on: ubuntu-latest
outputs:
zenoh-head-hash: ${{ steps.info.outputs.head-hash }}
zenoh-head-date: ${{ steps.info.outputs.head-date }}
steps:
- name: Checkout Zenoh
uses: actions/checkout@v4
with:
repository: eclipse-zenoh/zenoh
ref: ${{ inputs.branch }}
- id: info
name: Get HEAD info
run: |
echo "head-hash=$(git log -1 --format=%h)" >> $GITHUB_OUTPUT
echo "head-date=$(git log -1 --format=%as)" >> $GITHUB_OUTPUT
- name: Upload lockfile
uses: actions/upload-artifact@v4
with:
name: Cargo.lock
path: Cargo.lock
sync:
name: ${{ matrix.dependant }} sync Cargo.lock
needs: fetch
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dependant:
- eclipse-zenoh/zenoh-c
- eclipse-zenoh/zenoh-python
- eclipse-zenoh/zenoh-java
- eclipse-zenoh/zenoh-kotlin
- eclipse-zenoh/zenoh-plugin-dds
- eclipse-zenoh/zenoh-plugin-mqtt
- eclipse-zenoh/zenoh-plugin-ros2dds
- eclipse-zenoh/zenoh-plugin-webserver
- eclipse-zenoh/zenoh-backend-filesystem
- eclipse-zenoh/zenoh-backend-influxdb
- eclipse-zenoh/zenoh-backend-rocksdb
- eclipse-zenoh/zenoh-backend-s3
- eclipse-zenoh/zenoh-ts
steps:
- name: Checkout ${{ matrix.dependant }}
uses: actions/checkout@v4
with:
repository: ${{ matrix.dependant }}
ref: ${{ inputs.branch }}
submodules: true
token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
- name: Install Rust toolchain
# NOTE: Showing the active Rust toolchain (defined by the rust-toolchain.toml file)
# will have the side effect of installing it; if it's not installed already.
run: |
rustup update ${{ inputs.toolchain || '1.93.0' }}
rustup component add --toolchain ${{ inputs.toolchain || '1.93.0'}} clippy
# cyclors does not compile with cmake 4
- name: Install cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: "3.31.x"
- name: Install build dependencies
run: sudo apt-get install -y llvm-dev libclang-dev clang libacl1-dev
# NOTE: Not all Zenoh dependants have their Cargo manifest and lockfile
# at the repository's toplevel. The only exception being zenoh-kotlin and
# zenoh-java. Thus the need for this ugly workaround.
- name: Compute crate path of ${{ matrix.dependant }}
id: crate-path
run: |
if [[ "${{ matrix.dependant }}" =~ eclipse-zenoh/zenoh-(java|kotlin) ]]; then
echo "value=zenoh-jni" >> $GITHUB_OUTPUT
else
echo "value=." >> $GITHUB_OUTPUT
fi
- name: Compute clippy options
id: clippy-options
run: |
if [[ "${{ matrix.dependant }}" =~ eclipse-zenoh/zenoh-plugin-(ros2dds|dds) ]]; then
echo "value=--features stats,dynamic_plugin,dds_shm" >> $GITHUB_OUTPUT
else
echo "value=--all-features" >> $GITHUB_OUTPUT
fi
- name: Override ${{ matrix.dependant }} lockfile with Zenoh's
uses: actions/download-artifact@v4
with:
name: Cargo.lock
path: ${{ steps.crate-path.outputs.value }}
- name: Rectify lockfile
# NOTE: Checking the package for errors will rectify the Cargo.lock while preserving
# the dependency versions fetched from source.
run: cargo +${{ inputs.toolchain || '1.93.0' }} clippy --manifest-path ${{ steps.crate-path.outputs.value }}/Cargo.toml --all-targets ${{ steps.clippy-options.outputs.value }} -- --deny warnings
- name: Rectify lockfile for zenoh-c opaque-types
if: ${{ matrix.dependant == 'eclipse-zenoh/zenoh-c' }}
# Disable panic feature for zenoh-c opaque-types
run: |
features=$(cargo tree --manifest-path build-resources/opaque-types/Cargo.toml -f "{p} {f}" --all-features| grep opaque-types | cut -d" " -f4 | sed s/panic,//)
cargo +${{ inputs.toolchain || '1.93.0' }} clippy --manifest-path build-resources/opaque-types/Cargo.toml --all-targets --features $features -- --deny warnings
- name: cargo update ${{ matrix.dependant }}
run: cargo +${{ inputs.toolchain || '1.93.0' }} update zenoh --manifest-path ${{ steps.crate-path.outputs.value }}/Cargo.toml
- name: cargo update for zenoh-c build-resources
if: ${{ matrix.dependant == 'eclipse-zenoh/zenoh-c' }}
run: cargo +${{ inputs.toolchain || '1.93.0' }} update zenoh --manifest-path build-resources/opaque-types/Cargo.toml
- name: Create/Update a pull request if the lockfile changed
id: cpr
# NOTE: If there is a pending PR, this action will simply update it with a forced push.
uses: peter-evans/create-pull-request@v7
with:
title: Sync `Cargo.lock` with Zenoh `${{ needs.fetch.outputs.zenoh-head-hash }}` from `${{needs.fetch.outputs.zenoh-head-date }}`
body: |
This pull request synchronizes ${{ matrix.dependant }}'s Cargo lockfile with Zenoh's. This is done to ensure ABI compatibility between Zenoh applications, backends & plugins.
- **sha**: eclipse-zenoh/zenoh@${{ needs.fetch.outputs.zenoh-head-hash }}
- **date**: ${{ needs.fetch.outputs.zenoh-head-date }}
- **workflow**: [${{ github.run_id}}](https://github.com/eclipse-zenoh/ci/actions/runs/${{ github.run_id }})
commit-message: "build: Sync Cargo lockfile with Zenoh's"
committer: eclipse-zenoh-bot <eclipse-zenoh-bot@users.noreply.github.com>
author: eclipse-zenoh-bot <eclipse-zenoh-bot@users.noreply.github.com>
base: ${{ inputs.branch }}
branch: eclipse-zenoh-bot/sync-lockfile
delete-branch: true
labels: dependencies, internal
token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
- name: Enable auto merge for the pull request
if: contains(fromJSON('["created", "updated"]'), steps.cpr.outputs.pull-request-operation)
run: >
gh pr merge "${{ steps.cpr.outputs.pull-request-number }}"
--subject "build: Sync `Cargo.lock` with eclipse-zenoh/zenoh@${{ needs.fetch.outputs.zenoh-head-hash }} from ${{ needs.fetch.outputs.zenoh-head-date }} (#${{ steps.cpr.outputs.pull-request-number }})"
--repo "${{ matrix.dependant }}"
--squash
--auto
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}
- name: Add the PR as annotation to workflow run
if: contains(fromJSON('["created", "updated"]'), steps.cpr.outputs.pull-request-operation)
run: >
echo "::notice:: PR ${{ steps.cpr.outputs.pull-request-operation }}: https://github.com/${{ matrix.dependant}}/pull/${{ steps.cpr.outputs.pull-request-number }}"