Skip to content

Commit 8690abe

Browse files
authored
Merge pull request #1916 from input-output-hk/sfa/script_to_upgrade_dependencies
Add a script to update all dependencies
2 parents 6f9da0c + 52c9a94 commit 8690abe

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

docs/runbook/upgrade-repository-dependencies/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@
44

55
This runbook provides step-by-step instructions to upgrade the dependencies in the repository, including Rust crates, documentation, and JavaScript packages.
66

7+
## Update dependencies tool
8+
9+
The `update_dependencies.sh` script allows you to to update dependencies performing all the steps described in the next chapter.
10+
11+
It requires having `cargo-edit` installed, which can be done with the following command:
12+
13+
```
14+
cargo install cargo-edit
15+
```
16+
17+
To start the update, execute the command:
18+
19+
```
20+
. ../docs/runbook/upgrade-repository-dependencies/upgrade-dependencies.sh
21+
```
22+
23+
By default, Rust dependencies are updated to the latest version. If you want to only update to the latest compatible versions, add the `--incompatible` option to the command.
24+
25+
**Warning**: Before re-running the script, you need to revert the modified code to its original state to avoid incrementing the versions of crates and JSON packages twice.
26+
727
## Steps
828

929
### Upgrade Rust outdated dependencies
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
# get command line arguments to pass them to `cargo upgrade` command
4+
# By default, we allow upgrading all dependencies to the latest one.
5+
# If you want to upgrade only to the compatible version, launch script with option `--compatbile`
6+
CARGO_UPGRADE_OPTIONS=${*:-"--incompatible"}
7+
8+
# Need to install `cargo-edit` to execute `cargo upgrade` and `cargo set-version` commands
9+
10+
# Upgrade Rust outdated dependencies
11+
cargo upgrade "${CARGO_UPGRADE_OPTIONS}" --verbose
12+
# cargo upgrade -i allow --verbose
13+
# Let the CI run the tests at the end of the script
14+
# cargo test --all-features
15+
git commit -am "chore: update Rust dependencies"
16+
17+
# Bump Rust crates versions
18+
cargo set-version --bump patch
19+
git commit -am "chore: bump crates versions"
20+
21+
# Upgrade the documentation website dependencies
22+
pushd docs/website || exit
23+
make upgrade
24+
popd || exit
25+
git commit -am "chore: upgrade doc dependencies
26+
27+
By running 'make upgrade' command."
28+
29+
# Upgrade the explorer dependencies
30+
pushd mithril-explorer || exit
31+
make upgrade
32+
popd || exit
33+
git commit -am "chore: upgrade explorer dependencies
34+
35+
By running 'make upgrade' command."
36+
37+
# Upgrade www/ and www-test/ dependencies
38+
pushd mithril-client-wasm || exit
39+
make upgrade-www-deps
40+
popd || exit
41+
42+
git commit -am "chore: upgrade mithril client wasm 'www' and 'www-test' dependencies
43+
44+
By running 'make upgrade-www-deps' command."
45+
46+
# Bump Javascript packages versions
47+
48+
# Search all package.json files and bump the version
49+
# and exclude `package.json` in `node_modules` folder
50+
for package_json_file in $(find . -name package.json | grep -v "/node_modules/"); do
51+
folder="$(dirname $package_json_file)"
52+
pushd "$folder" || exit
53+
npm version patch
54+
popd || exit
55+
done
56+
57+
pushd mithril-client-wasm || exit
58+
make www-install www-test-install
59+
popd || exit
60+
61+
pushd mithril-explorer || exit
62+
make install
63+
popd || exit
64+
65+
pushd docs/website || exit
66+
make install
67+
popd || exit
68+
69+
git commit -am "chore: bump mithril client wasm 'www' and 'www-test' dependencies
70+
71+
By running:
72+
- 'make www-install' command in 'mithril-client-wasm'.
73+
- 'make www-test-install' command in 'mithril-client-wasm'.
74+
- 'make install' command in 'mithril-explorer'.
75+
- 'make install' command in 'docs/website'."
76+
77+
# create a temporary script file that print "hello"
78+
TMP_SCRIPT_DIR=/tmp/mithril
79+
FLAKE_UPDATE_SCRIPT=nix_flake_update.sh
80+
81+
mkdir -p "$TMP_SCRIPT_DIR"
82+
echo "git config --global --add safe.directory '*'
83+
nix --extra-experimental-features 'nix-command flakes' flake update" > "$TMP_SCRIPT_DIR/$FLAKE_UPDATE_SCRIPT"
84+
85+
# The nix update is deactivated while waiting to be compatible with the latest version
86+
# # Upgrade Nix Flake dependencies
87+
# docker run -v "$(pwd)":/mithril -v "$TMP_SCRIPT_DIR":/scripts/mithril -w /mithril nixos/nix /bin/sh -c ". /scripts/mithril/$FLAKE_UPDATE_SCRIPT"
88+
# rm "$TMP_SCRIPT_DIR/$FLAKE_UPDATE_SCRIPT"
89+
#
90+
# git commit -am "chore: update nix flake dependencies
91+
# 
92+
# By running 'nix flake update' command."

0 commit comments

Comments
 (0)