@@ -18,6 +18,98 @@ Every pull request should document all changes made in the [changelog].
18
18
If your name does not already appear in the [ AUTHORS] file, please feel free to
19
19
add it as part of your patch.
20
20
21
+ ## Preparing for a new release
22
+
23
+ ### Changelog
24
+
25
+ - Add a new * Unreleased* section by copying the current one.
26
+ Keep the sections, but delete the entries.
27
+ - Rename the old * Unreleased* section to the target release version and add the release date.
28
+ - Add the correct link for the target release revision to the bottom of the file.
29
+ - Delete any empty sections.
30
+ - Tidy up the entries, possibly reordering some for more logical grouping.
31
+
32
+ ### Dependencies
33
+
34
+ Rust dependencies like druid specify their own sub-dependencies in ` Cargo.toml ` .
35
+ These specifications are usually version ranges according to [ semver] ,
36
+ stating that the dependency requires a sub-dependency of the specified version
37
+ or any newer version that is still compatible. It is up to the final application
38
+ to choose which actual versions get used via the ` Cargo.lock ` file of that application.
39
+
40
+ Because the final application chooses the sub-dependency versions and they are most likely
41
+ going to be higher than the minimum that is specified in our ` Cargo.toml ` file,
42
+ we need to make sure that druid works properly with these newer versions.
43
+ Yes according to [ semver] rules they should work, but library authors make mistakes
44
+ and it won't be a good experience or a sign of druid quality if a new developer
45
+ adds druid as a dependency and it won't even compile.
46
+ For that reason our CI testing always uses the highest version that is still compatible.
47
+ This mimics what a new developer would experience when they start using druid.
48
+
49
+ What about the the minimum supported version or all the versions between the minimum and maximum?
50
+ It is not practical for us to test all the combinations of possible sub-dependency versions.
51
+ Without testing there can easily be mistakes. Let's say our ` Cargo.toml ` specifies that
52
+ we depend on the package ` foo ` version ` ^1.1.1 ` and the latest ` foo ` version is ` 1.1.3 ` .
53
+ The CI tests with ` 1.1.3 ` and contributors have ` 1.1.3 ` in their local ` Cargo.lock ` .
54
+ ` Cargo.toml ` specifies ` 1.1.1 ` as the minimum because that was the latest version
55
+ when the dependency was added and ` 1.1.1 ` did work just fine originally.
56
+ However it turns out that this specific version had a bug which doesn't interact well
57
+ with some other package ` bar ` . Our CI testing or manual testing would never find this out,
58
+ because we're already using ` 1.1.3 ` and deleting and regenerating ` Cargo.lock ` wouldn't change that.
59
+ Just because ` 1.1.1 ` used to work back in the day doesn't mean that it will always keep working.
60
+
61
+ One partial solution to this problem is to be more precise in what we are actually promising.
62
+ So whenever we release a new version we also update all our dependencies in ` Cargo.toml `
63
+ to match the versions that we are actually testing with. This will be much more accurate
64
+ to the spirit of the version specification - druid will work with the specified version
65
+ and any newer one if it's [ semver] compatible. We're not testing the extremely big matrix of
66
+ old versions of our sub-dependencies and so we shouldn't claim that the old versions will work.
67
+
68
+ #### Prerequisites for updating the dependency specifications
69
+
70
+ An easy way to do this is to use the ` cargo upgrade ` tool available via [ cargo-edit] .
71
+
72
+ ```
73
+ cargo install cargo-edit
74
+ ```
75
+
76
+ #### Performing the update
77
+
78
+ All of the following commands must be run from the root workspace.
79
+
80
+ First we want to update our ` Cargo.lock ` file to contain the newest versions
81
+ which are still [ semver] compatible with what we have specified in our ` Cargo.toml ` files.
82
+
83
+ If you just want to see what would happen you can add the ` --dry-run ` option.
84
+
85
+ ```
86
+ cargo update
87
+ ```
88
+
89
+ Now we'll use the ` cargo upgrade ` command to update all the versions in the ` Cargo.toml `
90
+ files to match the versions specified in ` Cargo.lock ` . It's crucial that we use the
91
+ ` --to-lockfile ` option, because without it ` cargo upgrade ` won't respect semver.
92
+
93
+ If you just want to see what would happen you can add the ` --dry-run ` option.
94
+
95
+ ```
96
+ cargo upgrade --workspace --to-lockfile
97
+ ```
98
+
99
+ #### Semver incompatible updates
100
+
101
+ Incompatible version updates should be done manually after carefully reviewing the changes.
102
+ However you can still use the ` cargo upgrade ` tool to find out which dependencies could be updated.
103
+
104
+ ```
105
+ cargo upgrade --workspace --dry-run
106
+ ```
107
+
108
+ Then based on the reported potential updates you should manually go and check out what has changed,
109
+ plus how and if it makes sense to update to the newer version.
110
+
21
111
[ GitHub Help ] : https://help.github.com/articles/about-pull-requests/
22
112
[ AUTHORS ] : AUTHORS
23
113
[ changelog ] : CHANGELOG.md
114
+ [ cargo-edit ] : https://github.com/killercup/cargo-edit
115
+ [ semver ] : https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
0 commit comments