Skip to content
Snippets Groups Projects
Unverified Commit d6cf147c authored by Przemek Rzad's avatar Przemek Rzad Committed by GitHub
Browse files

Filter workspace dependencies in the templates (#4599)

This detaches the templates from monorepo's workspace dependencies.

Currently the templates [re-use the monorepo's
dependencies](https://github.com/paritytech/polkadot-sdk-minimal-template/blob/bd8afe66ec566d61f36b0e3d731145741a9e9e19/Cargo.toml#L45-L58),
most of which are not needed.

The simplest approach is to specify versions directly and not use
workspace dependencies in the templates.

Another approach would be to programmatically filter dependencies that
are actually needed - but not sure if it's worth it, given that it would
complicate the synchronization job.

cc @Kianenigma @gupnik
parent 2b1c606a
No related merge requests found
Pipeline #478810 waiting for manual action with stages
in 1 hour, 18 minutes, and 21 seconds
......@@ -104,8 +104,6 @@ jobs:
toml set templates/${{ matrix.template }}/Cargo.toml 'workspace.package.edition' "$(toml get --raw Cargo.toml 'workspace.package.edition')" > Cargo.temp
mv Cargo.temp ./templates/${{ matrix.template }}/Cargo.toml
toml get Cargo.toml 'workspace.dependencies' --output-toml >> ./templates/${{ matrix.template }}/Cargo.toml
working-directory: polkadot-sdk
- name: Print the result Cargo.tomls for debugging
if: runner.debug == '1'
......@@ -118,6 +116,18 @@ jobs:
- name: Copy over the new changes
run: |
cp -r polkadot-sdk/templates/${{ matrix.template }}/* "${{ env.template-path }}/"
- name: Copy over required workspace dependencies
run: |
echo -e "\n[workspace.dependencies]" >> Cargo.toml
set +e
# If a workspace dependency is required..
while cargo tree --depth 1 --prefix none --no-dedupe 2>&1 | grep 'was not found in `workspace.dependencies`'; do
# Get its name..
missing_dep=$(cargo tree --depth 1 --prefix none --no-dedupe 2>&1 | grep 'was not found in `workspace.dependencies`' | sed -E 's/(.*)`dependency.(.*)` was not found in `workspace.dependencies`/\2/')
# And copy the dependency from the monorepo.
toml get ../polkadot-sdk/Cargo.toml 'workspace.dependencies' --output-toml | grep "^${missing_dep} = " >> Cargo.toml
done;
working-directory: "${{ env.template-path }}"
# 3. Verify the build. Push the changes or create a PR.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment