diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/.github/workflows/sync-lockfiles.yml b/.github/workflows/sync-lockfiles.yml new file mode 100644 index 0000000000..84d862c693 --- /dev/null +++ b/.github/workflows/sync-lockfiles.yml @@ -0,0 +1,91 @@ +name: Sync Cargo lockfile with Zenoh's dependants + +on: + schedule: + - cron: "0 0 * * *" # At the end of every day + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + sync: + name: Sync Cargo lockfile with ${{ matrix.dependant }} + runs-on: ubuntu-latest + strategy: + matrix: + dependant: + - zenoh-c + - zenoh-python + - zenoh-java + - zenoh-kotlin + - zenoh-plugin-dds + - zenoh-plugin-mqtt + - zenoh-plugin-ros1 + - zenoh-plugin-ros2dds + - zenoh-plugin-webserver + - zenoh-backend-filesystem + - zenoh-backend-influxdb + - zenoh-backend-rocksdb + - zenoh-backend-s3 + steps: + - name: Checkout ${{ matrix.dependant }} + uses: actions/checkout@v4 + with: + 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 show + + # 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 Cargo manifest path of ${{ matrix.dependant }} + id: manifest-path + run: | + if [[ "${{ matrix.dependant }}" =~ zenoh-(java|kotlin) ]]; then + echo "value=./zenoh-jni/Cargo.toml" >> $GITHUB_OUTPUT + else + echo "value=./Cargo.toml" >> $GITHUB_OUTPUT + fi + + - name: Override ${{ matrix.dependant }} lockfile with Zenoh's + # NOTE: We assume that the lockfile resides in the same directory as the manifest. + run: | + MANIFEST_PATH=${{ steps.manifest-path.outputs.value }} + curl "https://raw.githubusercontent.com/eclipse-zenoh/zenoh/Cargo.lock" --output ${MANIFEST_PATH/toml/lock} + + - name: Rectify lockfile + # NOTE: Checking the package for errors will rectify the Cargo.lock while preserving + # the dependency versions fetched from source. + run: cargo check --manifest-path ${{ steps.manifest-path.outputs.value }} + + - 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@v5 + with: + title: Sync lockfile with Zenoh's + body: Automated synchronization of the Cargo lockfile with Zenoh. This is done to ensure plugin ABI compatibility. + commit-message: "chore: Sync Cargo lockfile with Zenoh's" + committer: eclipse-zenoh-bot + author: eclipse-zenoh-bot + branch: eclipse-zenoh-bot/sync-lockfile + delete-branch: true + labels: dependencies + token: ${{ secrets.BOT_TOKEN_WORKFLOW }} + + - name: Auto approve the pull request + if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }} + run: gh pr review -R "eclipse-zenoh/${{ matrix.dependant }}" --approve "${{ steps.cpr.outputs.pull-request-number }}" + env: + GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }} + + - name: Enable auto merge for the pull request + if: steps.cpr.outputs.pull-request-operation == 'created' + run: gh pr merge -R "eclipse-zenoh/${{ matrix.dependant }}" --merge --auto "${{ steps.cpr.outputs.pull-request-number }}" + env: + GH_TOKEN: ${{ secrets.BOT_TOKEN_WORKFLOW }}