Skip to content

Commit

Permalink
Fix workflow sync lockfiles (2) (eclipse-zenoh#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz authored Jan 15, 2024
1 parent 1b9a576 commit 40d1c1e
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/sync-lockfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,24 @@ defaults:
shell: bash

jobs:
fetch:
name: Fetch Zenoh's lockfile
runs-on: ubuntu-latest
steps:
- name: Checkout Zenoh
uses: actions/checkout@v4
with:
repository: eclipse-zenoh/zenoh

- name: Upload lockfile
uses: actions/upload-artifact@v3
with:
name: Cargo.lock
path: Cargo.lock

sync:
name: Sync Cargo lockfile with ${{ matrix.dependant }}
needs: fetch
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -33,6 +49,8 @@ jobs:
- name: Checkout ${{ matrix.dependant }}
uses: actions/checkout@v4
with:
repository: eclipse-zenoh/${{ matrix.dependant }}
submodules: true
token: ${{ secrets.BOT_TOKEN_WORKFLOW }}

- name: Install Rust toolchain
Expand All @@ -43,25 +61,25 @@ jobs:
# 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
- name: Compute crate path of ${{ matrix.dependant }}
id: crate-path
run: |
if [[ "${{ matrix.dependant }}" =~ zenoh-(java|kotlin) ]]; then
echo "value=./zenoh-jni/Cargo.toml" >> $GITHUB_OUTPUT
echo "value=zenoh-jni" >> $GITHUB_OUTPUT
else
echo "value=./Cargo.toml" >> $GITHUB_OUTPUT
echo "value=." >> $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/main/Cargo.lock" --output ${MANIFEST_PATH/toml/lock}
uses: actions/download-artifact@v3
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 check --manifest-path ${{ steps.manifest-path.outputs.value }}
run: cargo check --manifest-path ${{ steps.crate-path.outputs.value }}/Cargo.toml

- name: Create/Update a pull request if the lockfile changed
id: cpr
Expand Down

0 comments on commit 40d1c1e

Please sign in to comment.